-
Notifications
You must be signed in to change notification settings - Fork 0
/
prometheus.yml.tpl
253 lines (240 loc) · 8.79 KB
/
prometheus.yml.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
####################################################################
# Hachyderm Prometheus Config (/etc/prometheus/prometheus.yml)
#
# DO NOT EDIT THIS FILE MANUALLY - IT IS AUTOGENERATED PERIODCALLY
# BY A SYSTEMD TIMER BASED ON TAGS IN TAILSCALE!
#
# Last rendered: {{ time.Now.Format "2006-01-02 15:04:05" }}
####################################################################
global:
scrape_interval: 30s
evaluation_interval: 1m
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them
rule_files:
# - "rules.yml"
scrape_configs:
###############################################################################
# SELF - PROMETHEUS
###############################################################################
# first we scrape ourselves
- job_name: "prometheus"
static_configs:
- targets: ["prod-prometheus01:9090"]
###############################################################################
# SYNTHETICS - BLACKBOX EXPORTER
###############################################################################
# do some blackbox probing to make sure we know when services are up and stuff
- job_name: "blackbox"
metrics_path: /probe
params:
module: [http_2xx_get]
static_configs:
- targets:
- https://hachyderm.io
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9115
###############################################################################
# NODE EXPORTER (ALL)
###############################################################################
# get some handy metrics from the node exporter (all nodes)
- job_name: "node"
static_configs:
- targets:
- "{{ (ds "tailscale").Self.HostName }}:9100"
labels:
env: prod
### PROD ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-prod") }}
- "{{ $hostDetail.HostName }}:9100"
{{- end }}
{{- end }}
labels:
env: prod
### DEV ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-dev") }}
- "{{ $hostDetail.HostName }}:9100"
{{- end }}
{{- end }}
labels:
env: dev
###############################################################################
# NGINX
###############################################################################
# Scrape nginx exporter and nginxlog exporter for anything running nginx,
# like mastodon-web or edge-cdn
- job_name: "nginx"
static_configs:
### PROD ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-prod") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-mastodon-web") (coll.Has $hostDetail.Tags "tag:role-edge-cdn") (coll.Has $hostDetail.Tags "tag:role-mastodon-streaming") }}
- "{{ $hostDetail.HostName }}:4040" # nginxlog
- "{{ $hostDetail.HostName }}:9113"
{{- end }}
{{- end }}
{{- end }}
labels:
env: prod
### DEV ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-dev") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-mastodon-web") (coll.Has $hostDetail.Tags "tag:role-edge-cdn") (coll.Has $hostDetail.Tags "tag:role-mastodon-streaming") }}
- "{{ $hostDetail.HostName }}:4040" # nginxlog
- "{{ $hostDetail.HostName }}:9113"
{{- end }}
{{- end }}
{{- end }}
labels:
env: dev
###############################################################################
# ELASTICSEARCH STATSD
###############################################################################
# statsd has been deprecated in mastodon-sidekiq, so we're only scraping this from
# the localhost (our mastodon stats exporter). also include elasticsearch nodes.
- job_name: "statsd"
static_configs:
- targets: ["localhost:9876"] # mastodon_api for hachyderm.io
labels:
env: prod
### PROD ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-prod") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-elasticsearch") }}
- "{{ $hostDetail.HostName }}:9102"
{{- end }}
{{- end }}
{{- end }}
labels:
env: prod
### DEV ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-dev") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-elasticsearch") }}
- "{{ $hostDetail.HostName }}:9102"
{{- end }}
{{- end }}
{{- end }}
labels:
env: dev
relabel_configs:
- source_labels: [__param_target]
target_label: instance
###############################################################################
# POSTGRESQL
###############################################################################
# postgresql exporter
- job_name: "postgresql"
static_configs:
### PROD ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-prod") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-postgres-primary") (coll.Has $hostDetail.Tags "tag:role-postgres-backup") }}
- "{{ $hostDetail.HostName }}:9187"
- "{{ $hostDetail.HostName }}:9930" # pgcat
{{- end }}
{{- end }}
{{- end }}
labels:
env: prod
### DEV ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-dev") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-postgres-primary") (coll.Has $hostDetail.Tags "tag:role-postgres-backup") }}
- "{{ $hostDetail.HostName }}:9187"
- "{{ $hostDetail.HostName }}:9930" # pgcat
{{- end }}
{{- end }}
{{- end }}
labels:
env: dev
###############################################################################
# REDIS
###############################################################################
- job_name: "redis"
static_configs:
### PROD ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-prod") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-redis") }}
- "{{ $hostDetail.HostName }}:9187"
{{- end }}
{{- end }}
{{- end }}
labels:
env: prod
### DEV ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-dev") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-redis") }}
- "{{ $hostDetail.HostName }}:9187"
{{- end }}
{{- end }}
{{- end }}
labels:
env: dev
###############################################################################
# MASTODON STREAMING
###############################################################################
- job_name: "streaming"
static_configs:
- targets: ["prod-mastodon-streaming01:4000", "prod-mastodon-streaming01:4001", "prod-mastodon-streaming01:4002"]
labels:
env: "prod"
- targets: ["dev-mastodon01:4000"]
labels:
env: "dev"
metric_relabel_configs:
- source_labels: [ __name__ ]
target_label: __name__
regex: '(.*)'
action: replace
replacement: mastodon_streaming_${1}
###############################################################################
# SIDEKIQ
###############################################################################
- job_name: "sidekiq"
static_configs:
### PROD ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-prod") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-mastodon-sidekiq") }}
- "{{ $hostDetail.HostName }}:9187"
{{- end }}
{{- end }}
{{- end }}
labels:
env: prod
### DEV ###############
- targets:
{{- range $hostDetail := (ds "tailscale").Peer }}
{{- if and (coll.Has $hostDetail "Tags") (coll.Has $hostDetail.Tags "tag:env-dev") }}
{{- if or (coll.Has $hostDetail.Tags "tag:role-mastodon-sidekiq") }}
- "{{ $hostDetail.HostName }}:9187"
{{- end }}
{{- end }}
{{- end }}
labels:
env: dev