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
After login either you can change the password or just skip the page.
Now we need to add data source first.
Click on the add data source and select your data source.
Here we are using Graphite as the data source, so let’s select the Graphite from the list.
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
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:
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
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.
There are 2 ways of creating queries:
- Select the value from the dropdown
- 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.
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:
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.