Sunday, May 19, 2013

Riemann and Drools

Riemann (http://riemann.io/is great tool for monitoring applications. When it comes to monitoring, there are good number for tools which help you monitor your infrastructure - things like cpu, disk, network, routers, databases etc. However, I've not seen many tools which can be used for custom application monitoring - exceptions, errors, statistics which are available inside a running program. Tools like Nagios, Zabbix and others do good job in monitoring the infrastructure, but what if you want to send your custom events, notifications or metrics ? The integration with these tools is not so easy ... usually a hack.

Custom application information is usually spit out to log files and there are separate scanners which run at periodic intervals and "grep" out this information. What we if spit out this information onto network and let something on other side collect this for us, apply filters/rules and notify us appropriately? That's exactly what Riemann does for you ...

Riemann aggregates events from your servers and applications with a powerful stream processing language. Send an email for every exception raised by your code. Track the latency distribution of your web app. See the top processes on any host, by memory and CPU. Combine statistics from every Riak node in your cluster and forward to Graphite. Send alerts when a key process fails to check in. Know how many users signed up right this second.

There is only one catch - you need to write your rules in Clojure! Clojure is lisp like language. Not many developers may know about it. What we need is a simple framework where we can set rules quickly. This is where Drools shines. Writing rules in DRL is pretty simple and intuitive. I built a simple wrapper which exports Riemann event to JSON, marshall it into Java object, insert it into Drools working memory and then apply rules. This has helped us to quickly setup custom rules.

1 comment:

  1. you can also stream process the events with zabbix https://www.zabbix.com/documentation/2.0/manual/appendix/triggers/functions and then decide what to do with them either send email, send alert etc. why not just use zabbix for that? (also supports macros).

    ReplyDelete