-
Notifications
You must be signed in to change notification settings - Fork 1
/
zabbix-traefik-metrics.yaml
399 lines (377 loc) · 15.3 KB
/
zabbix-traefik-metrics.yaml
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
zabbix_export:
version: '6.4'
template_groups:
- uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
name: Templates/Applications
templates:
- uuid: a8b14c3fddeb4f278e966e6d2c523e05
template: 'Traefik Metrics'
name: 'Traefik Metrics'
description: 'The template to monitor Traefik Metrics by Zabbix that work without any external scripts.'
groups:
- name: Templates/Applications
items:
- uuid: 72d8d9c97db041b88667409000aa3656
name: 'Traefik: Get metrics'
key: 'web.page.get["{$TRAEFIK.API}"]'
history: 1h
trends: '0'
value_type: TEXT
description: 'The HTTP API endpoint that returns metrics.'
preprocessing:
- type: REGEX
parameters:
- '\n\s?\n([\s\S]*)'
- \1
tags:
- tag: component
value: raw
discovery_rules:
- uuid: 0db764fbee3e4d22a6b79b5d38ffd192
name: 'Traefik: 4xx Requests'
type: DEPENDENT
key: traefik.reqests.4xx
delay: '0'
lifetime: 1h
item_prototypes:
- uuid: 81c58da0aec042aba673c844401598ee
name: 'Traefik: Service Requests {#TRAEFIK_SERVICE} - 4xx Errors'
type: CALCULATED
key: 'traefik.service_requests.4xx[{"{#TRAEFIK_SERVICE}"]'
params: '{#REQ_COUNTER}'
preprocessing:
- type: SIMPLE_CHANGE
parameters:
- ''
tags:
- tag: component
value: service
- tag: service
value: '{#TRAEFIK_SERVICE}'
trigger_prototypes:
- uuid: ce1a35af981d45339cde4173ca208b37
expression: 'sum(/Traefik Metrics/traefik.service_requests.4xx[{"{#TRAEFIK_SERVICE}"], 5m) > {$TRAEFIK.4XX_ERRORS} and {$TRAEFIK.4XX_ERRORS} <> "0"'
name: 'Traefik: Service Requests {#TRAEFIK_SERVICE} - 4xx Errors more than {$TRAEFIK.4XX_ERRORS}/5min'
priority: WARNING
graph_prototypes:
- uuid: 3560b5c1d1af423c96d5f9f80431ba80
name: '4xx Requests'
graph_items:
- color: 1A7C11
calc_fnc: ALL
item:
host: 'Traefik Metrics'
key: 'traefik.service_requests.4xx[{"{#TRAEFIK_SERVICE}"]'
master_item:
key: 'web.page.get["{$TRAEFIK.API}"]'
lld_macro_paths:
- lld_macro: '{#REQ_COUNTER}'
path: $.value
- lld_macro: '{#TRAEFIK_SERVICE}'
path: $.service
- lld_macro: '{#TRAEFIK_STATUS}'
path: $.status
preprocessing:
- type: PROMETHEUS_TO_JSON
parameters:
- 'traefik_service_requests_total{service=~".*", code=~".*"}'
- type: JAVASCRIPT
parameters:
- |
var data = JSON.parse(value);
var result = {};
var result2 = [];
data.forEach(function (item) {
first_code = item.labels.code.slice(0,1);
if (first_code == "4") {
key = item.labels.service + " - " + first_code + "xx status";
value = Number(item.value);
if (!result[key]) {
result[key] = {"item": key, "value": 0, "status": (first_code + "xx"), "service": item.labels.service};
}
result[key]["value"] += value;
}
})
Object.keys(result).forEach(function(key) {
result2.push({"item": key, "value": result[key]["value"], "status": result[key]["status"], "service": result[key]["service"]});
});
return JSON.stringify(result2);
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 3h
- uuid: eefc4f9c4e7e4cebbc0d7b2aba3485e7
name: 'Traefik: 5xx Requests'
type: DEPENDENT
key: traefik.reqests.5xx
delay: '0'
lifetime: 1h
item_prototypes:
- uuid: 0f5132dd4e3c4563b75cec184c6e0327
name: 'Traefik: Service Requests {#TRAEFIK_SERVICE} - 5xx Errors'
type: CALCULATED
key: 'traefik.service_requests.5xx[{"{#TRAEFIK_SERVICE}"]'
params: '{#REQ_COUNTER}'
preprocessing:
- type: SIMPLE_CHANGE
parameters:
- ''
tags:
- tag: component
value: service
- tag: service
value: '{#TRAEFIK_SERVICE}'
trigger_prototypes:
- uuid: d176d492b65540aabfb9f51e6a19c380
expression: 'sum(/Traefik Metrics/traefik.service_requests.5xx[{"{#TRAEFIK_SERVICE}"], 5m) > {$TRAEFIK.5XX_ERRORS} and {$TRAEFIK.5XX_ERRORS} <> "0"'
name: 'Traefik: Service Requests {#TRAEFIK_SERVICE} - 5xx Errors more than {$TRAEFIK.5XX_ERRORS}/5min'
priority: WARNING
graph_prototypes:
- uuid: 4d6b6b7cbfbf461cb660ad618661a9a5
name: '5xx Requests'
graph_items:
- color: 1A7C11
calc_fnc: ALL
item:
host: 'Traefik Metrics'
key: 'traefik.service_requests.5xx[{"{#TRAEFIK_SERVICE}"]'
master_item:
key: 'web.page.get["{$TRAEFIK.API}"]'
lld_macro_paths:
- lld_macro: '{#REQ_COUNTER}'
path: $.value
- lld_macro: '{#TRAEFIK_SERVICE}'
path: $.service
- lld_macro: '{#TRAEFIK_STATUS}'
path: $.status
preprocessing:
- type: PROMETHEUS_TO_JSON
parameters:
- 'traefik_service_requests_total{service=~".*", code=~".*"}'
- type: JAVASCRIPT
parameters:
- |
var data = JSON.parse(value);
var result = {};
var result2 = [];
data.forEach(function (item) {
first_code = item.labels.code.slice(0,1);
if (first_code == "5") {
key = item.labels.service + " - " + first_code + "xx status";
value = Number(item.value);
if (!result[key]) {
result[key] = {"item": key, "value": 0, "status": (first_code + "xx"), "service": item.labels.service};
}
result[key]["value"] += value;
}
})
Object.keys(result).forEach(function(key) {
result2.push({"item": key, "value": result[key]["value"], "status": result[key]["status"], "service": result[key]["service"]});
});
return JSON.stringify(result2);
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 3h
- uuid: b9fe073ebdd64893ba0bb56d60507213
name: 'Traefik: Requests'
type: DEPENDENT
key: traefik.reqests.all
delay: '0'
lifetime: 1h
item_prototypes:
- uuid: 86813d1e4d81430dbdae6c5306f9ab65
name: 'Traefik: Service Requests {#TRAEFIK_SERVICE}'
type: CALCULATED
key: 'traefik.service_requests.all[{"{#TRAEFIK_SERVICE}"]'
params: '{#REQ_COUNTER}'
preprocessing:
- type: SIMPLE_CHANGE
parameters:
- ''
tags:
- tag: component
value: service
- tag: service
value: '{#TRAEFIK_SERVICE}'
graph_prototypes:
- uuid: 5b0f640ab2174a16b136c822aff68206
name: 'Total Requests'
graph_items:
- color: 1A7C11
calc_fnc: ALL
item:
host: 'Traefik Metrics'
key: 'traefik.service_requests.all[{"{#TRAEFIK_SERVICE}"]'
master_item:
key: 'web.page.get["{$TRAEFIK.API}"]'
lld_macro_paths:
- lld_macro: '{#REQ_COUNTER}'
path: $.value
- lld_macro: '{#TRAEFIK_SERVICE}'
path: $.service
preprocessing:
- type: PROMETHEUS_TO_JSON
parameters:
- 'traefik_service_requests_total{service=~".*"}'
- type: JAVASCRIPT
parameters:
- |
var data = JSON.parse(value);
var result = {};
var result2 = [];
data.forEach(function (item) {
first_code = item.labels.code.slice(0,1);
key = item.labels.service;
value = Number(item.value);
if (!result[key]) {
result[key] = {"item": key, "value": 0, "service": item.labels.service};
}
result[key]["value"] += value;
})
Object.keys(result).forEach(function(key) {
result2.push({"item": key, "value": result[key]["value"], "service": result[key]["service"]});
});
return JSON.stringify(result2);
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 3h
- uuid: aada7ce63e5441a495c97693a733bcdd
name: 'Traefik: Response bytes'
type: DEPENDENT
key: traefik.service_response_bytes
delay: '0'
item_prototypes:
- uuid: 28313e7a68bd4680bfa0087866ac023b
name: 'Traefik: Service Reponse bytes {#TRAEFIK_SERVICE}'
type: CALCULATED
key: 'traefik.reponse_bytes.all[{"{#TRAEFIK_SERVICE}"]'
params: '{#RESPONSE_COUNTER}'
preprocessing:
- type: SIMPLE_CHANGE
parameters:
- ''
tags:
- tag: component
value: service
- tag: service
value: '{#TRAEFIK_SERVICE}'
graph_prototypes:
- uuid: 44704626cd384ca1b1473be6d04c48bb
name: 'Response bytes'
graph_items:
- drawtype: GRADIENT_LINE
color: 1A7C11
item:
host: 'Traefik Metrics'
key: 'traefik.reponse_bytes.all[{"{#TRAEFIK_SERVICE}"]'
master_item:
key: 'web.page.get["{$TRAEFIK.API}"]'
lld_macro_paths:
- lld_macro: '{#RESPONSE_COUNTER}'
path: $.value
- lld_macro: '{#TRAEFIK_SERVICE}'
path: $.service
preprocessing:
- type: PROMETHEUS_TO_JSON
parameters:
- 'traefik_service_responses_bytes_total{service=~".*"}'
- type: JAVASCRIPT
parameters:
- |
var data = JSON.parse(value);
var result = {};
var result2 = [];
data.forEach(function (item) {
first_code = item.labels.code.slice(0,1);
key = item.labels.service;
value = Number(item.value);
if (!result[key]) {
result[key] = {"item": key, "value": 0, "service": item.labels.service};
}
result[key]["value"] += value;
})
Object.keys(result).forEach(function(key) {
result2.push({"item": key, "value": result[key]["value"], "service": result[key]["service"]});
});
return JSON.stringify(result2);
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 3h
macros:
- macro: '{$TRAEFIK.4XX_ERRORS}'
value: '0'
description: '4xx requests per 5 minute'
- macro: '{$TRAEFIK.5XX_ERRORS}'
value: '0'
description: '5xx requests per 5 minute'
- macro: '{$TRAEFIK.API}'
value: 'http://proxy:8082'
description: 'e.g. http://localhost:8002'
dashboards:
- uuid: d3a3519cfb5749e58198ae00a8b85b35
name: 'Traefik Requests'
pages:
- widgets:
- type: graphprototype
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: ITEM_PROTOTYPE
name: itemid
value:
host: 'Traefik Metrics'
key: 'traefik.reponse_bytes.all[{"{#TRAEFIK_SERVICE}"]'
- type: INTEGER
name: source_type
value: '3'
- type: graphprototype
'y': '5'
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: ITEM_PROTOTYPE
name: itemid
value:
host: 'Traefik Metrics'
key: 'traefik.service_requests.4xx[{"{#TRAEFIK_SERVICE}"]'
- type: INTEGER
name: source_type
value: '3'
- type: graphprototype
x: '12'
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: ITEM_PROTOTYPE
name: itemid
value:
host: 'Traefik Metrics'
key: 'traefik.service_requests.all[{"{#TRAEFIK_SERVICE}"]'
- type: INTEGER
name: source_type
value: '3'
- type: graphprototype
x: '12'
'y': '5'
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: ITEM_PROTOTYPE
name: itemid
value:
host: 'Traefik Metrics'
key: 'traefik.service_requests.5xx[{"{#TRAEFIK_SERVICE}"]'
- type: INTEGER
name: source_type
value: '3'