Skip to content

Install InfluxDB2 Server and Data Source

Video Lecture

Install InfluxDB Server and Data Source Install InfluxDB Server and Data Source

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 its 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/

Note

These instructions have been updated to install InfluxDB v2.7.1 version and the Ubuntu & Debian platform.

wget -q https://repos.influxdata.com/influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
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. Your 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 an 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

Grafana 10 and Ubuntu 22.04 Notes

There are no considerable differences to be aware of as shown and discussed in the video.

InfluxDB 2.7.1

After creating your initial grafana user and telegraf bucket, you will be presented with an API token named grafana's Token. Copy this string and save for later. You will need it for the Grafana InfluxDB data source configuration.

Then continue, and finally press the [Configure Later] option to enter the InfluxDB UI.

The UI layout, just like Grafana, changes all the time with every new version. All the same options are there, but just maybe in a different place under a different section heading.

Comments