Clojure 如何使用Riemann客户端动态发送XDB标记
是否可以动态发送influx db标记,以下配置似乎不起作用,因为当我试图通过influx db客户端选择所有标记时,它返回0个结果,请告知应该如何更改。提前谢谢Clojure 如何使用Riemann客户端动态发送XDB标记,clojure,influxdb,riemann,Clojure,Influxdb,Riemann,是否可以动态发送influx db标记,以下配置似乎不起作用,因为当我试图通过influx db客户端选择所有标记时,它返回0个结果,请告知应该如何更改。提前谢谢 (def send-influx (influxdb/influxdb { :host "localhost" :db "riemann" :username "riemann" :password "riemann"} )) (streams (where (and (not (expired?
(def send-influx
(influxdb/influxdb {
:host "localhost"
:db "riemann"
:username "riemann"
:password "riemann"}
))
(streams
(where (and (not (expired? event)) (service "service"))
#(info %)
(by [:host :service :id]
(changed :metric {:pairs? true}
(fn [[startEvent endEvent]]
(when-not (empty? startEvent)
(let [diff (- (:metric endEvent) (:metric startEvent))]
(send-influx [{
:host (:host startEvent),
:service (:service startEvent),
:id (:id startEvent),
:metric diff,
:time (:time startEvent) },
:tag-fields {:id (:id startEvent)} }]
)
)
)
)
)
)
))
以下是Riemann文档中的一个示例:
(def influx (influxdb {:host "localhost"
:db "riemann"
:version :new-stream}))
(streams
(smap
(fn [event]
(assoc event :measurement (:service event)
:influxdb-tags {:state (:state event)}
;; :value = 0 by default
:influxdb-fields {:value (or (:metric event) 0)}))
influx))
如您所见,应该在事件中使用:measurements、:influxdb标记和:influxdb字段键
此配置应适用于Riemann 0.2.13或更高版本。不幸的是,它没有多大帮助,因为出于某些原因,由于版本不兼容或smth,出现了一些解析异常,但是我最终能够通过将配置更改为以下内容使其正常工作
(def send-influx
(influxdb/influxdb {
:host "localhost"
:db "riemann"
:username "riemann"
:password "riemann"
:tag-fields #(:id)})
(streams
(where (and (not (expired? event)) (service "service"))
#(info %)
(by [:host :service :id]
(changed :metric {:pairs? true}
(fn [[startEvent endEvent]]
(when-not (empty? startEvent)
(let [diff (- (:metric endEvent) (:metric startEvent))]
(send-influx [{
:host (:host startEvent),
:service (:service startEvent),
:id (:id startEvent),
:metric diff,
:time (:time startEvent) },
:id (:id startEvent) }]
)
)
)
)
)
)
))
“应该”但不是