Created
March 19, 2019 21:39
-
-
Save tzz/bc21431ddc964eb2af219bd93cf0934e to your computer and use it in GitHub Desktop.
Barebones Jinja template for Prometheus configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my global config | |
global: | |
scrape_interval: 1m # Set the scrape interval | |
evaluation_interval: 1m # Evaluate rules every N | |
# scrape_timeout is set to the global default (10s). | |
external_labels: | |
monitoring_server: {{ host }} | |
# Alertmanager configuration | |
alerting: | |
alert_relabel_configs: | |
- action: labeldrop | |
regex: monitoring_server | |
alertmanagers: | |
- static_configs: | |
- targets: {{ _alertmanager_locations | json }} | |
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'. | |
{% if host == federation_master %} | |
rule_files: [] | |
{% else %} | |
rule_files: | |
- {{ rules|json}} | |
{% endif %} | |
scrape_configs: | |
{% if host == federation_master %} | |
{% for wave in range(10) %} | |
- job_name: 'federate--telegraf-nostat-wave{{ wave }}' | |
scrape_interval: 1m | |
scrape_timeout: 1m | |
honor_labels: true | |
metrics_path: '/federate' | |
params: | |
'match[]': | |
- '{job="direct-telegraf",hostname=~".+{{ wave }}$",__name__!~"^(procstat|exec_mountstat).+"}' | |
static_configs: | |
- targets: {{ _federated_prometheus_locations|json }} | |
- job_name: 'federate--telegraf-stat-wave{{ wave }}' | |
scrape_interval: 15m | |
scrape_timeout: 5m | |
honor_labels: true | |
metrics_path: '/federate' | |
params: | |
'match[]': | |
- '{job="direct-telegraf",hostname=~".+{{ wave }}$",__name__=~"^(procstat|exec_mountstat).+"}' | |
static_configs: | |
- targets: {{ _federated_prometheus_locations|json }} | |
{% endfor %} | |
- job_name: 'federate--telegraf-nostat-nowave' | |
scrape_interval: 1m | |
scrape_timeout: 1m | |
honor_labels: true | |
metrics_path: '/federate' | |
params: | |
'match[]': | |
- '{job="direct-telegraf",hostname!~".+[0-9]$",__name__!~"^(procstat|exec_mountstat).+"}' | |
static_configs: | |
- targets: {{ _federated_prometheus_locations|json }} | |
- job_name: 'federate--telegraf-stat-nowave' | |
scrape_interval: 15m | |
scrape_timeout: 3m | |
honor_labels: true | |
metrics_path: '/federate' | |
params: | |
'match[]': | |
- '{job="direct-telegraf",hostname!~".+[0-9]$",__name__=~"^(procstat|exec_mountstat).+"}' | |
static_configs: | |
- targets: {{ _federated_prometheus_locations|json }} | |
- job_name: 'federate--prometheus' | |
scrape_interval: 1m | |
scrape_timeout: 1m | |
honor_labels: true | |
metrics_path: '/federate' | |
params: | |
'match[]': | |
- '{job="prometheus"}' | |
static_configs: | |
- targets: {{ _other_prometheus_locations|json }} | |
- job_name: 'snmp' | |
metrics_path: /snmp | |
params: | |
module: [ciscosw] | |
file_sd_configs: | |
- files: | |
- {{ inventory['cisco'] }} | |
relabel_configs: | |
- source_labels: [__address__] | |
target_label: __param_target | |
- source_labels: [__param_target] | |
target_label: instance | |
- target_label: __address__ | |
replacement: {{ snmp_exporter_host }} | |
{% else %} | |
- job_name: 'direct-telegraf' | |
honor_labels: true | |
file_sd_configs: | |
- files: | |
- {{ inventory['machines'] }} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment