Re: [riemann-users] Unable to create function

32 views
Skip to first unread message

Kyle Kingsbury

unread,
Dec 9, 2014, 9:48:32 AM12/9/14
to rieman...@googlegroups.com

You have an unmatched close parenthesis on line 68, char 37.

On Dec 9, 2014 1:02 AM, Abhishek Gupta <mail2ab...@gmail.com> wrote:
Hi Kyle,

I am trying to make a generic function for sending notification. But getting error. Can some one please help? I am kind of new in Clonjour...

(let [email (mailer {:from "rie...@localhost.com"})]
(streams
  (where (and (service #"availability$")
      (not (expired? event))
      (> metric 100.00))
      #(info "[Inside crossing metric rule 1]" %)
      (with :metric 1
        (rate 3
          (where (> metric 3/3)
            #(info "[TC]" %)
            (email "abhishe...@xxx.com")
          )))))
)


(defn tc [eventcnt serviceName numsec threshold toEmail]
  (where (and (service #serviceName)
      (not (expired? event))
      (> metric threshold))
      #(info "[Inside crossing metric rule 1]" %)
      (with :metric 1
        (rate numsec
          (where (> metric eventcnt/numsec)
            #(info "[TC]" %)
            (email toEmail)
          )))) 
)

I am getting below exception

INFO [2014-12-09 00:47:45,875] main - riemann.bin - PID 41021

ERROR [2014-12-09 00:47:45,915] main - riemann.bin - Couldn't start

java.lang.RuntimeException: Unmatched delimiter: ), compiling:(/Users/agupta9/riemann/riemann-0.2.6/etc/riemann.config:68:37)

at clojure.lang.Compiler.load(Compiler.java:7137)

at clojure.lang.Compiler.loadFile(Compiler.java:7086)

at clojure.lang.RT$3.invoke(RT.java:318)

at riemann.config$include.invoke(config.clj:349)

at riemann.bin$_main.invoke(bin.clj:68)

at riemann.bin$_main.invoke(bin.clj:59)

at clojure.lang.AFn.applyToHelper(AFn.java:154)

at clojure.lang.AFn.applyTo(AFn.java:144)

at riemann.bin.main(Unknown Source)

Caused by: java.lang.RuntimeException: Unmatched delimiter: )

at clojure.lang.Util.runtimeException(Util.java:221)

at clojure.lang.LispReader$UnmatchedDelimiterReader.invoke(LispReader.java:1099)

at clojure.lang.LispReader.read(LispReader.java:183)

at clojure.lang.LispReader$CtorReader.readTagged(LispReader.java:1168)

at clojure.lang.LispReader$CtorReader.invoke(LispReader.java:1164)

at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:609)

at clojure.lang.LispReader.readDelimitedList(LispReader.java:1138)

at clojure.lang.LispReader$ListReader.invoke(LispReader.java:972)

at clojure.lang.LispReader.readDelimitedList(LispReader.java:1138)

at clojure.lang.LispReader$ListReader.invoke(LispReader.java:972)

at clojure.lang.LispReader.readDelimitedList(LispReader.java:1138)

at clojure.lang.LispReader$ListReader.invoke(LispReader.java:972)

at clojure.lang.LispReader.readDelimitedList(LispReader.java:1138)

at clojure.lang.LispReader$ListReader.invoke(LispReader.java:972)

at clojure.lang.LispReader.read(LispReader.java:183)

at clojure.lang.Compiler.load(Compiler.java:7126)

... 8 more

--
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-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhishek Gupta

unread,
Dec 9, 2014, 7:24:55 PM12/9/14
to rieman...@googlegroups.com
Hi Kyle,

Looks like regex pattern was causing it. Now i am getting below error

My Code is:

(defn tc [eventCnt serviceName numSec threshold]

  (where (and (service serviceName)

      (not (expired? event))

      (> metric threshold))

      #(info "[Inside crossing metric rule 1]" %)

      (with :metric 1

        (rate numSec

          (where (> metric eventCnt/numSec)

            #(info "[TC]" %)


          ))))

)


(let [email (mailer {:from "rie...@localhost.com"})]

(streams

        (tc 3 "availability" 3 100.00

        (email "abhishe...@ag.com"))

))



java.lang.RuntimeException: No such namespace: eventCnt, compiling:(/Users/agupta9/riemann/riemann-0.2.6/etc/riemann.config:74:11)

at clojure.lang.Compiler.analyze(Compiler.java:6464)

at clojure.lang.Compiler.analyze(Compiler.java:6406)

at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:957)

at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)

at clojure.lang.Compiler.analyze(Compiler.java:6445)

at clojure.lang.Compiler.analyze(Compiler.java:6406)

at clojure.lang.Compiler.analyzeSeq(Compiler.java:6639)

at clojure.lang.Compiler.analyze(Compiler.java:6445)

at clojure.lang.Compiler.analyze(Compiler.java:6406)

at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782)

at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100)

at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)

at clojure.lang.Compiler.analyze(Compiler.java:6445)

at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632)

at clojure.lang.Compiler.analyze(Compiler.java:6445)

at clojure.lang.Compiler.access$100(Compiler.java:38)

at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6050)

at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)

at clojure.lang.Compiler.analyze(Compiler.java:6445)

at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632)

at clojure.lang.Compiler.analyze(Compiler.java:6445)

at clojure.lang.Compiler.analyze(Compiler.java:6406)

Aphyr

unread,
Dec 9, 2014, 7:28:30 PM12/9/14
to rieman...@googlegroups.com
On 12/09/2014 04:24 PM, Abhishek Gupta wrote:
> No such namespace: eventCnt,

eventCnt/whatever is Clojure syntax for a namespace, and no such namespace
exists. May I suggest http://aphyr.com/tags/Clojure-from-the-ground-up?

--Kyle

Abhishek Gupta

unread,
Dec 9, 2014, 7:33:25 PM12/9/14
to rieman...@googlegroups.com
Sorry figured out that it was language problem. But can't figure about this error:

Code i have:

(defn tc [eventCnt serviceName numSec threshold]

  (where (and (service serviceName)

      (not (expired? event))

      (> metric threshold))

      #(info "[Inside crossing metric rule 1]" %)

      (with :metric 1

        (rate numSec

          (where (> metric (/ eventCnt numSec))

            #(info "[TC]" %)


          ))))

)


(let [email (mailer {:from "rie...@localhost.com"})]

(streams

        (tc 3 "availability" 3 100.00

        (email "abhishe...@ag.com"))

))



clojure.lang.ArityException: Wrong number of args (5) passed to: config/tc, compiling:(/Users/agupta9/riemann/riemann-0.2.6/etc/riemann.config:78:2)

at clojure.lang.Compiler.load(Compiler.java:7142)

at clojure.lang.Compiler.loadFile(Compiler.java:7086)

at clojure.lang.RT$3.invoke(RT.java:318)

at riemann.config$include.invoke(config.clj:349)

at riemann.bin$_main.invoke(bin.clj:68)

at riemann.bin$_main.invoke(bin.clj:59)

at clojure.lang.AFn.applyToHelper(AFn.java:154)

at clojure.lang.AFn.applyTo(AFn.java:144)

at riemann.bin.main(Unknown Source)

Caused by: clojure.lang.ArityException: Wrong number of args (5) passed to: config/tc

at clojure.lang.AFn.throwArity(AFn.java:429)

at clojure.lang.AFn.invoke(AFn.java:48)

at riemann.config$eval144.invoke(riemann.config:83)

at clojure.lang.Compiler.eval(Compiler.java:6703)

at clojure.lang.Compiler.load(Compiler.java:7130)

... 8 more

Aphyr

unread,
Dec 9, 2014, 7:40:05 PM12/9/14
to rieman...@googlegroups.com
On 12/09/2014 04:33 PM, Abhishek Gupta wrote:
> Wrong number of args (5) passed to: config/tc

How many arguments does tc take?

--Kyle

Abhishek Gupta

unread,
Dec 9, 2014, 8:21:01 PM12/9/14
to rieman...@googlegroups.com
Thanks Kyle. Got it. I am learning with you :). I modified code but my code doesn't seem to be working now. Please help. Goal of this function is to send notification if in numsec eventcnt crosses threshold.

(defn alertrule [eventCnt serviceName numSec threshold]

        #(info "[Inside function 1 rule]" %)

  (where (and (= service serviceName)

      (not (expired? event))

      (> metric threshold))

      #(info "[Inside crossing metric rule 1]" %)

      (with :metric 1

        (rate numSec

          (where (> metric (/ eventCnt numSec))

            #(info "[TC]" %)

                (fn [] "1")

          ))))

)


(let [email (mailer {:from "rie...@localhost.com"})]

(streams

        (where (nil? (alertrule 3 "availability" 3 100.00))

                (email "abhishe...@ag.com")

        )

))

Aphyr

unread,
Dec 9, 2014, 8:24:38 PM12/9/14
to rieman...@googlegroups.com
On 12/09/2014 05:21 PM, Abhishek Gupta wrote:
> (fn [] "1")

What's that for?

--Kyle

Abhishek Gupta

unread,
Dec 9, 2014, 9:59:24 PM12/9/14
to rieman...@googlegroups.com
We receive many events. I have to send notification in case of 3 events crosses 200 threshold in 5sec. Please let me know what is wrong?

Abhishek Gupta

unread,
Dec 9, 2014, 10:08:36 PM12/9/14
to rieman...@googlegroups.com
Just to return some value if it matches condition. As of now my event itself not passing condition (where (> metric eventCnt/numSec)


I try to print what is being passed and it prints nil

#(info "[Printing params]" (:service %) (:metric %) (:eventCnt %))


Please help.

Reply all
Reply to author
Forward
0 new messages