-
Notifications
You must be signed in to change notification settings - Fork 1
/
cpu.tick
141 lines (126 loc) · 4.64 KB
/
cpu.tick
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
dbrp "graphite"."default"
var log_url = 'http://127.0.0.1:7777/'
var win_period = 7m
var win_every = 2m
var info_core_level = 5
var warn_core_level = 3
var crit_core_level = 0
var info_host_level = 20
var warn_host_level = 10
var crit_host_level = 5
var info_load_level = 30
var warn_load_level = 60
var crit_load_level = 70
var load = stream
|from()
.measurement('load')
.groupBy(*)
|flatten().tolerance(5s)
|default()
.field('info_load_level', info_load_level)
.field('warn_load_level', warn_load_level)
.field('crit_load_level', crit_load_level)
var cputime_all = stream
|from()
.measurement('cpu')
.groupBy(*)
// idle interrupt nice softirq steal system user wait
var cputime_host = cputime_all
|groupBy('host', 'type')
|flatten().tolerance(5s)
var cputime_host_calc = cputime_host
@streamAggregateUDF()
.aggregate('last(idle) as idle.last')
.aggregate('mean(idle) as idle.mean')
.aggregate('last(interrupt) as interrupt.last')
.aggregate('mean(interrupt) as interrupt.mean')
.aggregate('last(nice) as nice.last')
.aggregate('mean(nice) as nice.mean')
.aggregate('last(softirq) as softirq.last')
.aggregate('mean(softirq) as softirq.mean')
.aggregate('last(steal) as steal.last')
.aggregate('mean(steal) as steal.mean')
.aggregate('last(system) as system.last')
.aggregate('mean(system) as system.mean')
.aggregate('last(user) as user.last')
.aggregate('mean(user) as user.mean')
.aggregate('last(wait) as wait.last')
.aggregate('mean(wait) as wait.mean')
.timeAggregateRule('last')
.emitTimeout(10s)
|default()
.field('info_host_level', info_host_level)
.field('warn_host_level', warn_host_level)
.field('crit_host_level', crit_host_level)
|log()
var cputime_all_win = cputime_all
|groupBy('cpu', 'host', 'type')
|flatten().tolerance(5s)
|window()
.period(win_period)
.every(win_every)
var cputime_win_calc = cputime_all_win
@batchAggregateUDF()
.aggregate('last(idle) as idle.last')
.aggregate('mean(idle) as idle.mean')
.aggregate('last(interrupt) as interrupt.last')
.aggregate('mean(interrupt) as interrupt.mean')
.aggregate('last(nice) as nice.last')
.aggregate('mean(nice) as nice.mean')
.aggregate('last(softirq) as softirq.last')
.aggregate('mean(softirq) as softirq.mean')
.aggregate('last(steal) as steal.last')
.aggregate('mean(steal) as steal.mean')
.aggregate('last(system) as system.last')
.aggregate('mean(system) as system.mean')
.aggregate('last(user) as user.last')
.aggregate('mean(user) as user.mean')
.aggregate('last(wait) as wait.last')
.aggregate('mean(wait) as wait.mean')
.timeAggregateRule('last')
|log()
cputime_win_calc
|default()
.field('incident-owners', 'nobody')
.field('incident-is-expected', FALSE)
.field('incident-comment', '')
.field('alert-on', 'cpu-idle-time-per-core')
.field('info_core_level', info_core_level)
.field('warn_core_level', warn_core_level)
.field('crit_core_level', crit_core_level)
// durations are not supported for default()
// .field('win_period', win_period)
// .field('win_every', win_every)
|eval(lambda: win_period, lambda: win_every)
.as('win-period', 'win-every')
.keep()
|alert()
.info(lambda: "idle.mean" < "info_core_level")
.warn(lambda: "idle.mean" < "warn_core_level")
.crit(lambda: "idle.mean" < "crit_core_level")
.post(log_url)
.id('{{ .Name }}/{{ .TaskName }}/cpu-idle-time-per-core:{{ .Group }}')
cputime_host_calc
|default()
.field('incident-owners', 'nobody')
.field('incident-is-expected', FALSE)
.field('incident-comment', '')
.field('alert-on', 'cpu-idle-time-mean-host')
|alert()
.info(lambda: "idle.mean" < "info_host_level")
.warn(lambda: "idle.mean" < "warn_host_level")
.crit(lambda: "idle.mean" < "crit_host_level")
.post(log_url)
.id('{{ .Name }}/{{ .TaskName }}/cpu-idle-time-mean-host:{{ .Group }}')
load
|default()
.field('incident-owners', 'nobody')
.field('incident-is-expected', FALSE)
.field('incident-comment', '')
.field('alert-on', 'cpu-load')
|alert()
.info(lambda: "longterm" > "info_load_level")
.warn(lambda: "longterm" > "warn_load_level")
.crit(lambda: "longterm" > "crit_load_level")
.post(log_url)
.id('{{ .Name }}/{{ .TaskName }}:{{ .Group }}')