How to Configure Riemann

How to Configure Riemann

In our last blog of the Riemann Series, we learned about Riemann and How to Install Riemann on Ubuntu. In this blog, we will understand Riemann's Configuration.

Riemann Configuration

Riemann is configured using Clojure Language. This means our configuration file is processed as Clojure Program, and to process events and send notifications and metrics we will be writing Clojure.

Riemann's Base Configuration

When we install Riemann in our system it comes with a default configuration file present in the location /etc/riemann/riemann.config

Riemann Config File Path

Let's see the default configuration file of Riemann.

riemann default configuration file

Now we will understand the configuration file, and for this, we will divide the configuration into 3 sections.

NOTE: Any line or string prefixed with ; is a comment in Clojure.

First section :

We are setting up Riemann logs in a file. Here we are calling a function logging/init

We have specified the namespace of the function as 'logging' and the function name as 'init' and then subsequent arguments.

-> namespace is a way of organizing code in Clojure.

In this case, the argument is a map that can contain any parameters we want to pass to our logging/init function. Inside our map, we have specified a single parameter ":file" with a value "/var/log/riemann/riemann.log" where we want to store Riemann Logs.

-> :file is a Clojure keyword that is commonly used inside collections like a map to mark the key in the key/value pair.

So in our first section, we are done with writing Riemann logs in a file.

Second section :

In our second section, we will be configurtion Riemann Interface. Riemann generally listens on TCP, UDP and a WebSockets interface. By default, the TCP, UDP and WebSockets interface is bound to 127.0.0.1 or LocalHost. TCP, UDP on port 5555 and WebSockets on port 5556.

We can see our interface configuration is inside a stanza starting with 'let'.

The let expression creates an immutable alias for the symbols within a specific expression. The let expression takes a vector of one or more bindings. ( Bindings are pairs of symbols and values that are bound for that expression, symbols are pointers to values).

Let's understand this with help of an example, here in the expression the symbol host has a value of 127.0.0.1 The binding is only valid locally to our let expression.

This is useful because it allows us to override existing values of symbols inside the expression. So here the value of the host is set to 127.0.0.1, then we are calling tcp-server, udp-server and ws-server functions with that host symbol as the value of :host parameter. This set the host interface of TCP, UDP and WebSockets server to 127.0.0.1

NOTE: let binding is only limited to the expression itself. Outside the expression, the host symbol would be undefined. Also, the host symbol is immutable inside the expression in which it is defined. We cannot change the value of the host inside the expression.

For our purpose having Riemann bound to localhost isn't useful. So let's bind this server to all available interfaces.

We have updated the value of the host symbol from 127.0.0.1 to 0.0.0.0

We can also adjust the ports being used by Riemann by adding the :port argument to our map.

Now we will reload our Riemann Server to make those changes applicable.

#reloading the Riemann Server 
service riemann reload

NOTE: When we reload our Riemann Server and if we make a configuration mistake or syntax error then Riemann will continue with old configuration and won't apply the new one. And also log the error message.

So in our Second section, we have learned about the let expression and have also configured our Riemann server to listen for all available interfaces.

In our next blog, we will explore the last stanza and will learn about Event, Streams and Index in Riemann.


Hope you find this blog helpful !! See you in the next blog !! Keep Learning !!

Did you find this article valuable?

Support Goel Academy by becoming a sponsor. Any amount is appreciated!