Hi,
I was testing maintenacne-mode activation by sending special event with python riemann client
https://github.com/borntyping/python-riemann-clientSimple test I have created it was saving all events to log file if maintenance-mode is not activated. Here is the riemann.config file:
[root@metrics-collector1 ~]# cat /etc/riemann/riemann.config
; -*- mode: clojure; -*-
; vim: filetype=clojure
(logging/init {:file "/var/log/riemann/riemann.log"})
(defn maintenance-mode?
"Is Riemann currently in maintenance mode?"
[]
; Take an expression representing a query for maintenance mode
(->> '(and (= :host nil)
(= :service "maintenance-mode"))
; Search the current Riemann core's index for any matching events
(riemann.index/search (:index @core))
; Take the first match
first
; Find its state
:state
; Is it the string "active"?
(= "active")))
; 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 5 seconds.
(periodically-expire 5)
(let [index (index)]
; Inbound events will be passed to these streams:
(streams
(default :ttl 60
; Index all events immediately.
index
(where (not (maintenance-mode?)) #(info %) )
; Log expired events.
(expired
(fn [event] (info "expired" event))))))
After starting riemann server all events started to be saved to /var/log/riemann/riemann.log file.
I have sent maintenance-mode event with python riemann client:
[root@metrics-collector1 ~]# /usr/bin/riemann-client -H localhost -P 5555 send -h nil -s maintenance-mode -S active -l 100
{
"host": "nil",
"service": "maintenance-mode",
"state": "active",
"ttl": 100
}
Then I have checked the log file and events was still saved. I have expected events will not be saved to the log file when maintenance-mode is activated. Do you know why it didn't work?
Br,
Pawel