Tooling in DevOps: Installing Graphite for monitoring data.

In this article of series tooling in DevOps, we will talk about the database to keep the time series data which is very important to collect metrics. Graphite is one such database to keep time-series data.

Why Graphite?

Well, you want you monitoring data to be stored somewhere so you can explore it and draw some fancy-looking graphs out of it. For this purpose, graphite is required to save and the data and it also provides explorer where you can see your graphs.

Your monitoring data is mostly time series data and that’s why we will be using graphite.

Tooling in DevOps: Installing Graphite for time-series data.

Installating Graphite

sudo apt-get install graphite-web graphite-carbon -y

We need Postgres for graphite to work you can install it by using the below command.

sudo apt-get install postgresql libpq-dev python-psycopg2 -y

Next, you need to create a user for your graphite server to use in Postgres. You can do this using the below commands.

sudo -u postgres psql
postgres=# CREATE USER graphite WITH PASSWORD 'password';
postgres=# CREATE DATABASE graphite WITH OWNER graphite;
postgres=# \q

Now let’s configure graphite for database collection

sudo nano /etc/graphite/local_settings.py

Fix this section of the file below

SECRET_KEY = 'your-secret-key'
TIME_ZONE = 'America/Los_Angeles'
USE_REMOTE_USER_AUTHENTICATION = True
DATABASES = {
    'default': {
        'NAME': 'graphite',
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': 'graphite',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',
        'PORT': ''
    }
}

After the settings, since you have seen this is a Django app you need to run migrations to make it run.

sudo graphite-manage migrate auth
sudo graphite-manage syncdb

It will ask you to create a superuser and password. Next, we have to configure carbon. It is graphite storage backend. Look at the below commands

sudo vi /etc/default/graphite-carbon

Put this is the file and restart carbon

CARBON_CACHE_ENABLED=true
sudo systemctl start carbon-cache

This will start your graphite server. You can feed the data on port 2003 and Metrics explorer will be visible on the port. Run the below command to send some data to the backend.

echo "test.count 4 `date +%s`" | nc -q0 127.0.0.1 2003

After this, you can see the data in metics explorer.

This is very basic of graphite. In the next articles, we will see how we can use it with grafana and collectd.

With these two together we can have a central place for your all the monitoring needs.

This was an article on installing graphite and how to configure it. If you like the article please share and subscribe to support us.


Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

1 COMMENT
  • How to save your monitoring metrics in Prometheus vs Graphite. - Learn Steps
    Reply

    […] Graphite is a good option if you want to push the metrics from your application. Graphite exposes a port to which you can send the data and it will save it. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.