-
Notifications
You must be signed in to change notification settings - Fork 5
/
f3ew_riemann.config
95 lines (89 loc) · 3.19 KB
/
f3ew_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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
(logging/init {:file "/var/log/riemann/riemann.log"})
; Listen on the local interface over TCP (5555), UDP (5555), and websockets
; (5556)
(let [host "0.0.0.0"]
(tcp-server {:host host})
(udp-server {:host host})
(ws-server {:host host}))
; Expire old events from the index every hour.
(periodically-expire 3600)
(let [index (index)]
; Inbound events will be passed to these streams:
(streams
(default :ttl 60
; Index all events immediately.
index
; Log expired events.
(expired
(fn [event] (info "expired" event))))))
(def graph (graphite {:host "graphite.example.com"}))
; Note #() is the Clojure construct to build an anonymous function
(defn notify [ recipient ]
(let [ email (mailer { :from "[email protected]" } ) ]
; Make copies of the incoming stream to be handled by different adapters
(by :service
; Log
#(info "Notifying about " %)
; Send to Graphite
#(graph %)
; Notify via email.
(email recipient)
)
)
)
(streams
(where (re-matches #"tst-clk-app-00.*" host)
(by :service
; Debug logging for matched events
; #(info %)
; ddt takes the difference between metric values.
; d(metric)/dt
; If you send a constant value, this will always return 0.
; (ddt 60
; (with {:description "Clicks, ddt"}
; (pipe -
; (splitp > metric
; 5.0 (with :state "critical" - )
; 100.0 (with :state "warning" - )
; (with :state "ok" - )
; )
; (notify "[email protected]")
; )
; )
; )
; -> is one of the Swiss arrow functions in Clojure
; http://clojuredocs.org/clojure.core/-> because this is hard to google for.
( ->
(rate 60
(with {:description "Clicks, ddt" :service "Click"}
(pipe -
(splitp > metric
5.0 (with :state "critical" - )
160.0 (with :state "warning" - )
(with :state "ok" - )
)
(notify "[email protected]")
)
)
; Due to the ->, ddt gets the output of rate as a stream and processes it via the with block.
( ddt
(with {:description "Clicks, ddt" :service "click_rate_accel"}
(pipe -
(splitp > metric
5.0 (with :state "critical" - )
160.0 (with :state "warning" - )
(with :state "ok" - )
)
(notify "[email protected]")
)
)
)
)
)
)
; Enable debug logging for unhandled events
; (else
; #(info %)
; )
)
)