Skip to content

Instantly share code, notes, and snippets.

@tzz
Created March 19, 2019 21:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzz/bc21431ddc964eb2af219bd93cf0934e to your computer and use it in GitHub Desktop.
Save tzz/bc21431ddc964eb2af219bd93cf0934e to your computer and use it in GitHub Desktop.
Barebones Jinja template for Prometheus configuration
# 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