summaryrefslogtreecommitdiffstats
path: root/modules/tozt/files/kapacitor/disk.tick
blob: a263a0b9b2aa04e3780ba5077205dcfec2e75ab8 (plain) (blame)
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
dbrp "telegraf"."autogen"

var message = '''
{{- if eq .Level "OK" -}}
{{ index .Tags "host" }} is no longer using excessive disk IO
{{- else -}}
{{ index .Tags "host" }} is using excessive disk IO
{{- end -}}
'''

var details = '''
{{- if eq .Level "OK" -}}
{{ index .Tags "host" }} is now only averaging {{ index .Fields "activity" }}B/s of disk usage
{{- else -}}
{{ index .Tags "host" }} has been averaging {{ index .Fields "activity" }}B/s of disk usage for the last 10 minutes
{{- end -}}
'''

stream
|from()
    .measurement('diskio')
    .groupBy('host')
|eval(lambda: "read_bytes" + "write_bytes")
    .as('activity')
|sum('activity')
    .as('activity')
|derivative('activity')
    .nonNegative()
|window()
    .period(10m)
|mean('activity')
    .as('activity')
|alert()
    .crit(lambda: "activity" > 512*1024)
    .message(message)
    .details(details)