Grafana on Ubuntu Server 18.04 | InfluxDB / Telegraf

Recently, I setup Grafana at my workplace to allow more visibility on our network. In the past I have played with Grafana in my homelab but I didn’t understand how It could be useful for me at the time when I only had one server. Now that I have a handful of servers that can be a pain sometimes to monitor, I’ve decided to give Grafana another go.

For this installation, I will be using Ubuntu Server 18.04 in a Hyper V VM and will be setting up Grafana / InfluxDB for the backend. I will also be setting up Telegraf as my collector to collect the SNMP information from my Switches/Pfsense router.

Follow along with my journey of setting up Grafana to create some beautiful data. Just for the heads up, I found a lot of information on how to set this up by reading other blogs. I will post the blog in this guide to help any readers out when following along.

First, I opened Hyper V and configured myself a brand new Ubuntu 18.04 server. I ended up giving the box 8Gb of RAM for now and 300Gb of diskspace to store logs/the databases.

Now that I have the new VM in the Hyper V pool, I started up the VM and connected to the console of the server.

I went through just the basic setup of Ubuntu but make sure you set up a static IP address so that DHCP doesn’t change IPs on you when you start forwarding data to the server.

Once the Installation was complete, I rebooted the server and connected to the server using SSH.

Once I was SSH’d into the server, I then ran:
sudo nano /etc/apt/sources.list
and then added the following line to my source list
deb stretch main

After adding the source, I then ran an update / upgrade with the following command:
Sudo apt-get update && sudo apt-get upgrade -y

Once updates were installed, I then had to install Grafana, enable it to start on startup and start the service.
Sudo apt-get install grafana
Sudo systemctl enable grafana
Sudo systemctl start grafana
Sudo systemctl status grafana
  (To verify that Grafana is running)

Once Grafana is running, you should be able to visit it in your local PC’s web browser.
Default login credentials are admin/admin.

Once that you verified you can login, you need to setup influxdb with the following commands.
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


Next we have two more things to install and a couple of commands to run.
Sudo apt-update && sudo apt-get install telegraf
Sudo apt-get install influxdb
Sudo systemctl enable influxdb
influxd -config /etc/influxdb/influxdb.conf
echo $INFLUXDB_CONFIG_PATH /etc/influxdb/influxdb.conf
Next go into the config and make the following changes. (Use the search feature to find the line.)
Sudo Nano /etc/influxdb/influxdb.conf

reporting-disabled = true
store-enabled = true


# Whether to record statistics internally.
store-enabled = true
# The destination database for recorded statistics
store-database = “_internal”
# The interval at which to record statistics
store-interval = “20s”
### [http]
### Controls how the HTTP endpoints are configured. These are the primary
### mechanism for getting data into and out of InfluxDB.


# Determines whether HTTP endpoint is enabled.
enabled = true
# Determines whether the Flux query endpoint is enabled.
# flux-enabled = false
# The bind address used by the HTTP service.
bind-address = “:8086”
# Determines whether user authentication is enabled over HTTP/HTTPS.
auth-enabled = true
# The default realm sent back when issuing a basic auth challenge.
# realm = “InfluxDB”
# Determines whether HTTP request logging is enabled.
log-enabled = true


Once that is complete, start the influxdb service.
Sudo service influxdb start.

Next, we have to configure the database for us.
Restart the database.
Sudo service influxdb restart
Open Influx again and authenticate.
Auth username password

And create the database.
create database GRAFANA

At this point, we should be able to add the database into our Grafana config page like the photo above.

If you get this message when clicking “save and test” your database is configured correctly.

I wanted to add some data using SNMP stats from my network switch, so I ssh’d into the switch and edited the SNMP config. Then, you have to go into telegraf.conf and tell telegraf to pull data from the switch with the following configuration added.

Sudo apt install snmp snmp-mibs-downloader
Sudo nano /etc/telegraf/telegraf.conf
agents = [ "SWITCHIPHERE" ]
version = 2
community = "public"
interval = "60s"
timeout = "10s"
retries = 3
name = "hostname"
oid = "RFC1213-MIB::sysName.0"
is_tag = true
name = "uptime"
oid = "DISMAN-EXPRESSION-MIB::sysUpTimeInstance"
# IF-MIB::ifTable contains counters on input and output traffic as well as errors and discards.
name = "interface"
inherit_tags = [ "hostname" ]
oid = "IF-MIB::ifTable"
# Interface tag - used to identify interface in metrics database
name = "ifDescr"
oid = "IF-MIB::ifDescr"
is_tag = true
# IF-MIB::ifXTable contains newer High Capacity (HC) counters that do not overflow as fast for a few of the ifTable counters
name = "interface"
inherit_tags = [ "hostname" ]
oid = "IF-MIB::ifXTable"
# Interface tag - used to identify interface in metrics database
name = "ifDescr"
oid = "IF-MIB::ifDescr"
is_tag = true
# EtherLike-MIB::dot3StatsTable contains detailed ethernet-level information about what kind of errors have been logged on an interface (such as FCS error, frame too long, etc)
name = "interface"
inherit_tags = [ "hostname" ]
oid = "EtherLike-MIB::dot3StatsTable"
# Interface tag - used to identify interface in metrics database
name = "ifDescr"
oid = "IF-MIB::ifDescr"
is_tag = true


Once that is complete, start and enable telegraf.
Sudo systemctl enable telgraf
Sudo systemctl start telegraf
Sudo systemctl status telegraf
If telegraf fails to start when you check it with systemctl status, you messed up telegraf.conf somehow. Go back and verify that the config is correct.

If telegraf is working properly, you are now able to start editing a new dashboard!

This is my dashboard so far for my Cisco 2960x switch stack. I plan to continue to add and grow onto my Grafana config for more information on my homelab. I know that it can be a pain in the ass to setup, but all of the beautiful data when you finally get Grafana to work is worth all of your hard work!