我有下面的函数,它得到一个带有服务名称和阈值的映射。它检查服务是否超过了定义的阈值,然后在事件上调用多个下游子级。
(defn tc
[s & children]
(where
(and (service (:service_name s)) (not (expired? event)))
(by [:host :service]
(where (> metric (:threshold s)
(with :state "critical"
(apply sdo children)))))))我想使用地图矢量动态构建一个流:
(def services [{:service "cpu/usage" :threshold 90}
{:service "memory/usage" :threshold 90}])当我试图在一个流中运行它时,我得到了以下警告:
(streams
(doseq [s services] (tc s prn)))
WARN [2015-01-05 14:27:07,187] Thread-15 - riemann.core - instrumentation service caught
java.lang.NullPointerException
at riemann.core$stream_BANG_$fn__11140.invoke(core.clj:19)
at riemann.core$stream_BANG_.invoke(core.clj:18)
at riemann.core$instrumentation_service$measure__11149.invoke(core.clj:57)
at riemann.service.ThreadService$thread_service_runner__8782$fn__8783.invoke(service.clj:66)
at riemann.service.ThreadService$thread_service_runner__8782.invoke(service.clj:65)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:701)如果我在doseq中运行streams函数,它就可以工作。此命令工作正常,并给出以下输出:
(doseq [s services]
(streams (tc s prn)))
#riemann.codec.Event{:host "testhost", :service "memory/usage", :state "critical", :description nil, :metric 91.0, :tags nil, :time 1420460856, :ttl 60.0}发布于 2015-01-06 07:15:40
如果你的事件没有所有必需的字段,它似乎会爆炸,这是一个类似的项目的示例,我从一个事件序列构建一个事件(减少)这并不完全是你正在做的事情,尽管我正在以同样的方式生成事件:
{:service (:service (first events))
:metric (->> events count)
:host "All-counts"
:state "OK"
:time (:time (last events))
:ttl default-interval}我特别是在缺少时间的时候得到了NPE。如果你不能从某个地方继承它,只要在这里没有一个合理的值就把它补上(例如使用now ),事件过期将不会起作用,你会耗尽内存
https://stackoverflow.com/questions/27779872
复制相似问题