(Last Updated On: March 2, 2019)

InfluxDB is an Open Source Time Series Database Platform for storing  Time Series Data, these are metrics & Events collected from different devices. It is a product of InfluxData and part of TICK Stack – which comprises:

T – Telegraf; This is an agent written in Go for collecting performance metrics from the system it’s running on and the services running on that system. The collected metrics are output to InfluxDB or other supported data stores.
IInfluxDB
CChronograf; A web application written in Go and React.js that provides the tools to visualize your monitoring data and easily create alerting and automation rules.
KKapacitor A data processing engine.  It can process both stream and batch data from InfluxDB

In my monitoring series guides, I concentrated on the use of:

  • Telegraf for collecting metrics from systems
  • InfluxDB as Datastore
  • Grafana for metrics visualization

InfluxDB installation for CentOS is available –> Install Grafana and InfluxDB on CentOS 7

Install InfluxDB on Ubuntu 18.04

Installation of InfluxDB on Ubuntu 18.04 is done from Influxdata repository. Once the repo is added, the package can then be installed using an apt package manager. Add the InfluxData repository to the file  /etc/apt/sources.list.d/influxdb.list

echo "deb https://repos.influxdata.com/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

Import apt key:

sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -

Update apt index and install influxdb

sudo apt-get update
sudo apt-get install -y influxdb

Start and enable the service to start on boot up.

sudo systemctl enable --now influxdb
sudo systemctl is-enabled influxdb

Check service status:

$ systemctl status influxdb
● influxdb.service - InfluxDB is an open-source, distributed, time series database
Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-03-02 08:10:27 CET; 33s ago
Docs: https://docs.influxdata.com/influxdb/
Main PID: 25994 (influxd)
Tasks: 8 (limit: 2299)
CGroup: /system.slice/influxdb.service
└─25994 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.270808Z lvl=info msg="Starting precreation service" log_id=0DwJgBEl000 service
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.270818Z lvl=info msg="Starting snapshot service" log_id=0DwJgBEl000 service=sn
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.270826Z lvl=info msg="Starting continuous query service" log_id=0DwJgBEl000 se
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.270837Z lvl=info msg="Starting HTTP service" log_id=0DwJgBEl000 service=httpd
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.270842Z lvl=info msg="opened HTTP access log" log_id=0DwJgBEl000 service=httpd
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.270992Z lvl=info msg="Listening on HTTP" log_id=0DwJgBEl000 service=httpd addr
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.271015Z lvl=info msg="Starting retention policy enforcement service" log_id=0D
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.271632Z lvl=info msg="Listening for signals" log_id=0DwJgBEl000
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.272100Z lvl=info msg="Storing statistics" log_id=0DwJgBEl000 service=monitor d
Mar 02 08:10:28 ubuntu-2gb-nbg1-1 influxd[25994]: ts=2019-03-02T07:10:28.274056Z lvl=info msg="Sending usage statistics to usage.influxdata.com" log_id

Install InfluxDB on Debian 9

Add influxdata repository using the following command:

echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

Import repo gpg key for installing signed packages:

sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -

Update apt index and install influxdb package:

sudo apt-get update
sudo apt-get install -y influxdb

Start influxdb service:

sudo systemctl start influxdb
sudo systemctl enable influxdb

You can check the status to confirm if running using:

sudo systemctl status influxdb

Open influxdb service ports on the firewall

I use ufw firewall on all my Ubuntu 18.04 and Debian 9 servers. If ufw is not installed, install it using the command:

sudo apt-get install ufw

Then activate firewall service:

sudo ufw enable

By default, InfluxDB uses the following network ports:

  • TCP port 8086 is used for client-server communication over InfluxDB’s HTTP API
  • TCP port 8088 is used for the RPC service for backup and restore

We will open port 8086 since telegraf will push metrics using this port.

sudo ufw allow 8086/tcp

InfluxDB default configuration file is located under /etc/influxdb/influxdb.conf. Most sections are commented out, you can modify it to your liking and restart influxdb service after.

InfluxDB http Authentication

If you need http authentication, modify influxdb http section to contain the following.

$ sudo vim /etc/influxdb/influxdb.conf 
[http]
auth-enabled = true

Then create a user with an authentication password:

curl -XPOST "http://localhost:8086/query" --data-urlencode "q=CREATE USER \ username WITH PASSWORD 'strongpassword' WITH ALL PRIVILEGES"

Replace:

– username with your own username
– strongpassword with your own password (note that the password requires single quotes)

Now whenever you need to run any influxdb commands on the terminal, you need to specify username using -username and password using -password options.

influx -username 'username' -password 'password'

For curl, use -u to specify username and password separated by a colon.

curl -G http://localhost:8086/query -u username:password --data-urlencode "q=SHOW DATABASES"

By default, influxdb service is listening on all interfaces on port 8086.