2017-03-09 06:12:27 -05:00
|
|
|
global:
|
|
|
|
{%- if server.get('config', {}).global is defined %}
|
|
|
|
{{ server.config.global | yaml(False) | indent(2, true) }}
|
|
|
|
{%- endif %}
|
|
|
|
|
2017-05-24 07:20:21 -04:00
|
|
|
{%- if server.get('config', {}).get('alertmanager') %}
|
|
|
|
alerting:
|
2018-04-24 06:02:15 -04:00
|
|
|
{%- if server.get('config', {}).get('alert_relabel_configs') %}
|
|
|
|
alert_relabel_configs:
|
|
|
|
{%- for label in server.config.get('alert_relabel_configs', []) %}
|
|
|
|
- action: {{ label.get('action', 'replace') }}
|
|
|
|
{%- if label.get('source_labels') %}
|
|
|
|
{%- if label.source_labels is string %}
|
|
|
|
{%- set label_list = label.source_labels.split(',') %}
|
|
|
|
{%- elif label.source_labels is list %}
|
|
|
|
{%- set label_list = label.source_labels %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if label_list is defined %}
|
|
|
|
source_labels: {{ label_list }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if label.get('regex') %}
|
|
|
|
regex: "{{ label.regex }}"
|
|
|
|
{%- endif %}
|
|
|
|
{%- if label.get('target_label') %}
|
|
|
|
target_label: "{{ label.target_label }}"
|
|
|
|
{%- endif %}
|
|
|
|
{%- if label.get('replacement') %}
|
|
|
|
replacement: "{{ label.replacement }}"
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2017-05-24 07:20:21 -04:00
|
|
|
alertmanagers:
|
|
|
|
{%- for name, alertmanager in server.config.alertmanager.iteritems() %}
|
|
|
|
{%- if alertmanager.get('enabled', True) %}
|
|
|
|
# {{ name }}
|
|
|
|
{%- if alertmanager.static_configs is defined %}
|
|
|
|
- static_configs:
|
|
|
|
- targets: {{ alertmanager.static_configs.get('target', [])|yaml }}
|
|
|
|
{%- elif alertmanager.dns_sd_configs is defined %}
|
|
|
|
- dns_sd_configs:
|
|
|
|
- names: {{ alertmanager.dns_sd_configs.get('domain', [])|yaml }}
|
|
|
|
type: {{ alertmanager.dns_sd_configs.type }}
|
|
|
|
port: {{ alertmanager.dns_sd_configs.port }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
|
2017-05-29 09:05:06 -04:00
|
|
|
{%- if server.get('config', {}).get('remote_write') %}
|
|
|
|
remote_write:
|
|
|
|
{%- for name, remote_endpoint in server.config.remote_write.iteritems() %}
|
|
|
|
{%- if remote_endpoint.get('enabled', True) %}
|
|
|
|
# {{ name }}
|
|
|
|
- url: {{ remote_endpoint.url }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
|
2017-03-09 06:12:27 -05:00
|
|
|
rule_files:
|
2017-05-17 10:00:52 -04:00
|
|
|
- alerts.yml
|
2017-03-09 06:12:27 -05:00
|
|
|
|
2017-06-26 09:34:08 -04:00
|
|
|
{%- set static_target = server.target.static %}
|
2018-01-26 07:35:38 -05:00
|
|
|
{%- if server.get('use_grains', {}).get('target', True) %}
|
|
|
|
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
|
|
|
|
{%- set static_grain = node_grains.get('prometheus', {}).get('server', {}).get('target', {}).get('static', {}) %}
|
|
|
|
{%- for job_name, job in static_grain.iteritems() %}
|
|
|
|
{%- if static_target[job_name] is not defined %}
|
|
|
|
{%- do static_target.update({job_name: {
|
|
|
|
'enabled': job.get('enabled', True),
|
|
|
|
'metrics_path': job.get('metrics_path', '/metrics'),
|
|
|
|
'honor_labels': job.get('honor_labels', False),
|
|
|
|
'scrape_interval': job.get('scrape_interval', server.get('config', {}).get('global', {}).get('scrape_interval', '15s')),
|
|
|
|
'scrape_timeout': job.get('scrape_interval', server.get('config', {}).get('global', {}).get('scrape_interval', '15s')),
|
|
|
|
'scheme': job.get('scheme', 'http')}
|
2017-07-28 08:33:36 -04:00
|
|
|
}) %}
|
2018-01-26 07:35:38 -05:00
|
|
|
{%- 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 %}
|
2017-07-28 08:33:36 -04:00
|
|
|
{%- endif %}
|
2018-01-26 07:35:38 -05:00
|
|
|
{%- if static_target[job_name]['endpoint'] is not defined %}
|
|
|
|
{%- do static_target[job_name].update({'endpoint': []}) %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if static_target[job_name]['metric_relabel'] is not defined %}
|
|
|
|
{%- do static_target[job_name].update({'metric_relabel': []}) %}
|
|
|
|
{%- endif %}
|
2018-03-27 05:45:06 -04:00
|
|
|
{%- if static_target[job_name]['relabel_configs'] is not defined %}
|
|
|
|
{%- do static_target[job_name].update({'relabel_configs': []}) %}
|
|
|
|
{%- endif %}
|
2018-01-26 07:35:38 -05:00
|
|
|
{%- for target in job.get('endpoint', []) %}
|
|
|
|
{%- do static_target[job_name]['endpoint'].append(target) %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- for label in job.get('metric_relabel', []) %}
|
|
|
|
{%- do static_target[job_name]['metric_relabel'].append(label) %}
|
|
|
|
{%- endfor %}
|
2018-03-27 05:45:06 -04:00
|
|
|
{%- for label in job.get('relabel_configs', []) %}
|
|
|
|
{%- do static_target[job_name]['relabel_configs'].append(label) %}
|
|
|
|
{%- endfor %}
|
2017-06-28 03:28:56 -04:00
|
|
|
{%- endfor %}
|
2017-04-13 04:21:19 -04:00
|
|
|
{%- endfor %}
|
2018-01-26 07:35:38 -05:00
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
|
2017-04-13 04:21:19 -04:00
|
|
|
scrape_configs:
|
2017-06-26 09:34:08 -04:00
|
|
|
{%- for job_name, job in static_target.iteritems() %}
|
2017-04-13 04:21:19 -04:00
|
|
|
{%- set nodes = [] %}
|
2017-06-26 09:34:08 -04:00
|
|
|
{%- for target in job.get('endpoint', []) %}
|
2017-04-13 04:21:19 -04:00
|
|
|
{%- set address = "'%s:%d'" | format(target.address, target.port) %}
|
|
|
|
{%- do nodes.append(address) %}
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endfor %}
|
2017-04-25 08:37:44 -04:00
|
|
|
{%- if nodes|length > 0 and job.get('enabled', True) %}
|
2017-04-13 04:21:19 -04:00
|
|
|
- job_name: {{ job_name }}
|
|
|
|
{% if job.get('scheme') %}scheme: {{ job.scheme }}{%- endif %}
|
2017-08-21 05:32:02 -04:00
|
|
|
{% if job.get('metrics_path') %}metrics_path: {{ job.metrics_path }}{%- endif %}
|
2018-01-26 07:35:38 -05:00
|
|
|
{% if job.honor_labels is defined %}honor_labels: {{ job.honor_labels }}{%- endif %}
|
|
|
|
{% if job.scrape_interval is defined %}scrape_interval: {{ job.scrape_interval }}{%- endif %}
|
|
|
|
{% if job.scrape_timeout is defined %}scrape_timeout: {{ job.scrape_timeout }}{%- endif %}
|
|
|
|
{%- if job.get('params') %}
|
|
|
|
params:
|
|
|
|
{%- for param_name, param_value in job.get('params', {}).iteritems() %}
|
|
|
|
{{ param_name }}: {{ param_value }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2017-04-13 04:21:19 -04:00
|
|
|
{%- if job.get('tls_config') %}
|
2017-03-30 09:43:41 -04:00
|
|
|
tls_config:
|
2017-04-13 04:21:19 -04:00
|
|
|
{% if job.tls_config.get('skip_verify') is defined %}insecure_skip_verify: {{ job.tls_config.skip_verify | lower }}{%- endif %}
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ job.tls_config.key_name }}{%- endif %}
|
2017-04-13 04:21:19 -04:00
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
static_configs:
|
2017-04-13 04:21:19 -04:00
|
|
|
- targets: [{{ nodes | join(',') }}]
|
2017-06-28 03:28:56 -04:00
|
|
|
{%- if job.get('metric_relabel') %}
|
|
|
|
metric_relabel_configs:
|
|
|
|
{%- for label in job.get('metric_relabel', []) %}
|
2018-03-06 06:20:58 -05:00
|
|
|
- action: {{ label.get('action', 'replace') }}
|
|
|
|
{%- if label.get('source_labels') %}
|
|
|
|
{%- if label.source_labels is string %}
|
|
|
|
{%- set label_list = label.source_labels.split(',') %}
|
|
|
|
{%- elif label.source_labels is list %}
|
|
|
|
{%- set label_list = label.source_labels %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if label_list is defined %}
|
|
|
|
source_labels: {{ label_list }}
|
|
|
|
{%- endif %}
|
2017-06-28 03:28:56 -04:00
|
|
|
{%- endif %}
|
2018-03-06 06:20:58 -05:00
|
|
|
{%- if label.get('regex') %}
|
2017-06-28 03:28:56 -04:00
|
|
|
regex: "{{ label.regex }}"
|
2018-03-06 06:20:58 -05:00
|
|
|
{%- endif %}
|
|
|
|
{%- if label.get('target_label') %}
|
2017-06-28 03:28:56 -04:00
|
|
|
target_label: "{{ label.target_label }}"
|
2018-03-06 06:20:58 -05:00
|
|
|
{%- endif %}
|
|
|
|
{%- if label.get('replacement') %}
|
|
|
|
replacement: "{{ label.replacement }}"
|
2017-06-28 03:28:56 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2018-03-27 05:45:06 -04:00
|
|
|
{%- if job.get('relabel_configs') %}
|
|
|
|
relabel_configs:
|
|
|
|
{%- for label in job.get('relabel_configs', []) %}
|
|
|
|
{%- if label.source_labels is string %}
|
|
|
|
{%- set label_list = label.source_labels.split(',') %}
|
|
|
|
{%- elif label.source_labels is list %}
|
|
|
|
{%- set label_list = label.source_labels %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if label_list is defined %}
|
|
|
|
- source_labels: {{ label_list }}
|
|
|
|
regex: "{{ label.regex }}"
|
|
|
|
{%- if label.get('target_label') %}
|
|
|
|
target_label: "{{ label.target_label }}"
|
|
|
|
{%- endif %}
|
|
|
|
{%- if label.get('replacement') %}
|
|
|
|
replacement: "{{ label.replacement }}"
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|
2017-04-13 04:21:19 -04:00
|
|
|
{%- endfor %}
|
2017-03-09 06:12:27 -05:00
|
|
|
|
2017-09-20 03:46:47 -04:00
|
|
|
{%- set kubernetes_target = {} %}
|
2018-01-26 07:35:38 -05:00
|
|
|
{%- if server.get('use_grains', {}).get('target', True) %}
|
|
|
|
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
|
|
|
|
{%- set kubernetes_grain = node_grains.get('prometheus', {}).get('server', {}).get('target', {}).get('kubernetes', {}) %}
|
|
|
|
{%- if kubernetes_grain %}
|
|
|
|
{%- do kubernetes_target.update(kubernetes_grain) %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2017-09-20 03:46:47 -04:00
|
|
|
|
|
|
|
{%- if kubernetes_target.get('enabled', False) %}
|
2017-07-19 05:42:11 -04:00
|
|
|
|
2017-03-09 06:12:27 -05:00
|
|
|
- job_name: 'kubernetes-api'
|
|
|
|
scheme: https
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
kubernetes_sd_configs:
|
2017-04-13 04:21:19 -04:00
|
|
|
- api_server: {{ kubernetes_target.api_ip }}
|
2017-03-09 06:12:27 -05:00
|
|
|
role: endpoints
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
relabel_configs:
|
|
|
|
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
|
|
|
|
action: keep
|
|
|
|
regex: default;kubernetes;https
|
|
|
|
|
|
|
|
- job_name: 'kubernetes-node'
|
|
|
|
scheme: https
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
kubernetes_sd_configs:
|
2017-04-13 04:21:19 -04:00
|
|
|
- api_server: {{ kubernetes_target.api_ip }}
|
2017-03-09 06:12:27 -05:00
|
|
|
role: node
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
relabel_configs:
|
|
|
|
- action: labelmap
|
|
|
|
regex: __meta_kubernetes_node_label_(.+)
|
|
|
|
|
2017-09-20 03:46:47 -04:00
|
|
|
- job_name: 'kubernetes-cadvisor'
|
|
|
|
scheme: https
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
|
|
|
kubernetes_sd_configs:
|
|
|
|
- api_server: {{ kubernetes_target.api_ip }}
|
|
|
|
role: node
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
|
|
|
relabel_configs:
|
|
|
|
- action: labelmap
|
|
|
|
regex: __meta_kubernetes_node_label_(.+)
|
|
|
|
- source_labels: [__address__]
|
|
|
|
action: replace
|
|
|
|
target_label: __address__
|
|
|
|
regex: (.+)(?::\d+)
|
|
|
|
replacement: $1:{{ kubernetes_target.get('cadvisor', {}).get('port', 4194) }}
|
|
|
|
- source_labels: [__scheme__]
|
|
|
|
action: replace
|
|
|
|
target_label: __scheme__
|
|
|
|
replacement: {{ kubernetes_target.get('cadvisor', {}).get('scheme', 'http') }}
|
|
|
|
|
2017-07-19 05:42:11 -04:00
|
|
|
{%- if kubernetes_target.get('endpoint', {}).get('enabled') %}
|
2017-06-26 09:39:56 -04:00
|
|
|
- job_name: 'kubernetes-service-endpoints'
|
2017-03-09 06:12:27 -05:00
|
|
|
scheme: https
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
kubernetes_sd_configs:
|
2017-04-13 04:21:19 -04:00
|
|
|
- api_server: {{ kubernetes_target.api_ip }}
|
2017-03-09 06:12:27 -05:00
|
|
|
role: endpoints
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
relabel_configs:
|
|
|
|
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
|
|
|
|
action: keep
|
|
|
|
regex: true
|
|
|
|
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
|
|
|
|
action: replace
|
|
|
|
target_label: __scheme__
|
|
|
|
regex: (https?)
|
|
|
|
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
|
|
|
|
action: replace
|
|
|
|
target_label: __metrics_path__
|
|
|
|
regex: (.+)
|
|
|
|
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
|
|
|
|
action: replace
|
|
|
|
target_label: __address__
|
|
|
|
regex: (.+)(?::\d+);(\d+)
|
|
|
|
replacement: $1:$2
|
|
|
|
- action: labelmap
|
|
|
|
regex: __meta_kubernetes_service_label_(.+)
|
|
|
|
- source_labels: [__meta_kubernetes_service_namespace]
|
|
|
|
action: replace
|
|
|
|
target_label: kubernetes_namespace
|
|
|
|
- source_labels: [__meta_kubernetes_service_name]
|
|
|
|
action: replace
|
|
|
|
target_label: kubernetes_name
|
|
|
|
- source_labels: [__meta_kubernetes_pod_node_name]
|
|
|
|
action: replace
|
|
|
|
target_label: kubernetes_io_hostname
|
|
|
|
- source_labels: [__meta_kubernetes_pod_name]
|
|
|
|
action: replace
|
|
|
|
target_label: kubernetes_pod_name
|
2017-07-19 05:42:11 -04:00
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
|
2017-07-19 05:42:11 -04:00
|
|
|
{%- if kubernetes_target.get('pod', {}).get('enabled') %}
|
2017-03-09 06:12:27 -05:00
|
|
|
- job_name: 'kubernetes-pod'
|
|
|
|
scheme: https
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
kubernetes_sd_configs:
|
2017-04-13 04:21:19 -04:00
|
|
|
- api_server: {{ kubernetes_target.api_ip }}
|
2017-03-09 06:12:27 -05:00
|
|
|
role: pod
|
|
|
|
tls_config:
|
|
|
|
insecure_skip_verify: true
|
2017-07-28 08:33:36 -04:00
|
|
|
{% 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: {{ server.dir.config_in_container }}/{{ kubernetes_target.key_name }}{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
relabel_configs:
|
|
|
|
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
|
|
|
|
action: keep
|
|
|
|
regex: true
|
|
|
|
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
|
|
|
|
action: replace
|
|
|
|
target_label: __metrics_path__
|
|
|
|
regex: (.+)
|
|
|
|
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
|
|
|
|
action: replace
|
|
|
|
regex: (.+):(?:\d+);(\d+)
|
|
|
|
replacement: ${1}:${2}
|
|
|
|
target_label: __address__
|
|
|
|
- action: labelmap
|
|
|
|
regex: __meta_kubernetes_pod_label_(.+)
|
|
|
|
- source_labels: [__meta_kubernetes_pod_namespace]
|
|
|
|
action: replace
|
|
|
|
target_label: kubernetes_namespace
|
|
|
|
- source_labels: [__meta_kubernetes_pod_name]
|
|
|
|
action: replace
|
|
|
|
target_label: kubernetes_pod_name
|
2017-07-19 05:42:11 -04:00
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|
|
|
|
|
2018-04-05 09:49:24 -04:00
|
|
|
{%- set dns_endpoints = {} %}
|
|
|
|
{%- if server.get('use_grains', {}).get('target', True) %}
|
|
|
|
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
|
|
|
|
{%- set dns_grain = node_grains.get('prometheus', {}).get('server', {}).get('target', {}).get('dns', {}) %}
|
|
|
|
{%- if dns_grain.get('enabled', False) %}
|
|
|
|
{%- for endpoint in dns_grain.get('endpoint', []) %}
|
|
|
|
{%- do dns_endpoints.update({endpoint.name: endpoint}) %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
|
2017-05-12 11:30:35 -04:00
|
|
|
{%- if server.get('target', {}).get('dns', {}).get('enabled', False) %}
|
2018-04-05 09:49:24 -04:00
|
|
|
{%- for endpoint in server.get('target', {}).get('dns', {}).get('endpoint', []) %}
|
|
|
|
{%- do dns_endpoints.update({endpoint.name: endpoint}) %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
{%- for name, endpoint in dns_endpoints | dictsort %}
|
|
|
|
- job_name: {{ endpoint.name }}
|
2017-03-09 06:12:27 -05:00
|
|
|
dns_sd_configs:
|
|
|
|
- names:
|
2018-04-05 09:49:24 -04:00
|
|
|
{%- for domain in endpoint.domain %}
|
2017-03-29 13:19:34 -04:00
|
|
|
- {{ domain }}
|
|
|
|
{%- endfor %}
|
2018-04-05 09:49:24 -04:00
|
|
|
type: {{ endpoint.type }}
|
|
|
|
port: {{ endpoint.port }}
|
|
|
|
{%- endfor %}
|