Pass all options for static target from formula
Change-Id: I21c84341d5a585862d21f75a4d263f8f5781675d
This commit is contained in:
parent
dd19c7f616
commit
94c1a3c99a
3 changed files with 33 additions and 19 deletions
|
@ -8,6 +8,7 @@ parameters:
|
||||||
enabled: true
|
enabled: true
|
||||||
dir:
|
dir:
|
||||||
config: /srv/volumes/prometheus/server
|
config: /srv/volumes/prometheus/server
|
||||||
|
config_in_container: /srv/prometheus
|
||||||
data: /srv/volumes/local/prometheus/server
|
data: /srv/volumes/local/prometheus/server
|
||||||
bind:
|
bind:
|
||||||
port: 9090
|
port: 9090
|
||||||
|
|
|
@ -42,7 +42,19 @@ rule_files:
|
||||||
{%- set static_grain = node_grains.get('prometheus', {}).get('server', {}).get('target', {}).get('static', {}) %}
|
{%- set static_grain = node_grains.get('prometheus', {}).get('server', {}).get('target', {}).get('static', {}) %}
|
||||||
{%- for job_name, job in static_grain.iteritems() %}
|
{%- for job_name, job in static_grain.iteritems() %}
|
||||||
{%- if static_target[job_name] is not defined %}
|
{%- if static_target[job_name] is not defined %}
|
||||||
{%- do static_target.update({job_name: {}}) %}
|
{%- do static_target.update({job_name: {
|
||||||
|
'enabled': job.get('enabled', True),
|
||||||
|
'scheme': job.get('scheme', 'http')}
|
||||||
|
}) %}
|
||||||
|
{%- if job.get('tls_config') %}
|
||||||
|
{%- do static_target[job_name].update({
|
||||||
|
'tls_config': {
|
||||||
|
'skip_verify': job.get('tls_config', {}).get('skip_verify', False),
|
||||||
|
'cert_name': job.get('tls_config', {}).get('cert_name'),
|
||||||
|
'key_name': job.get('tls_config', {}).get('key_name')
|
||||||
|
}
|
||||||
|
}) %}
|
||||||
|
{%- endif %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if static_target[job_name]['endpoint'] is not defined %}
|
{%- if static_target[job_name]['endpoint'] is not defined %}
|
||||||
{%- do static_target[job_name].update({'endpoint': []}) %}
|
{%- do static_target[job_name].update({'endpoint': []}) %}
|
||||||
|
@ -72,8 +84,8 @@ scrape_configs:
|
||||||
{%- if job.get('tls_config') %}
|
{%- if job.get('tls_config') %}
|
||||||
tls_config:
|
tls_config:
|
||||||
{% if job.tls_config.get('skip_verify') is defined %}insecure_skip_verify: {{ job.tls_config.skip_verify | lower }}{%- endif %}
|
{% if job.tls_config.get('skip_verify') is defined %}insecure_skip_verify: {{ job.tls_config.skip_verify | lower }}{%- endif %}
|
||||||
{% if job.tls_config.get('cert_name') %}cert_file: {{ job.tls_config.ssl_dir }}/{{ job.tls_config.cert_name }}{%- endif %}
|
{% if job.tls_config.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ job.tls_config.cert_name }}{%- endif %}
|
||||||
{% if job.tls_config.get('key_name') %}key_file: {{ job.tls_config.ssl_dir }}/{{ job.tls_config.key_name }}{%- endif %}
|
{% if job.tls_config.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ job.tls_config.key_name }}{%- endif %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: [{{ nodes | join(',') }}]
|
- targets: [{{ nodes | join(',') }}]
|
||||||
|
@ -103,15 +115,15 @@ scrape_configs:
|
||||||
scheme: https
|
scheme: https
|
||||||
tls_config:
|
tls_config:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
{% if kubernetes_target.get('cert_name') %}cert_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
{% if kubernetes_target.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
||||||
{% if kubernetes_target.get('key_name') %}key_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.key_name }}{%- endif %}
|
{% if kubernetes_target.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
||||||
kubernetes_sd_configs:
|
kubernetes_sd_configs:
|
||||||
- api_server: {{ kubernetes_target.api_ip }}
|
- api_server: {{ kubernetes_target.api_ip }}
|
||||||
role: endpoints
|
role: endpoints
|
||||||
tls_config:
|
tls_config:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
{% if kubernetes_target.get('cert_name') %}cert_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
{% if kubernetes_target.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
||||||
{% if kubernetes_target.get('key_name') %}key_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.key_name }}{%- endif %}
|
{% if kubernetes_target.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
||||||
relabel_configs:
|
relabel_configs:
|
||||||
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
|
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
|
||||||
action: keep
|
action: keep
|
||||||
|
@ -121,15 +133,15 @@ scrape_configs:
|
||||||
scheme: https
|
scheme: https
|
||||||
tls_config:
|
tls_config:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
{% if kubernetes_target.get('cert_name') %}cert_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
{% if kubernetes_target.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
||||||
{% if kubernetes_target.get('key_name') %}key_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.key_name }}{%- endif %}
|
{% if kubernetes_target.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
||||||
kubernetes_sd_configs:
|
kubernetes_sd_configs:
|
||||||
- api_server: {{ kubernetes_target.api_ip }}
|
- api_server: {{ kubernetes_target.api_ip }}
|
||||||
role: node
|
role: node
|
||||||
tls_config:
|
tls_config:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
{% if kubernetes_target.get('cert_name') %}cert_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
{% if kubernetes_target.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
||||||
{% if kubernetes_target.get('key_name') %}key_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.key_name }}{%- endif %}
|
{% if kubernetes_target.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
||||||
relabel_configs:
|
relabel_configs:
|
||||||
- action: labelmap
|
- action: labelmap
|
||||||
regex: __meta_kubernetes_node_label_(.+)
|
regex: __meta_kubernetes_node_label_(.+)
|
||||||
|
@ -139,15 +151,15 @@ scrape_configs:
|
||||||
scheme: https
|
scheme: https
|
||||||
tls_config:
|
tls_config:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
{% if kubernetes_target.get('cert_name') %}cert_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
{% if kubernetes_target.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
||||||
{% if kubernetes_target.get('key_name') %}key_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.key_name }}{%- endif %}
|
{% if kubernetes_target.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
||||||
kubernetes_sd_configs:
|
kubernetes_sd_configs:
|
||||||
- api_server: {{ kubernetes_target.api_ip }}
|
- api_server: {{ kubernetes_target.api_ip }}
|
||||||
role: endpoints
|
role: endpoints
|
||||||
tls_config:
|
tls_config:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
{% if kubernetes_target.get('cert_name') %}cert_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
{% if kubernetes_target.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
||||||
{% if kubernetes_target.get('key_name') %}key_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.key_name }}{%- endif %}
|
{% if kubernetes_target.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
||||||
relabel_configs:
|
relabel_configs:
|
||||||
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
|
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
|
||||||
action: keep
|
action: keep
|
||||||
|
@ -186,15 +198,15 @@ scrape_configs:
|
||||||
scheme: https
|
scheme: https
|
||||||
tls_config:
|
tls_config:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
{% if kubernetes_target.get('cert_name') %}cert_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
{% if kubernetes_target.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
||||||
{% if kubernetes_target.get('key_name') %}key_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.key_name }}{%- endif %}
|
{% if kubernetes_target.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
||||||
kubernetes_sd_configs:
|
kubernetes_sd_configs:
|
||||||
- api_server: {{ kubernetes_target.api_ip }}
|
- api_server: {{ kubernetes_target.api_ip }}
|
||||||
role: pod
|
role: pod
|
||||||
tls_config:
|
tls_config:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
{% if kubernetes_target.get('cert_name') %}cert_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
{% if kubernetes_target.get('cert_name') %}cert_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.cert_name }}{%- endif %}
|
||||||
{% if kubernetes_target.get('key_name') %}key_file: {{ kubernetes_target.ssl_dir }}/{{ kubernetes_target.key_name }}{%- endif %}
|
{% if kubernetes_target.get('key_name') %}key_file: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
||||||
relabel_configs:
|
relabel_configs:
|
||||||
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
|
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
|
||||||
action: keep
|
action: keep
|
||||||
|
|
|
@ -3,6 +3,7 @@ prometheus:
|
||||||
enabled: true
|
enabled: true
|
||||||
dir:
|
dir:
|
||||||
config: /srv/volumes/prometheus/server
|
config: /srv/volumes/prometheus/server
|
||||||
|
config_in_container: /srv/prometheus
|
||||||
data: /srv/volumes/local/prometheus/server
|
data: /srv/volumes/local/prometheus/server
|
||||||
bind:
|
bind:
|
||||||
port: 9090
|
port: 9090
|
||||||
|
|
Loading…
Reference in a new issue