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.
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.
1 COMMENT
[…] 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. […]