Clojure仪表板查询
我正在尝试使用query在riemann仪表板上显示一个图形 “pingDelay>0” 我已经使用以下代码为我的数据编制了索引Clojure仪表板查询,clojure,riemann,riemann-dashboard,Clojure,Riemann,Riemann Dashboard,我正在尝试使用query在riemann仪表板上显示一个图形 “pingDelay>0” 我已经使用以下代码为我的数据编制了索引 (let [index (index)] (defn write-dht-metric [e] (let [dhtstate (re-find #"dht_status: health\.(\S+), msg count (\d+) \((\d+) bytes\).*peak \{ping = (\d+)" (:pgmsg e))] (if (
(let [index (index)]
(defn write-dht-metric [e]
(let [dhtstate (re-find #"dht_status: health\.(\S+), msg count (\d+) \((\d+) bytes\).*peak \{ping = (\d+)" (:pgmsg e))]
(if (not= dhtstate nil)
(do
(prn "RESULT>" dhtstate)
(index {:host "dht-info"
:service (:service e)
:time (unix-time)
:dhtStatus (get dhtstate 1)
:msgCount (get dhtstate 2)
:pingDelay (get dhtstate 3)}
)
)
)
)
)
)
然而,我并没有在图表上看到任何东西。早些时候,我认为可能是因为我的“pingDelay”在字符串“12345”中,所以我也尝试了:pingDelay#(Long.(get dhtstate 3)),但没有成功
有人能帮我做些什么让它工作吗
关于事实证明,我必须将pingDelay的值写入“:metric field”。它现在开始工作。在函数调用中定义顶级表单有点奇怪。它之所以有效,是因为定义一个var会将该var返回给调用表单。更典型的是这样写:
(defn write-dht-metric [e]
(let [dhtstate (re-find #"dht_status: health\.(\S+), msg count (\d+) \((\d+) bytes\).*peak \{ping = (\d+)" (:pgmsg e))]
(if (not= dhtstate nil)
(do
(prn "RESULT>" dhtstate)
(index {:host "dht-info"
:service (:service e)
:time (unix-time)
:dhtStatus (get dhtstate 1)
:msgCount (get dhtstate 2)
:pingDelay (get dhtstate 3)})))))
(let [index (index)]
(streams
write-dht-metric))
还有其他几种书写方式:
(defn write-dht-metric [e]
(let [dhstate (:dhstate e)]
(prn "RESULT>" dhtstate)
(index {:host "dht-info"
:service (:service e)
:time (unix-time)
:dhtStatus (get dhtstate 1)
:msgCount (get dhtstate 2)
:pingDelay (get dhtstate 3)})))
(let [index (index)]
(streams
(with :dhstate (re-find #"dht_status: health\.(\S+), msg count (\d+) \((\d+) bytes\).*peak \{ping = (\d+)" (:pgmsg event))
(when :dhstate
write-dht-metric)))