]> git.openstreetmap.org Git - chef.git/blob - cookbooks/prometheus/templates/default/prometheus.yml.erb
Attach extra labels to jobs
[chef.git] / cookbooks / prometheus / templates / default / prometheus.yml.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 global:
4   scrape_interval: 15s
5   evaluation_interval: 15s
6
7 alerting:
8   alertmanagers:
9     - path_prefix: /alertmanager
10       static_configs:
11         - targets:
12             - localhost:9093
13
14 rule_files:
15   - /etc/prometheus/*_rules.yml
16
17 scrape_configs:
18   - job_name: prometheus
19     scrape_interval: 5s
20     scrape_timeout: 5s
21     metrics_path: /prometheus/metrics
22     static_configs:
23       - targets:
24           - localhost:9090
25   - job_name: alertmanager
26     metrics_path: /alertmanager/metrics
27     static_configs:
28       - targets:
29           - localhost:9093
30   - job_name: ssl
31     scrape_interval: 15m
32     metrics_path: /probe
33     static_configs:
34 <% @certificates.values.sort_by { |c| c[:domains].first }.each do |certificate| -%>
35       - targets:
36 <% certificate[:nodes].sort_by { |h| h[:name] }.each do |host| -%>
37           - <%= certificate[:domains].first %>/<%= host[:name] %>:443
38 <% end -%>
39         labels:
40           domain: <%= certificate[:domains].first %>
41 <% end -%>
42     relabel_configs:
43       - source_labels: [__address__]
44         regex: "([^/]+)/.*"
45         target_label: __param_module
46       - source_labels: [__address__]
47         regex: "[^/]+/(.*)"
48         target_label: __param_target
49       - source_labels: [__param_target]
50         regex: "([^.]+)\\..*"
51         target_label: instance
52       - target_label: __address__
53         replacement: 127.0.0.1:9219
54 <% @jobs.sort.each do |name, targets| -%>
55   - job_name: <%= name %>
56 <% if targets.first[:scrape_interval] -%>
57     scrape_interval: <%= targets.first[:scrape_interval] %>
58 <% end -%>
59 <% if targets.first[:scrape_timeout] -%>
60     scrape_timeout: <%= targets.first[:scrape_timeout] %>
61 <% end -%>
62 <% if targets.first[:sni] -%>
63     tls_config:
64       server_name: <%= targets.first[:sni] %>
65     relabel_configs:
66       - target_label: __scheme__
67         replacement: https
68 <% end -%>
69     static_configs:
70 <% targets.each do |target| -%>
71       - targets:
72           - "<%= target[:address] %>"
73         labels:
74           instance: <%= target[:instance] %>
75 <% target[:labels].sort.each do |name, value| -%>
76           <%= name %>: <%= value %>
77 <% end -%>
78 <% end -%>
79     metric_relabel_configs:
80 <% targets.each do |target| -%>
81 <% target[:metric_relabel].each do |relabel| -%>
82       - source_labels: [instance,<%= relabel[:source_labels] %>]
83         regex: "<%= target[:instance] %>;<%= relabel[:regex] %>"
84         action: <%= relabel[:action] %>
85 <% end -%>
86 <% end -%>
87 <% end -%>
88   - job_name: snmp
89     scrape_interval: 5m
90     scrape_timeout: 2m
91     metrics_path: /snmp
92     static_configs:
93 <% @snmp_targets.sort_by { |t| t[:instance] }.each do |target| -%>
94       - targets:
95 <% target[:modules].each do |module_name| -%>
96           - "<%= target[:target] %>/<%= module_name %>/<%= target[:address] %>"
97 <% end -%>
98         labels:
99           instance: <%= target[:instance] %>
100 <% target[:labels].sort.each do |name, value| -%>
101           <%= name %>: <%= value %>
102 <% end -%>
103 <% end -%>
104     relabel_configs:
105       - source_labels: [__address__]
106         regex: "([^/]+)/[^/]+/.*"
107         target_label: __param_target
108       - source_labels: [__address__]
109         regex: "[^/]+/([^/]+)/.*"
110         target_label: __param_module
111       - source_labels: [__address__]
112         regex: "[^/]+/([^/]+)/.*"
113         target_label: module
114       - source_labels: [__address__]
115         regex: "[^/]+/[^/]+/(.*)"
116         target_label: __address__