1

I am using riemann output plugin in logstash and I want to alert using riemann when the user field is root.

Logstash-config:

if "server2-cronlog" in [tags]{
        riemann {
            riemann_event =>  [
                        "service", "My Awesome Logs",
                        "username", "%{user}",
                        "description", "%{command}"
                      ]
          }
    }

Riemann-config: I add the following lines to the end of riemann config file contents (as were when riemann was installed)

(def email(mailer {    :host "xyz"
            :port 25
            :user "abc@gmail.com"
            :from "abc@gmail.com"
}))

(def tell-ops(rollup 3 3600 (email "cde@gmail.com")))

(streams
(where (username "root") tell-ops)
)

; print events to the log
(streams
        prn)

Note: Our smtp server does not require password, thus it's not written in config.

I see from my logstash console a riemann event is generated.

In my riemann server console, I get the following warning:

WARN [2014-06-25 16:18:23,007] pool-1-thread-8 - riemann.streams - riemann.email$mailer$make_stream__17457$stream__17458@782bbb7b threw
java.lang.AssertionError: Assert failed: (or (and (nil? user) (nil? pass)) (and user pass))
    at postal.smtp$smtp_send_STAR_.invoke(smtp.clj:31)
    at postal.smtp$smtp_send.doInvoke(smtp.clj:58)
    at clojure.lang.RestFn.invoke(RestFn.java:423)
    at postal.core$send_message.invoke(core.clj:35)
    at riemann.email$email_event.invoke(email.clj:18)
    at riemann.email$mailer$make_stream__17457$stream__17458.invoke(email.clj:69)
    at riemann.streams$rollup$side_effects__10105$fn__10111.invoke(streams.clj:1040)
    at riemann.streams$rollup$side_effects__10105.invoke(streams.clj:1040)
    at riemann.streams$part_time_simple$stream__9560.invoke(streams.clj:611)
    at riemann.config$eval43$stream__44$fn__49.invoke(riemann.config:39)
    at riemann.config$eval43$stream__44.invoke(riemann.config:39)
    at riemann.core$stream_BANG_$fn__11096.invoke(core.clj:19)
    at riemann.core$stream_BANG_.invoke(core.clj:18)
    at riemann.transport$handle.invoke(transport.clj:116)
    at riemann.transport.tcp$tcp_handler.invoke(tcp.clj:84)
    at riemann.transport.tcp$gen_tcp_handler$fn__11316.invoke(tcp.clj:65)
    at riemann.transport.tcp.proxy$org.jboss.netty.channel.SimpleChannelHandler$ff19274a.messageReceived(Unknown Source)
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:88)
    at riemann.transport.tcp.proxy$org.jboss.netty.channel.SimpleChannelHandler$ff19274a.handleUpstream(Unknown Source)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:70)
    at riemann.transport.proxy$org.jboss.netty.handler.codec.oneone.OneToOneDecoder$ff19274a.handleUpstream(Unknown Source)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43)
    at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67)
    at org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor$ChildExecutor.run(OrderedMemoryAwareThreadPoolExecutor.java:314)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)

So console is: the above warning, then three events description with state, description, then same warning and end nullpointer exception.

The email is not being sent to the user. What is wrong??

Siddharth Trikha
  • 2,648
  • 8
  • 57
  • 101
  • 1
    Seems as if the `mailer` function expects a map with either both `:user` and `:pass` being `nil` or both being set to valid values. Since you're missing the `:pass` key (note: it might be called differently; please refer to the documentation in that case), the assertion inside `mailer` throws an error. – xsc Jun 25 '14 at 11:43
  • @xsc: I removed the user and the mail is sent, however in riemann server comsole i can see a NullPointerException too like: ` `java.lang.NullPointerException atclojure.lang.Numbers.ops(Numbers.java:961) atclojure.lang.Numbers.gt(Numbers.java:227 atriemann.index$nbhm_index$reify__8966$fn__8968.invoke(index.clj:73)` – Siddharth Trikha Jun 26 '14 at 04:05
  • Without the riemann version, an excerpt from the code that throws the exception and a full stacktrace it's quite hard to examine this. And unless this is still connected to your mailer issue, maybe open a new question? :) – xsc Jun 26 '14 at 08:00
  • @xsc: Riemann version: riemann-0.2.5. I guess it's bug in this version when event is missing a ttl field. – Siddharth Trikha Jun 26 '14 at 08:06

0 Answers0