Explore InfluxDB: Part 1
By Fahad Ahammed
- 3 minutes read - 579 wordsI have been trying to manage time to explore InfluxDB for observability. This article is one of many about InfluxDB and Telegraf. I will cover basic installation here.
To install InfluxDB I have used docker-compose for now. In future, maybe I will choose and share some other form of installation.
docker-compose.yaml
Normally, image: 'influxdb:latest'
is denoting to latest version of influx, influxdb2+.
Now we need telegraf on our servers from where we will get the metrics.
I have a ubuntu server at which some application is running.
- Docker
- Nginx
- Redis
So, I wanted to monitor those as well as host information.
First, I have installed telegraf.
It will enable a systemd service and make it running when installation complete. After installation, stop the service.
make a backup of the configuration file
Create a new configuration with passing some parameters
Here we are generating sample config and writing the config to the default config file of telgraf. I have used some plugins to send the metrics to influxdb.
- cpu
- mem
- system
- net
- swap
- processes
- disk
- diskio
- docker
- nginx
- redis
After that, need to pass token to allow this telegraf for sending metrics to the influxdb and also the influxdb endpoint.
Change the url of the influxdb and also the token collected from Influxdb Data>API Tokens. Also need to change the organization and bucket if you want.
Restart the telegraf.
As soon as telegraf starts sending the data, You should be able to get the already created/default dashboard for system where you will be able to get information about uptime, load, cpu, memory, disk etc information. But what I also needed is nginx dashboard, redis and Docker dashboard.
Community plugins can be found here – https://github.com/influxdata/community-templates
- Redis: https://raw.githubusercontent.com/influxdata/community-templates/master/redis/redis.yml
- Nginx: https://raw.githubusercontent.com/influxdata/community-templates/master/nginx_mysql/nginx_mysql.yml
- Docker: https://raw.githubusercontent.com/influxdata/community-templates/master/docker/docker.yml
To Apply the templates you can use –
Or
You can just import through the dashboard itself. Settings>Template>Lookup Template with the url in the input field.
Redis was kind of readymade. But Nginx and Docker needed to change some parameters/variables.
For nginx, there are two variables created and can be changed.
- mysqlBucket
- nginxBucket
I did set only for nginx, as I did not need MySQL for now. I changed the bucket to my bucket at which telegraf is sending the metrics.
For Docker, there were no variables in the template file but default bucket set to docker. But I was not sending the metrics to the bucket named “docker”. So, I needed to edit all the graphs of the dashoard and replace the bucket “docker” with v.dockerBucket
. Created a variable named dockerBucket setting value to the bucket where telegraf already sending the metrics.
Also I needed to add telegraf user to the docker group for giving telegraf permission to read docker stat from docker daemon.
This is the solution of below error on telegraf service.
For nginx, I needed to set some config to get the status too. First, needed to check if nginx install has the required module or not.
If it doesn’t return anything then we need to install that module.
After having that, I have created a location block which will give nginx status in return.
This endpoint was giving me some statistics/metrics of nginx itself. I needed to set this url to telegraf and restart telegraf service.
Thus the required dashboards are ready. I might need some more later.
Final dashboard for one of my RaspberryPi 3B+ as of now:
In next part I will try to cover the alert and task. Thank you for reading.