Riemann named function doesn't work with event

33 views
Skip to first unread message

Alexandr Stepanov

unread,
Mar 15, 2017, 1:39:16 PM3/15/17
to Riemann Users
Hi! I'm following the doc 


```(streams
  (smap (fn [event]
          (assoc event :time (unix-time)))
        index))```

I want to create named function like 


```
(defn testfuncy [event]
          (assoc event :time (unix-time)))

(let [index (index)]
  (streams
    (default :ttl 60
    (where (host "dev-kafka")
     (smap (testfuncy event) index)
      #(info %))

)))```

But this doesn't work, and have exception:

clojure.lang.Compiler$CompilerException: java.lang.ClassCastException: riemann.common$event cannot be cast to clojure.lang.Associative, compiling:(/opt/riemann/etc/riemann.config:44:1)
at clojure.lang.Compiler.load(Compiler.java:7391)
at clojure.lang.Compiler.loadFile(Compiler.java:7317)
at clojure.lang.RT$3.invoke(RT.java:320)
at riemann.config$include.invokeStatic(config.clj:412)
at riemann.config$include.invoke(config.clj:390)
at riemann.bin$_main.invokeStatic(bin.clj:99)
at riemann.bin$_main.invoke(bin.clj:85)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.AFn.applyTo(AFn.java:144)
at riemann.bin.main(Unknown Source)
Caused by: java.lang.ClassCastException: riemann.common$event cannot be cast to clojure.lang.Associative
at clojure.lang.RT.assoc(RT.java:792)
at clojure.core$assoc__4371.invokeStatic(core.clj:191)
at clojure.core$assoc__4371.invoke(core.clj:190)
at riemann.config$testfuncy.invokeStatic(riemann.config:41)
at riemann.config$testfuncy.invoke(riemann.config:40)
at riemann.config$eval36.invokeStatic(riemann.config:48)
at riemann.config$eval36.invoke(riemann.config:44)
at clojure.lang.Compiler.eval(Compiler.java:6927)
at clojure.lang.Compiler.load(Compiler.java:7379)
... 9 common frames omitted

Thanks

Aphyr

unread,
Mar 15, 2017, 4:56:09 PM3/15/17
to rieman...@googlegroups.com
On Wed, Mar 15, 2017 at 10:39:15AM -0700, Alexandr Stepanov wrote:
>Hi! I'm following the doc
>
>
>```(streams
> (smap (fn [event]
> (assoc event :time (unix-time)))
> index))```
>
>I want to create named function like
>
>
>```
>(defn testfuncy [event]
> (assoc event :time (unix-time)))
>
>(let [index (index)]
> (streams
> (default :ttl 60
> (where (host "dev-kafka")
> (smap (testfuncy event) index)

testfuncy is already a function of an event; you don't need to call it
with anything to use it as a stream.

--Kyle

Alexandr Stepanov

unread,
Mar 15, 2017, 5:07:38 PM3/15/17
to Riemann Users
Thanks for your reply, but when I call it

```
(let [index (index)]
  (streams
    (default :ttl 60
    (where (host "dev-deck-kafka")
     (smap (testfuncy) index)
      #(info %))

)))
```
I got


clojure.lang.Compiler$CompilerException: clojure.lang.ArityException: Wrong number of args (0) passed to: config/testfuncy, compiling:(/opt/riemann/etc/riemann.config:44:1) 

Mathieu Corbin

unread,
Mar 15, 2017, 5:30:11 PM3/15/17
to rieman...@googlegroups.com
Hi,

Just do:


(let [index (index)]
  (streams
    (default :ttl 60
    (where (host "dev-deck-kafka")
     (smap testfuncy index)
      #(info %))


--
You received this message because you are subscribed to the Google Groups "Riemann Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to riemann-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexandr Stepanov

unread,
Mar 15, 2017, 5:32:33 PM3/15/17
to Riemann Users
Mathieu you are awesome. thanks a lot! 
Reply all
Reply to author
Forward
0 new messages