More projects, more servers, more headaches identifying misbehaving apps. In this series, I will be documenting my process on how to setup centralized monitoring with 1 server collecting metrics on the rest of my network. Right now I am using Nagios for alerts, which does its job well but doesn’t provide good historical data.

Grafana makes really slick graphs of data and is a great platform for viewing lots of system metrics. InfluxDB is a database designed for logging time based data, and Telegraf feeds InfluxDB your system metrics.

To get started, I have a low power Ubuntu LTS machine that I will be using to host Grafana and the InfluxDB database. I have already configured SSH and iptables for security.

Step 1: Install Grafana and dependencies

Add the Grafana and InfluxDB Repos:

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
echo " jessie main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install grafana influxdb

Now we need to modify the Grafana config.

I recommend using another database engine instead of the built in sqlite3 database. I chose to use MySQL. 

mysql -u root -p
CREATE USER 'grafana'@'localhost' IDENTIFIED BY 'pass';  
GRANT ALL PRIVILEGES ON `grafana`. * TO 'grafana'@'localhost';

Open the /etc/grafana/grafana.ini file. You will want to change the database lines to these (replacing credentials):

# Either "mysql", "postgres" or "sqlite3", it's your choice
type = mysql
host =
name = grafana
user = grafana
# If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;"""
password = grafana

Later down you may want to disable user registration

allow_sign_up = true
sudo systemctl start grafana
sudo systemctl start influxdb

Now is also a good time to secure our InfluxDB server.


CREATE USER "myusernamehere" WITH PASSWORD 'mysecurepasswordhere' WITH ALL PRIVILEGES

Open the /etc/influxdb/influxdb.conf file, and inside the [http] section, set auth to true.

  # Determines whether HTTP endpoint is enabled.
  # enabled = true

  # The bind address used by the HTTP service.
  # bind-address = ":8086"

  # Determines whether user authentication is enabled over HTTP/HTTPS.
  auth-enabled = true
sudo systemctl restart influxdb
sudo systemctl enable influxdb
sudo systemctl enable grafana-server</pre>

InfluxDB and Grafana are now running! Login at http://localhost:3000 with admin / admin and change your password! Up next I will talk about how to configure these services to handle incoming Telegraf data.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.


1 2 3 4
February 28th, 2018

Concluding the February Challenge

Writing every day for the month of February has been an experience, and has changed my perspective on writing tremendously. […]

February 27th, 2018


Cloudflare stats are very useful, but they expire and can’t be tracked over a long period of time. That’s why […]

February 26th, 2018

Nightly Database Backups to Google Drive

If you have a Google Apps account (a business account with more than 5 users or one provided by your […]

February 25th, 2018

Sublime Text

Sublime Text is a really powerful text editor and includes tons of functionality relevant to programming. I will dive into […]

February 24th, 2018

Great Resources for Student Developers

Being enrolled in a university comes with its pros and cons (a topic itself worthy of many other blog posts), […]

February 23rd, 2018

What is MVC?

MVC is a term thrown around lots of software development projects. Laravel, Zend, CodeIgniter, Ruby on Rails, Django, iOS, and […]

February 22nd, 2018

Getting Started With Phalcon PHP

To get started with Phalcon, I already have my server stack setup with Ubuntu 16.04, Percona MySQL, Nginx, and PHP […]

February 21st, 2018

What is Phalcon?

Phalcon is a modern PHP framework with the typical feature set you’d expect. Database ORM, error handling, MVC architecture, and […]

February 20th, 2018

Setting Up a PHP Development Environment

If you do PHP development, moving to a PHP IDE is extremely beneficial especially when debugging. PHPStorm is a great […]