A dashboard is a group of one or more panels structured and arranged into one or more rows. Grafana is one of the most awesome dashboards. Grafana Dashboard makes it easy to build the right queries, and personalize the display properties so that you can build a flawless dashboard for your requirement.
If you are looking to monitor your entire infrastructure or just your home, everybody helps by having a complete Grafana dashboard. In today’s tutorial, we are discussing completely how we can easily create a Grafana dashboard, what are the best practices, what the different panels are, about Dashboard UI, and how they can be used efficiently.
- Best practices for creating dashboards
- Dashboard UI
- Steps to create a Grafana dashboard using UI
- Steps to create a Grafana dashboard using API
Best practices for creating dashboards
This section will make you understand some best practices to follow when creating Grafana dashboards:
- At the time of new dashboard creation, ensure that it has a meaningful name.
- If you want to create a dashboard for the experiment then set the word TEST or TMP in the name.
- Also, include your name or initials in the dashboard name or as a tag so that people know who owns the dashboard.
- After performing all the testing tasks on temporary experiment dashboards, remove all of them.
- If you build multiple related dashboards, consider how to cross-reference them for easy navigation. For more information on this take a look at the best practices for managing dashboards.
- Grafana retrieves data from a data source. A basic understanding of data sources in general and your precise is necessary.
- Withdraw unnecessary dashboard stimulating to diminish the load on the network or backend. For instance, if your data changes every hour, then you don’t need to set the dashboard refresh rate to 30 seconds.
- Perform the left and right Y-axes when displaying time series with multiple units or ranges.
- Reuse your dashboards and drive consistency by utilizing templates and variables.
- Add documentation to dashboards and panels.
- To add documentation to a dashboard, add a Text panel visualization to the dashboard. Record things like the purpose of the dashboard, useful resource links, and any instructions users might need to interact with the dashboard. Check out this Wikimedia example.
- To add documentation to a panel, edit the panel settings and add a description. Any text you add will appear if you hover your cursor over the small ‘i’ in the top left corner of the panel.
- Beware of stacking graph data. The visualizations can be misleading, and hide related data. We advise turning it off in most cases.
Also Check: Best Open Source Dashboard Monitoring Tools
Dashboard UI
- Zoom out time range
- Time picker dropdown: You can access relative time range options, auto-refresh options, and set custom absolute time ranges.
- Manual refresh button: Will let all panels refresh (fetch new data).
- Dashboard panel: Tap the panel title to edit panels.
- Graph legend: You can change series colors, y-axis, and series visibility directly from the legend.
Steps to create a Grafana dashboard using UI
- Hover the ‘Plus’ icon located on the left menu with your cursor (it should be the first icon)
- At that point, a dropdown will open. Click on the ‘dashboard’ option.
- Create a dashboard option in Grafana
- A new dashboard will automatically be created with a first panel.
In Grafana v6.0+, the query and the visualization panels are departed. It implies that you can easily write your query, and decide later which visualization you want to use for your dashboard.
- Complete MySQL dashboard with Grafana & Prometheus | MySQL Database Monitoring using Grafana and Prometheus
- MongoDB Monitoring with Grafana & Prometheus | Mongodb Prometheus Grafana Dashboard
- Windows Server Monitoring using Prometheus and WMI Exporter | How to Install WMI Exporter in Windows?
This is particularly handy because you don’t have to reset your panel every time when you want to change the visualization types.
- First, click on ‘Add Query’ and make sure that your data source is correctly bound to Grafana.
- Write your query and refactor it until you’re happy with the final result. By default, Grafana sets new panels to “Graph” types.
- Choose the visualization that fits your query the best. You have to choose between ten different visualizations (or more if you have plugins installed!)
- Tweak your dashboard with display options until you’re satisfied with the visual of your panel.
- Add more panels, and build a complete dashboard for your needs! Here is an example of what a dashboard could be with a little bit of work. Here is an example with a more futuristic theme on disk monitoring.
Steps to create a Grafana dashboard using API
Most of the API requests are authenticated within Grafana. To call the Grafana API to create a dashboard, you will have to get a token. If you don’t own the Grafana example, you have to ask your administrator for a token.
- Hover the ‘Configuration’ icon in the left menu and click on the “API Keys” option.
- Click on “Add API Key”. Enter a key name and at least an “Editor” role to the key.
- Click on “Add”
- A popup page will open and show you the token you will be using in the future. It is very important that you copy it immediately. You won’t be able to see it after closing the window.
- Now that you have your API key, you need to make a call to the /api/dashboards/db endpoint using the token in the authorization header of your HTTP request.
For this example, I will be using Postman.
- Create a new POST request in Postman, and type http://localhost:3000/api/dashboards/db as the target URL.
- In the authorization panel, select the ‘Bearer token’ type and paste the token you got from the UI.
- In the body of your request, select “Raw” then “JSON (application/json)”. Paste the following JSON to create your dashboard.
{ "dashboard": { "id": null, "uid": null, "title": "Production Overview", "tags": [ "templated" ], "timezone": "browser", "schemaVersion": 16, "version": 0 }, "folderId": 0, "overwrite": false }
Here’s the description of every field in the request:
- dashboard.id: the dashboard ID, should be set to null on dashboard creation.
- dashboard.uid: the dashboard unique identifier, should be set to null on dashboard creation.
- title: the title of your dashboard.
- tags: dashboard can be assigned tags in order to retrieve them quicker in the future.
- timezone: the timezone for your dashboard, should be set to the browser on dashboard creation.
- schema version: constant value that should be 16.
- version: your dashboard version, should be set to zero as it is the first version of your dashboard.
- folderId: you can choose to set a folder id to your dashboard if you already have existing folders
- overwrite: you could update an existing dashboard, but it should be set to false in our case as we creating it.
- Click on “Send”. You choose to see the following success message.
{ "id": 3, "slug": "production-overview", "status": "success", "uid": "uX5vE8nZk", "url": "/d/uX5vE8nZk/production-overview", "version": 1 }
- Make sure that your dashboard was created in Grafana.
That’s it! You now have a complete idea of the two ways to create a Grafana dashboard in 2021.
If you have any comments on this content, or if you found that this guide has run out of date in the future, make sure to leave a comment below.