Let’s create your first Grafana dashboard

Table of contents
Reading Time: 4 minutes

In my previous blog, we discussed the setup of Grafana-Graphite for JMX monitoring.  Now we will create a first Grafana dashboard where we will create Grafana queries to visualize JMX metrics stored in Graphite.

As we know, Grafana UI runs on http://localhost:3000/ by default so let’s open the URL in the browser with the default username and password which is admin: admin

login

After login either you can change the password or just skip the page.

Now we need to add data source first.

datasource

Click on the add data source and select your data source.

select_data_source

Here we are using Graphite as the data source, so let’s select the Graphite from the list.

graphite

Here, we need to add the Graphite URL. As Graphite UI runs on http://localhost (80 port by default), so let’s add it and verify the working of the data source by clicking on the “Save & Test” button at the bottom.

So the data source has been added. Now let’s go to the Dashboard page to create the dashboard. Click on the dashboard at the left side icon -> Manage

dashboard_page

Here, we have 2 options to create the dashboard. Either we can import or create the new one. If you have any existing dashboard json then go for import else click on the Dashboard option to create the new one.

Let’s click on the Dashboard -> Graph, you will get the following page:

new_panel

Here, we can create multiple panels as per our requirement. I am going to create only one here, so let’s start adding metrics. For this, we need to edit this panel by clicking on Panel Title -> Edit

metrics

First, select the data source as Graphite from the drop down just below the Metrics tab.

You can see there are multiple tabs, you can explore each and every tab by clicking on it.

We can change the name of the panel from the General tab. We will use the Metrics tab to create the Grafana queries. There is an Alert tab from where we can set up alerts which we will see in my next blog.

So let’s start creating queries. Just go to the Metrics tab and start clicking on “select metric” option. You will see some values there.

metrics_queries

There are 2 ways of creating queries:

  1. Select the value from the dropdown
  2. Directly add the query in edit mode.

Select the value from the dropdown: 

As soon as you will click on one of the value, you will get the “select metric” option again at the right side. You will continuously get this option until you reach to a concrete value. Metrics are stored in nested structure in Graphite. So all these options are those nested values.

Directly add the query in edit mode:

There is an option at the right side of the query “Toggle Edit Mode”. If you already have a query just paste the query there and close that edit mode, you will find the data on Graph.

Query example:

alias(sumSeries(kafka_connect_03.local.kafka.connect.type_connect-metrics.client-id_connect-1.incoming-byte-rate), ‘connect_metric’)

query_edit_mode

After finalizing the query, you can perform some functions as well on those values. You can see, there is an option of Functions, just below the Series. There are a lot of functions available which you can explore. I am using 2 functions here: sumSeries and alias.

sumSeries: It adds metrics together and returns the sum at each data point.

alias: It creates an alias for the fully qualified metrics name which is a very long name. See the example below:

Without alias:

without_alias

With Alias:

alias

You can create multiple queries by clicking on “Add Query” button.

That’s It. Hope this blog will help you to create your first Grafana dashboard.

Stay tuned for the next blog to set up alerts in Grafana.

Reference:

http://docs.grafana.org/

 

 

Knoldus-blog-footer-image

 

Written by 

Rishi is a tech enthusiast with having around 10 years of experience who loves to solve complex problems with pure quality. He is a functional programmer and loves to learn new trending technologies. His leadership skill is well prooven and has delivered multiple distributed applications with high scalability and availability by keeping the Reactive principles in mind. He is well versed with Scala, Akka, Akka HTTP, Akka Streams, Java8, Reactive principles, Microservice architecture, Async programming, functional programming, distributed systems, AWS, docker.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading