Skip to main content

Zabbix and CloudWatch: mix them together the Grafana way.

Many times, when I am debugging an environment, I find myself opening a lot of web browser tabs and windows to get metrics and see graphs from a number of data sources. It is a tiresome and prone to error way to go as each metric can be presented in a different timezone, and there is no way to stack them together.
Grafana is an excellent solution to this problem as it can aggregate and mix many data sources and present them in a rich way. In this post I will show how to aggregate and mix metrics from Zabbix and AWS CloudWatch.

Installing Grafana

We will install Grafana 2.5.0 on an Ubuntu 14.04 server. Full installation documentation can be found here.
First, download and install the .deb package and its dependencies:
1
2
3
$ sudo apt-get install -y adduser libfontconfig
$ sudo dpkg -i grafana_2.5.0_amd64.deb
Now, start the service:
1
$ sudo service grafana-server start
The Grafana UI is accessible at FQDN/IP Address:3000:
Image 1
The default username is admin and the default password is also admin (and yes, you should change it!)

Adding Zabbix as a Data Source

Now that we have Grafana up and running we will need to add our Zabbix server as a data source. To do this, we will use grafana-zabbix. The original instruction can be found here (go to the Grafana 2.1.x and 2.5.x section).
First, lets download the grafana-zabbix tarball to some directory on the Grafana server and extract it:
Second, lets copy the Zabbix directory from the extracted tarball to the Grafana data source plugin directory and restart the Grafana server:
1
2
$ sudo cp -R grafana-zabbix-2.5.0/zabbix/ /usr/share/grafana/public/app/plugins/datasource/
$ sudo service grafana-server restart
Now, lets add the Zabbix server as a data source. on the main UI page press on Data Sources (1) and then on the Add new tab (2):
Image 2
At the Add data source section give a name to the data source (1) and select Zabbix at the Type drop-down list (2). At the Http settings set the url to the API end point of the Zabbix server, which is usually http://<zabbix-server>/zabbix/api_jsonrpc.php (3). At the Zabbix API details fill in the Zabbix User and its Password (this user must have permissions that will allow us access to the required information in the Zabbix server, 4). Enable the Trends option (5) and press on Add (6):
Image 3
After you have pressed on the Add button, the Test Connection button will appear (1). Press on this button to test the connection. Finally, if the connection test was successful, press on Save (2):
Image 4

Adding CloudWatch as a Data Source

on the main UI page press on Data Sources (1) and then on the Add new tab (2):
Image 2
At the Add data source section give a name to the data source (1) and check the Default check box (2). Select CloudWatch at the Type drop-down list (3). At the Default Region, fill in the AWS default region (4) and press on ADD (5):
Image 5
To access the CloudWatch data we need permissions to the relevant AWS APIs. There are two ways to accomplish that. The first way, which you can use both if you are running your Grafana server on an EC2 instance or on a machine outside AWS, is to use AWS access keys. How to generate and download the keys is beyond the scope of this blog, but here is a good place to start. After you have generated the keys, create  a directory named .aws in the home directory of the user running the Grafana server, and there create a file named credentials:
1
2
# mkdir ~/.aws
# vim ~/.aws/credentials
To this file, paste the following (replacing the AWS access and secret access keys and region with your access keys and AWS region respectively):
1
2
3
4
[default]
aws_access_key_id = <aws_access_key_id >
aws_secret_access_key = <aws_secret_access_key>
region = <region>
A second way to access the CloudWatch APIs, which will work only for EC2 instances, is to attache an IAM role to the instance (this is the best and most secure way).

Mixing the Data Sources

Now that we have both Zabbix and CloudWatch as data sources on our Grafana server we can start visualizing the data collected. Lets start by creating a new dashboard. On the main UI page press on the dashboard drop-down list (1) and in the popup window that appeared press on +New (2):
Image 2
Lest give a title to the new dashboard. Press on the Manage Dashboard button (1) and than on Settings. In the General (2) tab enter a Title for the dashboard (3) and set the Timezone (4) and finally save the changes (5) :
Image 101
Now, lets create our first graph. Press on the green row  button (1) and select Add Panel (2) and Graph (3):
Image 102
Press on no title (click here) on the new graph that appeared (1) and select Edit (2):
Image 2
In the Graph section select the General tab (1) and give a Title to the new graph (2):
Image 2
Now lets get some metrics from Zabbix. Press on the Metrics tab (1) and select Zabbix-Server as the Datasource (2). In the Group select the group (3), in the Host select the host (4), In the Application select the Zabbix application you want (5) and finally select the Zabbix item you want to plot (6). I am plotting memory metrics:
Image 2
To added another metric on the same graph press on “+ Query” and follow the same steps above.
To set the correct Y-axes units for the memory metric press on the Axes & Grid tab (1), and set the Unit of the Left Y (2) to data | bytes (3):
Image 2
The final result should look similar to this:
Image 2
As a last step, lets add another graph, but this time we will use CloudWatch as the data source. Add another graph by Pressing on the “+ ADD ROW” button and than on the green row button and select Add Panel and Graph. Follow the same steps presented above but this time select CloudWatch as the data source (1). Select the region you are using (2), the namespace (3), the metric (4) and the Stats (5). In the Dimensions press on “+” and select the CloudWatch dimension you want and its value (6). I have chosen the sum of the 5xx error code of some elastic load balancer (ELB):
Image 2
The final result with both the Zabbix and CloudWatch metrics should look similar to this:
Image 2

Comments

  1. I truly appreciate the time and work you put into sharing your knowledge. I found this topic to be quite effective and beneficial to me. Thank you very much for sharing. Continue to blog.

    Data Engineering Services 

    AI & ML Solutions

    Data Analytics Services

    Data Modernization Services

    ReplyDelete

Post a Comment

Popular posts from this blog

Zabbix, AWS and Auto Registration

One of the things I love the most with AWS is  auto-scaling . You choose an AMI, set some parameters and AWS will spin instances up and down whenever a threshold is breached. But with all these instances spinning up and down there are some unknowns. For example, what is the IP address of the new instance? Its host name? This can be critical when other components of your infrastructure are dependent on knowing these parameters. I had this problem when I started to use  Zabbix  as the monitoring system. At first it seemed like a complicated one, but Zabbix has a wonderful feature called  Auto Registration  which can be used exactly for this situation. I will try to show how to configure auto registration both on the client (EC2 instance running Ubuntu 14.04) and on the Zabbix server (Zabbix Server 2.4.2). Zabbix-agent Installation and Configuration Let’s start with installing zabbix-agent on the Ubuntu client: 1 2 $ sudo apt-get update $ sud...

SIPp cheatsheet

SIPp  is a free test tool and traffic generator for the SIP protocol. It uses XML format files to define test scenarios. General usage: sipp remote_host[:remote_port] [options] Some important command-line options: -sf filename Load test scenario from specified file. -inf filename Use CSV file to insert data substituted for [field0], [field1], etc into XML scenario. First line of file describes order of inserting field sets (SEQUENTIAL/RANDOM/USE). -sn name Use one of the embedded, predefined scenarios like "uac", "uas". -r rate Scenario execution rate, default value = 10 times per period, default period = 1000 ms. -rp period Scenario execution period [ms], combined with execution rate. Execution rate is combined of rate and period parameters, i.e. if period = 3500 and rate = 7 there will be 7 calls in 3.5 s. -t transport mode Set the transport mode: "u1" - UDP, one socket (default), "un" - UDP, one socket per call, other modes (...

Creating an OpenStack development environment with an existing External Network via Packstack

Packstack provides a very simple, and very well automated process for reading development environments for OpenStack. I’d like to document here just some reproducible steps I’ve been using to set up these sorts of environments. The process for running this on a single node is very straightforward: http://haidv204.blogspot.com/2018/06/how-to-install-openstack-using-rdo.html and expanding this setup to multiple nodes is similarly straightforward; you can replace the flag --allinone with  --install-hosts=${controller_node_ip},${compute_node_1_ip},${compute_node_2_ip}... and it fires off a multi-node setup. This, however, does not assume you have external networks or other parts of your network outside of OpenStack you’d like these resources to be able to connect to. The servers in use in my environment are: Controller:  16GB RAM / 100GB Disk, 8 vCPUs  Note:  This will work with much fewer resources. I deployed this into a public cloud — for this reason, I al...