Install InfluxDB2 Server and Data Source
Video Lecture
Description
We are going to install InfluxDB v2, the InfluxDB data source, a Telegraf agent and then collect some data.
InfluxDB is a database useful for storing large amounts of time stamped data.
Telegraf is an agent that supports plugins and it will save it's data into InfluxDB.
Note : The configuration of Grafana, InfluxDB and Telegraf is commonly known on the internet as the TIG stack.
Next,
The first part is to Install the InfluxDB2 service and create the data source in Grafana.
The installation commands for your OS are at https://portal.influxdata.com/downloads/
For these instructions, I have chosen InfluxDB v2.1.1
version and the Ubuntu & Debian
platform.
wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null
export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null
sudo apt-get update && sudo apt-get install influxdb2
The InfluxDB service is usually not started by default. We can start it and check its status.
sudo service influxdb start
sudo service influxdb status
We can now visit the InfluxDB UI at the address http://[Your Domain name or IP address]:8086
If your InfluxDB web address is accessible from the internet, then I recommend setting some firewall rules using the methods available to you.
When you first access the InfluxDB UI, it will require you to create a user and password to log in.
After logging in, we need to create a user, password, organization and bucket name.
I have named my organization sbcode
and my bucket telegraf
. You username and password for accessing InfluxDB can also be anything you want.
Also, you can name your organization anything you like, just remember it though, since you will need it when creating the data source in the Grafana UI.
Using the InfluxDB UI, make sure you have a bucket named telegraf
, a scraper named anything you like, and a access token to allow the InfluxDB data source to connect with.
Note
Ideally you should create a specific user with read only permissions that you can use to connect to InfluxDB from Grafana, and use the token for that user instead.
Firewall
If your server is on the public internet, and you haven't configured a dedicated firewall, it may be accessible via the address http://[your domain or ip]:8086/
You can restrict access to port 8086 using iptables.
iptables -A INPUT -p tcp -s <domain name or ip of allowed host> --dport 8086 -j ACCEPT
iptables -A INPUT -p tcp --dport 8086 -j DROP
iptables -L
Useful Links
InfluxDB Open Source (OSS) Metrics Template
Grafana 9 and Ubuntu 22.04 Notes
There are no considerable differences to be aware of as shown and discussed in the video.
InfluxDB 2.4.0
I have tested InfluxDB 2.4.0. There are some differences in the presentation of InfluxDB 2.4.0 UI but nothing significant.