We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Monitor Linux System with Grafana and Telegraf

Learn how to – Monitor Linux System with Grafana and Telegraf.

In this article, we’re going to look at how to Monitor a Linux System with Grafana and Telegraf. Telegraf metrics will be stored on InfluxDB, then we can visualize them on Grafana using a system dashboard.

A prerequisite for this setup is a Linux system and InfluxDB server. You can check our previous guides on:

For Telegraf installation checkout the guides below:

Installing Telegraf on CentOS / RHEL

Influxdata provides the repository for installing telegraf on CentOS / RHEL Linux system. To add the repository to your system, use the commands:

sudo tee /etc/yum.repos.d/influxdb.repo<<EOF
[influxdb]
name = InfluxDB Repository - RHEL $releasever
baseurl = https://repos.influxdata.com/rhel/$releasever/$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF

Update cache to confirm that the repository is working fine:

sudo yum makecache fast

Then install telegraf:

sudo yum -y install telegraf

Installing Telegraf on Ubuntu / Debian

For a Debian and  Ubuntu , install telegraf using:

Configure telegraf on Linux

A basic telegraf configuration with InfluxDB output and basic inputs to collect system metrics can look like below:

[global_tags]

# Configuration for telegraf agent
[agent]
    interval = "10s"
    debug = false
    hostname = "server-hostname"
    round_interval = true
    flush_interval = "10s"
    flush_jitter = "0s"
    collection_jitter = "0s"
    metric_batch_size = 1000
    metric_buffer_limit = 10000
    quiet = false
    logfile = ""
    omit_hostname = false

###############################################################################
#                                  OUTPUTS                                    #
###############################################################################

[[outputs.influxdb]]
    urls = ["http://influxdb-ip:8086"]
    database = "database-name"
    timeout = "0s"
    username = "auth-username"
    password = "auth-password"
    retention_policy = ""

###############################################################################
#                                  INPUTS                                     #
###############################################################################

[[inputs.cpu]]
    percpu = true
    totalcpu = true
    collect_cpu_time = false
    report_active = false
[[inputs.disk]]
    ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.io]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.system]]
[[inputs.swap]]
[[inputs.netstat]]
[[inputs.processes]]
[[inputs.kernel]]

For a comprehensive list of inputs supported by Telegraf, visit Telegraf inputs Github page.

Replace:

  • server-hostname with your valid hostname.
  • http://influxdb-ip:8086 with your valid InfluxDB URL, IP address, and port.
  • database-name with InfluxDB database nae for this host
  • auth-username with InfluxDB http authentication username.
  • auth-password with InfluxDB http authentication password.

Once all changes have been made, you can then start and enable the telegraf service:

sudo systemctl start telegraf && sudo systemctl enable telegraf

This will automatically create the InfluxDB database if it doesn’t exist.

Add an InfluxDB data source to Grafana

You need to have Grafana installed, you can follow:

Before you can add a dashboard to Grafana for Telegraf system metrics, you need to first import the data source. Login to your Grafana and go to Configuration > Data Sources > Add data source 

Provide the following details:

  • Name – Any valid name
  • Type: InfluxDB
  • HTTP URL: InfluxDB URL address e.g http://localhost:8086 for local db server

Under InfluxDB Details, provide:

  • Database name as defined on telegraf configuration file
  • HTTP authentication username and password as configured on telegraf.

Importing Grafana Dashboard

Once the data source has been added, the next thing is to import the dashboard. I customized one of the dashboards initially created by a user on the community and uploaded it.

Download the dashboard from https://grafana.com/dashboards/5955, it is in JSON format. The head over to Grafana > Import

Select Upload .json and upload downloaded file. Alternatively, you can use Grafana dashboard URL or ID – 5955. Under Options section, give it a unique name and select data source added earlier from the drop-down menu and click the import button.

You should see Metrics being visualized immediately.

Also, see:

Cart

Your Cart is Empty

Back To Shop