System monitoring with Grafana (InfluxDB, CollectD)

Last Release: 10/30/2020    

System monitoring with Grafana (InfluxDB, CollectD)


System monitoring with Grafana allows you to query, visualize, alert on and understand your metrics. We live in a world of data, big data. Tracking everything in logs or monitoring tools is somewhat tiring. Especially if you need constant input. Grafana has some disadvantages when compared with Kibana (for instance full-text data search), or it’s maybe better to say that they have a different purposes. Grafana is great with metrics analysis, compared with Kibana which is more for exploring logged data. All in all, it’s an eye opener. Pleasing esthetics, ease of use, you’ll hardly want to go back to a rusty old terminal.. on the other hand some habits die hard..

System monitoring with grafana Log in

As mentioned, grafana is here just for esthetics, a data representation tool. We need couple more things, like a collector (that gathers all the data points from a system/service) and a storage service compatible with grafana (a data source). As for the collectors, there are many options:

  • statsd
  • Telegraf
  • collectd
  • zabbix
  • NetData
  • Munin

Officially supported datasources for grafana:

  • Graphite
  • Elasticsearch
  • CloudWatch
  • InfluxDB
  • OpenTSDB
  • Prometheus
  • MySQL
  • Postgres
  • Microsoft SQL Server (MSSQL)

Here, we’ll rely on collectd & InfluxDB. The thing we’ll make, in rough sketch:

System monitoring with Grafana Structure

InfluxDB Setup

We’ll get things ready before we turn to collectd. Install InfluxDB:


curl -sL | sudo apt-key add -
source /etc/lsb-release
echo "deb${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

Red Hat/CentOS

# cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
name = InfluxDB Repository - RHEL \$releasever
baseurl =\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey =

# sudo yum install influxdb
# sudo service influxdb start or systemctl start influxdb (if you're using systemd)

Steps are also available on Influx site. After installation edit /etc/influxdb/influxdb.conf , set:


enabled = true
bind-address = ":8096"
database = "collectd"
typesdb = "/usr/share/collectd/types.db"

We defined input/output points and we’re ready for the collectd. Before you continue, start/restart influx:

# service influxdb start [or restart]

Collectd Setup

InfluxDB is not waiting for our data, continue with Collectd:

Red Hat/CentOS

Through EPEL repository:

# yum install epel-release
# yum install collectd


# sudo apt-get install collectd


Collectd generates/gathers the stats (System/Services), but we need to put it somewhere for grafana to use it. We need to define which data to collect, and where to put it. Somewhere in /etc is collectd config. Probably /etc/collectd/collectd.conf :

Hostname "YourHostNameHere"
FQDNLookup true
BaseDir "/var/lib/collectd"
PIDFile "/var/run/"
PluginDir "/usr/lib64/collectd"
TypesDB "/usr/share/collectd/types.db"

With basic info set, we now need to enable some plugins. For example: syslog, disk, interface, disk, load, memory, network are some most frequently used, so uncomment them. Aside from network, default values are fine. For network, the plugin will send data to some collector (InfluxDB in this case), so we’ll need to point it towards our InfluxDB server:

<Plugin network>
Server "" "8096"

Don’t forget to start/restart the service:

# service collectd start [or restart]

Grafana Setup

System monitoring with Grafana is great, even with all this “hassle”, I’m still optimistic. For any additional help, if needed, check grafana documentation.

Grafana Ubuntu [Debian)

Add the following line to your /etc/apt/sources.list file.

# deb stretch main

Then add the Package Cloud key. This allows you to install signed packages.

# curl | sudo apt-key add -

Update your Apt repositories and install Grafana

# sudo apt-get update
# sudo apt-get install grafana

Grafana CentOS [RedHat]

Directly, find a path/file on grafana website:

$ sudo yum install

or through YUM repository. Add the following to a new file at /etc/yum.repos.d/grafana.repo


Then install Grafana via the yum command.

$ sudo yum install grafana


Grafana is listening by default on the port 3000. Check your firewall setup if needed. Default config file is somewhere in /etc/grafana* , most likely on /etc/grafana/grafana.ini . There are a number of options to play with, so look around. Something useful that comes into mind is setting a nginx pass thing (a Reverse Proxy), so your grafana shows on a neat path like: <domain>/grafana/ .

root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
#root_url = http://localhost:3000
#root_url = %(protocol)s://%(domain)s:/grafana/

and within Nginx config:

location /grafana/ {
  proxy_pass http://<ip/domain>:3000/;
  rewrite ^/grafana/(.*) /$1 break;
  proxy_set_header Host $host;

When you’re done with the adjustments, go login to grafana (<ip/domain>:3000). you can create your own dashboard, or you can download it from grafana labs. For example, here we’ll use Host Overview. When you login to your grafana, add the datasource/InfluxDB we’ve already configure above:

  • Type: InfluxDB
  • URL: http://localhost:8086
  • Database: collectd

System monitoring with grafana DataSource

Import the dashboard we mentioned earlier (Host Overview), and with that you should immediately see what collectd gathered in InfluxDB:

System monitoring with Grafana Stats

Three types of Grafana plugins :

  1. Panel plugins – These allow new data visualization to be added to Grafana.
  2. Data Source – Grafana Data Source plugins.
  3. App – Bundles of panels, data source, dashboard with new UI.

To install, Grafan provides a cmd tool grafana-cli:

# grafana-cli

Get a list of all available plugins in the repository:

# grafana-cli plugins list-remote

To install:

# grafana-cli plugins install <plugin>

Restart grafana after you finish installing plugin(s):

# service restart grafana-server

To list installed plugins on your system:

# grafana-cli plugins ls

To remove plugin:

# grafana-cli plugins remove <plugin>

Grafana SSL setup

To setup SSL (Let’s encrypt in this case) you should add SSL keys in your /etc/grafana/grafana.ini config file. Grafana probably doesn’t have enough permissions to access those files directly, and a quick solution is to simply copy those keys/files to some custom folder within grafana’s reach (alter permissions):

protocol = https
cert_file = /etc/grafana/ssl/fullchain.pem
cert_key = /etc/grafana/ssl/privkey.pem

Restart grafana-server.

Grafana – Restart Admin Password

In case you need this (as I did), you can try:

# grafana-cli admin reset-admin-password --homepath "/usr/share/grafana/" newpass

but that didn’t work for me at the time. The approach that did:

  1. stop grafana
  2. setup admin user and password in grafana.ini
  3. delete /var/lib/grafana/grafana.db
  4. restart
Note: This did the trick, but all previous dashboard data is lost.


There is definitely a lot of things to cover here (CollectD and different DBs/Data sources, setup of different sources Grafana could use, etc.) . This was just a quick intro, so you could get a rough picture on how things work. We’ll try to keep things here fresh by updating some info as we dig up something interesting. Most likely there will be a lot of  new/related posts, so stay tunned.

Things to work on:

  • Secure your ports/access
  • Play around with Plugins
  • Monitor Nginx or some other service/log
  • Maintenance & Limits (InfluxDB/CollectD)
  • Vulnerability check: Grafana, InfluxDB, CollectD