-
Notifications
You must be signed in to change notification settings - Fork 0
/
riemann.config
79 lines (59 loc) · 2.04 KB
/
riemann.config
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
; -*- mode: clojure; -*-
; vi: filetype=clojure
(require 'aero.core)
(logging/init {:file "riemann.log"})
(let [host "127.0.0.1"]
(tcp-server {:host host})
(udp-server {:host host}))
(instrumentation {:enabled? false})
(periodically-expire 10)
(defn int-cores [es]
(map
(fn [e] (update e :cores (fn [v] (Integer/parseInt v)))) es))
(defn high-cpu-load [{:keys [cores metric]}]
(< (* 2 cores) metric))
(def config
(let [home (System/getProperty "user.home")]
(aero.core/read-config (str home "/.re-ops.edn") {:profile :dev})))
(def smtp (get-in config [:shared :smtp]))
(def email (mailer smtp))
(def to (get-in config [:riemann :to]))
(def from (get-in config [:riemann :from]))
(def tell-ops (rollup 5 3600 (email to)))
(let [index (index)]
(streams
(default :ttl 60
index
(where (service "usb")
(by :host
(changed :result {:pairs? true}
(fn [[e1 e2]]
(when e1
(when-not (= (hash-set e1) (hash-set e2))
(riemann.email/email-event smtp {:to to :from from} e1)))))))
(where (and (tagged "success") (not (expired? event)))
(where (service "disk-usage")
(by :host
(where (<= 85 metric) tell-ops)))
(where (service "entropy/available")
(by :host
(fixed-event-window 5
(smap folds/mean
(where (<= 0 metric 1000) tell-ops)))))
(where (service "cpu/idle")
(by :host
(fixed-event-window 10
(smap folds/mean
(where (<= 0 metric 10) tell-ops)))))
(where (service "load/one")
(by :host
(fixed-event-window 10
(smap int-cores
(smap folds/mean
(where* high-cpu-load tell-ops))))))
(where (service "load/five")
(by :host
(fixed-event-window 5
(smap int-cores
(smap folds/mean
(where* high-cpu-load tell-ops))))))))))