Install InfluxDB 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, the InfluxDB data source, a Telegraf agent and then collect data from some SNMP devices.

InfluxDB is a database useful for storing large amounts of timestamped 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 InfluxDB service and create the data source in Grafana.

The install commands for your OS are at https://docs.influxdata.com/influxdb/v1.8/introduction/install/

I am using Ubuntu 20.04

Check the available InfluxDB version in your apt cache.

sudo apt-cache policy influxdb

It will be the last stable version of InfluxDB

I am going to use a later version 1.8 of InfluxDB, so I will update the apt cache first.

I add the required information to the repository

wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

then update and install

sudo apt update
sudo apt-cache policy influxdb
sudo apt install influxdb -y

then start the service check it's status is active and ensure it starts in case of reboot and

sudo systemctl start influxdb
sudo systemctl status influxdb
sudo systemctl enable influxdb

The InfluxDB will listen on port 8086, and if your server is on the internet, then depending on any existing firewall rules, anybody may be able to query the server using the url

http://[your domain name or ip]:8086/metrics

If you want to prevent direct internet access, then you can use iptables to only allow the port for localhost.

iptables -A INPUT -p tcp -s localhost --dport 8086 -j ACCEPT
iptables -A INPUT -p tcp --dport 8086 -j DROP

You have other options to secure your InfluxDB as well which are listed at https://docs.influxdata.com/influxdb/v1.8/administration/security/

Warning

iptables settings will be lost in case of system reboot. You will need to reapply them manually,

or

install iptables-persistent

sudo apt install iptables-persistent

This will save your settings into two files called,

/etc/iptables/rules.v4

/etc/iptables/rules.v6

Any changes you make to the iptables configuration won't be auto saved to these persistent files, so if you want to update these files with any changes, then use the commands,

iptables-save > /etc/iptables/rules.v4

iptables-save > /etc/iptables/rules.v6

Next, start the InfluxDB prompt, create a Telegraf database and create a specific read only user for Grafana.

influx
> create database telegraf
> show databases
> create user grafana with password 'password'
> grant READ on telegraf to grafana 
> show users
> show GRANTS for grafana
> quit

Note

It may take several seconds to initially connect to the InfluxDB before you get the prompt

Now continue to add the InfluxDB Data Source as shown in the video.