Grafana dashboards – getting started!

Collection of metrics data is of limited use if you cannot analyse it. One of the ways to analyse data collected is by creating dashboards. Grafana is one of the best open-source dashboarding tools. It is fast, simple, extendable and supports many data sources.

In the blog entry we will do the following

  • Install Grafana
  • Configure Prometheus as a data source
  • Create a chart & a put it on a dashboard

Install Grafana

Grafana is available various Linux flavours. For this blog entry, we will be installing Grafana on Ubuntu.

sudo apt-get install -y apt-transport-https
sudo apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

sudo apt-get update
sudo apt-get install grafana

Once installed it can be started using the following command

systemctl start grafana-server
systemctl status grafana-server

The grafana server by default starts on port 3000.

All grafana settings can be easily be changed. These are available on /etc/grafana/grafana.ini. These can be edited

sudo vi /etc/grafana/grafana.ini

More on that in a later blog post.

Configure data source

We can now login to our grafana server via a browser url – http://<server-name>:3000

The default username/password is admin/admin.

Its time to add a data source.

Click on Add Data Source.

If you want to know how to get started with a Prometheus server. Please see this blog entry.

Click on Prometheus

Add the Prometheus server details and press Save and Test.

If grafana is able to connect to Prometheus server it will show the following

Its time to chart something!

Create a chart

For the purpose of this blog entry, we will chart the number of successful HTTP requests which have been processed by the Prometheus server when it is scraping Prometheus server metrics. The name of the metric is prometheus_http_requests_total.

Creating a chart is easy.Just follow the steps

Click on New Dashboard

Click on Add Query

Start typing the following – prometheus_http_requests_total you would see a list of metrics which are filtered as you type.

Your query should look like – prometheus_http_requests_total{code=”200″,handler=”/metrics”}

Once you press enter you would be able to see the following line chart

That is it. Grafana is running and is able to show data in a chart. Press the back button highlighted in the red box to see the dashboard.

This entry was just to get us started on Grafana. In future, posts we will see how we can use both Prometheus and Grafana to create/import pre-built open source dashboards, create alerts and send them across as emails or as notifications to Slack or MS Teams channels. I hope you find this entry useful. If you like it share it below!

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *