Installing Graphite and Grafana to view graphs of Centreon

In this paper we will hallucinate… especially if you're a fan of measuring graphics and want to exploit… you can export the results of our Centreon to a machine with Grafana and get the best solution for displaying our data… They will be impressive dashboards that can generate, the will customize to our liking, metric combining intervals for each item that we monitored with Centreon. And super-simple!

 

Centreon (among others) It lets you export data format recolecciona Database Time Series (TSDB), as a result, we can store them in a database Graphite and Grafana present that data in beautiful Dashboards. Grafana is an Open platform to create our own dashboards that allow monitoring our infrastructure. In this document, Graphite and see how to install Grafana on a machine with CentOS 7. So, Centreon Nagios will monitor our or our platform as before, but also, Redirecting metrics that monitors a remote BD, and Grafana can read this information and so we create the Dashboard that interests us!

 

Eye that this document does not have to be used only for Nagios or Centreon, if not we will see in future documents how to read and treat information databases such as MySQL, You will see that interesting, We see future electricity consumption measurements of home or business, or anything you can think of, It really is impressive, especially if then we put this on a screen in our department. Or in our homes with a magic mirror type MagicMirror I'll tell, the… and I even dare to put pictures of what I have ridden at home so you can see that is awesome.

 

Installation of Graphite,

The Centreon machine in this example is the IP address 192.168.1.57 and where we will install Centos will Graphite and Grafana 192.168.1.104. We started!!

 

To install Graphite, We use the repository EPEL, if you have not installed, you must do, and install the necessary packages and Graphite:

yum install -y epel-release
yum install -y httpd graphite-web python-carbon perl

 

Initialise the interface of graphite and started running:

/usr/bin/graphite-manage syncdb --noinput
/usr/bin/graphite-build-index
/usr/bin/chown -R apache:apache /var/lib/graphite-web
systemctl start carbon-cache

 

Edit the file welcome and we discussed everything with pads (#).

vim /etc/httpd/conf.d/welcome.conf

 

Modificamos el fichero ‘/etc/httpd/conf.d/graphite-web.conf’ to allow access from any IP:

##ServerName graphite-web
<IfModule mod_authz_core.c>
    # Apache 2.4
    Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
    # Apache 2.2
    Order Deny,Allow
    Allow from all
</IfModule>

 

And restart the service to reload the configuration:

systemctl restart httpd

 

In addition to adding a couple of rules that will allow external access to the port of Graphite and web access, restart the firewall settings to recharge, for it:

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-port=2003/tcp
firewall-cmd --reload

 

Eye, we must indicate that the services to start booting the machine with Centos, and? We run for it:

chkconfig httpd on
chkconfig grafana-server on
chkconfig carbon-cache on

 

We can try to open Graphite to see if we have access and view the default agent if it contains some information, for it will not be easier than opening a browser to the IP address of CentOS, in this case as easy as http://192.168.1.104 data and see that we are having…

 

Redirect output Centreon Graphite,

Good, Now we'll make the Centreon Broker also write data to Graphite, To do this we take the following steps on the machine where we installed Centreon!

We install the plugin will need in the Broker with:

yum install -y centreon-broker-graphite

 

And we can open the GUI configuration of our Centreon, we are going to “Configuration” > “Pollers” > “Broker configuration” > “central-broker-master” > Eyelash “Output” > In the combo Output we choose 'Graphite – Storage – Graphite’ > “Add”, We completed the following fields as follows:

  • Name: Graphite
  • DB host: 192.168.1.104 (Graphite IP address)
  • DB port: 2003
  • DB user:
  • DB password:
  • Metric naming: centreon.metric.$HOST$.$SERVICE$.$METRIC$
  • Status naming: centreon.status.$HOST$.$SERVICE$

 

With that indicate where the information it collects export our Centreon and in what format you send to our Graphite (and then we will see in Grafana).

 

As usual, remember that after any configuration changes, we reload the config in Centreon, for it, We will do so: “Configuration” > “Pollers” > “Export configuration” > mark “Generate Configuration files” & “Run monitoring engine debug” & “Move Export Files” & in Method select “Reload”, finally press on “Export” and we wait…

after that, I recommend you restart these two services from its shell Centreon, we connect with Putty or whatever we want to run the machine Centreon:

service cbd restart
service centengine restart

 

If we want, we can return back to Graphite to see how we have new metrics that come from our beloved Centreon… the thing goes well, no?

 

Installing Grafana

Back to our machine with CentOS, we will continue and install and configure Grafana!

 

The first will add a new repository to your machine, for it, create file '/etc/yum.repos.d/grafana.repo’ with the following content:

[grafana]
name=grafana
baseurl=https://packagecloud.io/grafana/stable/el/7/$basearch
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

 

And proceed to install and start your service Grafana:

yum install -y grafana
systemctl start grafana-server

 

Add the firewall machine itself access to the port 3000 to connect to Grafana from any computer & reload with:

firewall-cmd --zone=public --permanent --add-port=3000/tcp
firewall-cmd --reload

 

And ready!! and tenmos (i) Graphite installed and configured, (ii) our Centreon already sends data to this machine and (iii) one Grafana installed to be able to interpret the data obtained and we show them in a Dashboards like that singer said torero… ‘im-pre-zionante’!!!

 

Accessing Grafana and created our first dashboard,

We can now open a browser to the IP address of your machine with CentOS and connect to grafana, in my example will be against this direction: http://192.168.1.104:3000 and we validate user default admin password 'admin'.

 

First of all you will set up a data source, that is, let's say that Grafana can read data from the database of Graphite, press first in “Add data source”,

 

 

And this connector indicate:

  • Name: Centreon
  • Type: Graphite
  • Url: http://localhost

And click on “Add”, I said, With this we will make Grafana can read data from the local machine, Graphite. In other documents we will see how to add other data sources to try and exploit other information in Grafana.

 

Following this assistant introduccón, press in “New dashboard” to create our first Dashboard!

 

Well honestly, Grafana use is super super easy, we can add different types of panels in each Dashboard, We started with the most typical, it is just the type 'Graph’ We understand that as are graphic, can be linear, in columns, estacado… all that you will discover, It is very intuitive!!!

 

We created this first panel that can resize to make it look more or less large, double click on the title you can edit, click on “Edit”,

 

And would the great Tamariz… Tiarararaaa!!!! ohhh magic!!! attentive….

This Panel can show what we want, we have several tabs (General, Metrics, Axes, Legend, Display…) I encourage you to you you discover or be patient and future posts I will put concrete examples. But we go, tab 'Metrics’ we can add the metrics that interest us see, do a very simple example, add it of type "Centreon’ > ‘metric’ > 'SERVER’ > 'ITEM MONITORED', and poof!!!! it will be shown on the graph, and we can see any server or device that monitorizemos with Centreon here!! We will draw both its name and all the services that we monitor from Centreon!!! olé, olé olé and Rigodón!!!

 

Do you think? You do not tell me we can not think what to display and how, with stunning graphics with Grafana?

Dedicating a little time we can create ourselves the dashboard with panels that interest us, each panel with metrics, which are, and you will see that can be customized to stop, to leave as we like more… keep trying that at some future document back to Grafana to see more possibilities!!!

 

Latest posts by Hector Herrero (see all)