Friday, 20 June 2025

Implementing Default Dashboards for Grafana

This is a continuation of my previous post, where I explained how to set up Grafana. In this post, we’ll configure Grafana’s metrics endpoint as a Prometheus scrape target. After that, we’ll go ahead and build the default Grafana dashboards.

 

1. Configure Prometheus to Scrape Grafana

Edit your prometheus.yml file to add a new scrape job for Grafana:

 

prometheus.yml 

global:
  scrape_interval: 15s
  evaluation_interval: 15s

rule_files:
  - "rules_with_labels.yaml"

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
  - job_name: 'node_exporter'
    static_configs:
      - targets: ['localhost:9100']
  - job_name: 'grafana'
    static_configs:
      - targets: ['localhost:3000']

Start Prometheus server.

prometheus --config.file=./prometheus.yml

Verify Metrics Are Scraped

Visit Prometheus UI (http://localhost:9090) and try searching for any of the following Grafana metrics:

 

Common Grafana Metrics:

·      grafana_http_request_duration_seconds_count

·      grafana_http_request_duration_seconds_sum

·      grafana_access_evaluation_count

·      grafana_access_evaluation_duration_sum

·      grafana_alerting_active_alerts


 

2. Implementing Default Dashboards in Grafana

Grafana provides some default dashboards for the data source we’ll be using. Let’s configure Prometheus as the data source and explore these default dashboards.

 

Open this URL in your browser:

http://localhost:3000

 

You will be navigated to the grafana login page.

 


Login to Grafana

·      Username: admin

·      Password: admin

 

You'll be asked to set a new password after first login.

Upon successful login to Grafana, you will be taken to landing page.

 


Click on Connections available at left navigation bar.

 


Click on Data sources  link on let navigation bar.

 


Click on ‘Add data source’ button to add new datasource.

 


Add your prometheus instance details

 


 a


 

 

Click the ‘Save & Test’ button. If the connection is successful, a success message will appear, as shown above.

 

You’ll then see that the Prometheus data source has been added to your list of data sources.

 


Configure default dashboards

Click on Prometheus data source from data sources listing page.

 

Go to Dashboards tab. 


 

When Grafana is set up with Prometheus as a data source, it typically comes with three default dashboards, you can see the same in above image.

 

·      Prometheus Stats: This dashboard gives insights into Prometheus's internal metrics, how it's performing and functioning internally.

 

·      Prometheus 2.0 Stats: A more in-depth, version-specific dashboard for Prometheus 2.x internals, offering refined metrics and new data points introduced in Prometheus 2.x.

 

·      Grafana Metrics: This dashboard is for monitoring Grafana itself, using metrics exposed by Grafana’s internal Prometheus endpoint (if enabled).

 

Just click on the Import buttons against each dashboard to import them.

 

Navigate to the Dashboards panel, you can see all the three dashboards are listed here.


 

Click on ‘Grafana metrics’ dashboard to visualize the Grafana metrics captured in Prometheus database.


 

To modify the configuration of a panel in Grafana, hover over the panel and click on the three vertical dots () located in the top-right corner of the panel. From the dropdown menu that appears, select "Edit". 

 


This will open the Panel Editor, where you can customize various aspects of the panel, such as:

 

·      The query used to fetch data (e.g., PromQL for Prometheus)

·      The visualization type (graph, gauge, table, etc.)

·      The axes, thresholds, and display options

·      Panel title, description, and other settings

 

The Panel Editor provides a flexible interface to tweak the panel's data and appearance according to your specific monitoring needs.

 


In the Metrics browser section, you can see a PromQL Query like below.

sum by (status_code) (irate(grafana_http_request_duration_seconds_count[5m]))

 

You can execute the same query in Prometheus UI and get the results.

 


Does Grafana have its own query language like PromQL?

No, Grafana does not have its own query language like PromQL. Grafana is a powerful visualization and dashboarding tool that supports multiple data sources, each of which uses its own query language.

 

Here's how it works:

·      When you add a Prometheus data source, you write PromQL queries inside Grafana.

·      If you add Loki (for logs), you use LogQL.

 

·      If you use Elasticsearch, you write Lucene/DSL queries.

 

·      If you use MySQL/Postgresql. you use standard SQL.

 

·      For InfluxDB, you use InfluxQL or Flux.

 


 

Previous                                                    Next                                                    Home

No comments:

Post a Comment