Graphite Grafana: Metrics Monitoring Made Easy
In this post we are going to learn how to monitor time series data by installing Graphite and Grafana on Ubuntu Server 18.04.
Join the DZone community and get the full member experience.
Join For FreeWhat Is Graphite?
Graphite stores our time series metrics. It also has the capability to show on-demand graphs of your selected data.
Graphite is composed of several components: Carbon, Whisper, and the Graphite-WebApp.
Carbon is what listens for your connects that will send time series data.
Whisper is the storage library that is used to store our time series data.
Finally, the Graphite WebApp is the pretty web front-end you see below.
Here is a screenshot of my production Graphite installation where I store metrics for this web site. You can also see a graph of my used disk space.
After we install Grafana we will add our Graphite server as a data source for the panels we will create.
What Is Grafana?
Grafana is a great open source graphing tool that can graph time series data.
It is highly configurable and the graphs look amazing.
After we have collected our time series data in Graphite, we can create several dashboards that tie everything together.
Here is a sample graph of my production web server time series data.
The left most panel is graphing the disk usage time series data I showed in the Graphite section.
Now that we know what Graphite Grafana together can do for us, let's get started configuring.
Installing Graphite
There are several different ways to install Graphite but I will go with what has worked easiest for me.
We will be installing Graphite and all of it's components in it's own Python Environment.
First, ensure you have a fully updated server and reboot.
# apt update && apt upgrade -y
# reboot
We are going to install Graphite into its default location of /opt/graphite
by creating a new Python Virtual Environment there.
# apt install virtualenv
# virtualenv /opt/graphite
# source /opt/graphite/bin/activate
(graphite)#
Next, we can use pip to install Graphite's components
pip install --no-binary=:all: https://github.com/graphite-project/whisper/tarball/master
pip install --no-binary=:all: https://github.com/graphite-project/carbon/tarball/master
pip install --no-binary=:all: https://github.com/graphite-project/graphite-web/tarball/master
Finally, we can start Graphite with this command:
(graphite)# PYTHONPATH=/opt/graphite/webapp gunicorn wsgi --workers=4 --bind=127.0.0.1:8080 --log-file=/var/log/gunicorn.log --preload --pythonpath=/opt/graphite/webapp/graphite &
This starts the web app running in the background. We need to disown this process so that it will keep running when we log out.
(graphite)# disown %1
Browse to the IP address or DNS address of your server and you will see the Graphite Web App.
Restarting Carbon
If you ever change the configuration for Carbon (which we will in the next post) you will need to know how to restart it so that the changes take effect.
# cd /opt/graphite
# source bin/activate
# bin/carbon-cache.py stop
# bin/carbon-cache.py start
# bin/carbon-cache.py status
Next we will install and configure Graphite.
Installing Grafana
Grafana comes as an installable binary file which makes installing it on Ubuntu Server 18.04 easy. You can find the latest version on the Grafana Downloads Page.
First, fetch the latest binary which is 5.2.2 at the time of this writing.
# wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_5.2.2_amd64.deb
Next, install the binary package:
# dpkg -i grafana_5.2.2_amd64.deb
Finally, start the Grafana service.
# systemctl start grafana-server
# systemctl enable grafana-server
The default port for Grafana is port 3000. So if you browse to your server on port 3000 you will see the Grafana dashboard.
http://{your server ip or dns}:3000
You will see a screen where it asks you to configure a data source.
We have Graphite installed already so we will add Graphite as a data source.
Graphite Grafana
Together these two solutions give us a great way to collect and display time series metrics data.
Currently, our installation isn't doing much.
In the next post we will configure SystemD to send metrics to Graphite for performance monitoring our infrastructure servers.
I hope you have enjoyed this post.
Published at DZone with permission of Bill Ward, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments