Send changed event to influxdb

已查看 83 次
跳至第一个未读帖子

Elena

未读,
2016年7月28日 08:28:562016/7/28
收件人 Riemann Users
Hi.

I'm trying to send event to influxdb. I want to calculate time between events and sent the result event with this calculated metric to influxdb. I tryed 'with' and 'event' statements. This one returns me an error:

WARN [2016-07-28 12:19:15,064] defaultEventExecutorGroup-2-1 - riemann.streams - riemann.config$eval41$new_fork__7980__auto____45$fn__47@1caf9e56 threw
java.lang.ClassCastException: riemann.codec.Event cannot be cast to clojure.lang.IFn
        at riemann.config$test.invokeStatic(riemann.config:46)
 
Can you help me to understand what I'm doing wrong?

; -*- mode: clojure; -*-
; vim: filetype=clojure

(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 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

; Log expired events.
(expired
(fn [event] (info "expired" event))))))

; InfluxDB database details where Riemann will store the data.
(def influxdb-creds {
:host "localhost"
:port 8086
:db "riemann"
:username "riemann"
:password "riemann"
})

(def influxBatchSender
(batch 100 1/10
(async-queue! :agg {
:queue-size 1000
:core-pool-size 1
:max-pool-size 4
:keep-alive-time 60000 }
(influxdb influxdb-creds))))

(streams
(where (and (not (expired? event)) (host "xxx"))
prn
(by [:host :service]
(changed :time {:pairs? true}
(fn [[event event']]
(when-not (empty? event)
(prn "changed from" (:time event) "to" (:time event') "diff" (- (:time event') (:time event)))
(event {:service "test"
                     :metric (- (:time event') (:time event))} influxBatchSender))))))) 

Aphyr

未读,
2016年7月28日 15:30:522016/7/28
收件人 rieman...@googlegroups.com
On 07/28/2016 07:28 AM, Elena wrote:
> Hi.
>
> I'm trying to send event to influxdb. I want to calculate time between events
> and sent the result event with this calculated metric to influxdb. I tryed
> 'with' and 'event' statements. This one returns me an error:
>
> WARN [2016-07-28 12:19:15,064] defaultEventExecutorGroup-2-1 - riemann.streams -
> riemann.config$eval41$new_fork__7980__auto____45$fn__47@1caf9e56 threw
> java.lang.ClassCastException: riemann.codec.Event cannot be cast to clojure.lang.IFn
> at riemann.config$test.invokeStatic(riemann.config:46)
>
> Can you help me to understand what I'm doing wrong?

> (fn [[event event']]
> (when-not (empty? event)
> (prn "changed from" (:time event) "to" (:time event') "diff" (- (:time event') (:time event)))
> (event {:service "test"
>
> :metric (- (:time event') (:time event))}
> influxBatchSender)))))))

You've named this function's parameter `event`, which means you're shadowing the
`riemann.core/event` function you're trying to call. You can drop the call to
`event` altogether (maps are already events), change the argument name, or use
the fully qualified function name.

--Kyle

Elena

未读,
2016年8月1日 04:08:112016/8/1
收件人 Riemann Users
Thanks a lot. It helped me.
回复全部
回复作者
转发
0 个新帖子