I tried using Grafana Git Sync's Dashboard previews in pull requests

I tried using Grafana Git Sync's Dashboard previews in pull requests

2025.09.06

Introduction

The Grafana Git Sync feature I wrote about in my blog the other day includes a function called "Dashboard previews in pull requests."
Since there doesn't seem to be an official name for this feature, I'll refer to it as the pull request preview feature in this article.
This feature automatically attaches preview images of dashboard changes to GitHub pull requests, allowing you to check the changes before applying them to the dashboard in the main branch - it's a wonderful feature!

Since I unexpectedly struggled with the setup, I'll describe the setup procedure and my actual experience using it.

Setup

Several steps are needed to use the pull request preview feature.
The overall process is as follows:

  • Enable Git Sync
  • Install Grafana Image Renderer
  • Configure Webhook
    • Set up ngrok
    • Configure GitHub Webhook

Enabling Git Sync

This time we'll enable Git Sync using Docker.
I'll introduce the code details in the next section.

For information on how to enable Git Sync on a local instance, please refer to my previous blog post.
https://dev.classmethod.jp/articles/grafana-v12-git-sync/## Installing Grafana Image Renderer
Grafana Image Renderer is a plugin that automatically renders Grafana panels as PNG images.
It is used for sharing panel images or creating dashboard reports.
Although it appears in the Grafana plugins list, it cannot be enabled from there and needs to be installed separately.
For installation methods, please check the install section of the plugin.
https://grafana.com/grafana/plugins/grafana-image-renderer/?tab=installation#installation

This time, I wanted to prepare an environment together with Git Sync, so I built everything using Docker.
The directory structure is simple.

			
			├── config
│   └── grafana.ini
└── docker-compose.yml

		

In the docker-compose.yml file, we configure the settings needed for Git Sync and Image Renderer.

			
			services:
  renderer:
    image: grafana/grafana-image-renderer:latest
    container_name: grafana-image-renderer
    restart: unless-stopped
    ports:
      - "8081:8081"
    networks:
      - grafana

  grafana:
    image: grafana/grafana:12.1.0-ubuntu
    container_name: grafana
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      # Git Sync feature toggles
      - GF_FEATURE_TOGGLES_PROVISIONING=true
      - GF_FEATURE_TOGGLES_KUBERNETESDASHBOARDS=true
      # Image Renderer configuration
      - GF_RENDERING_SERVER_URL=http://renderer:8081/render
      - GF_RENDERING_CALLBACK_URL=http://grafana:3000/
    volumes:
      - grafana-storage:/var/lib/grafana
      - grafana-logs:/var/log/grafana
      - ./config/grafana.ini:/etc/grafana/grafana.ini
    depends_on:
      - renderer
    networks:
      - grafana

volumes:
  grafana-storage:
    driver: local
  grafana-logs:
    driver: local

networks:
  grafana:
    driver: bridge

		

The grafana.ini file will be needed later when setting up ngrock.

			
			# ngrok URL
root_url = https://xxxxxxxxxxxx.ngrok-free.app
```## Webhook Configuration
The pull request preview feature hooks into pull requests to generate images using the Image Renderer plugin.
When generating images from GitHub's Webhook with the Image Renderer plugin, the Webhook needs to access the local Grafana instance, but it cannot access it directly.
Therefore, to access the local Grafana instance, we will create an endpoint that connects the Webhook and the local Grafana instance.
We will use [ngrok](https://ngrok.com/), which is introduced in the official documentation, as the endpoint.

By using ngrok, you can generate a URL to directly receive Webhooks on your locally hosted Grafana instance.
### ngrok Account Registration
https://ngrok.com/
Register an account from signup.### Get auth token
Select Your Authtoken and copy the displayed token.
![CleanShot 2025-08-11 at 16.59.33@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/5QRPqsY1oyvJ.png)
Set the authentication token with the following command.

		

ngrok config add-authtoken $YOUR_AUTHTOKEN

			
			
Use ngrok to make port 3000 accessible from the public.
Running the following command will issue a URL corresponding to http://localhost:3000.
Copy the issued URL as we will use it later.

		

$ ngrok http 3000

🤫 Decouple policy and sensitive data with vaults: https://ngrok.com/r/secrets
Session Status online
Account example@example.com (Plan: Free)
Version 3.26.0
Region Japan (jp)
Latency 66ms
Web Interface http://127.0.0.1:4040
Forwarding https://xxxxxxxxxxxxx.ngrok-free.app -> http://localhost:3000

Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00

			
			Let's access the issued URL.
![CleanShot 2025-08-11 at 17.04.57@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/ikdYyTJr55A8.png)
Click "Visit Site" to be forwarded to localhost:3000 and transition to Grafana.
![CleanShot 2025-08-12 at 09.45.49@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/YQBsu385Myd1.png)
Now Grafana is accessible from the internet.
Let's add the ngrok URL we copied earlier to the root_url in grafana.ini.

		

ngrok URL

root_url = https://xxxxxxxxxxxx.ngrok-free.app

			
			root_url is the URL used when accessing Grafana from a web browser.### GitHub Webhooks Configuration
Since we issued a URL with ngrok, let's set the URL in GitHub Webhooks.

Access the GitHub repository that you will use with the GitSync feature.
Open the target repository on GitHub and select Settings > Webhooks.
![CleanShot 2025-08-12 at 09.49.51@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/Cl69jp7uGHXZ.png)
Create a Webhook with the following settings.
For Payload URL, enter `<URL obtained from ngrok>`/api/webhooks/git.
![CleanShot 2025-09-06 at 23.16.54@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/8We6chcuF0Dm.png)
Webhook creation is complete.
![CleanShot 2025-09-06 at 20.55.03@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/pK2hcLvVCjac.png)
## Enable Pull Request Previews
Navigate to Grafana > Administration > Provisioning
Check the `Enable dashboard previews in pull requests` option and save.
![CleanShot 2025-08-12 at 09.59.39@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/dQwHvPq23TZw.png)
First, create a Time series panel with test data and create the main branch.
![CleanShot 2025-08-12 at 10.01.21@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/dmnZiEBTSkie.png)
Next, change the visualization format to Bar chart and save the dashboard.
When saving, set it up so you can create a branch and submit a pull request.
![CleanShot 2025-08-12 at 10.03.04@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/cDPZD20VJavZ.png)
Now that saving is complete, click Open pull request in GitHub to submit a pull request.
![CleanShot 2025-08-12 at 10.04.10@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/2XV9DkOsoGL2.png)
When you check the pull request content, you can see Before and After dashboards displayed!
This is very convenient!
![CleanShot 2025-08-12 at 10.07.11@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/JZsybGrZvdiw.png)
## I Tried Various Things
I tried several things I was curious about with the pull request preview feature.### Minor modifications
I tried to see if changes can be detected when making small modifications.
This change involves adjusting the thickness of the line graph lines and making the graph background border transparent, but judging solely from this image is extremely difficult.
![CleanShot 2025-09-06 at 22.18.39@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/JJrkZ9xpW7Cf.png)
When managing dashboards in GitHub, determining edited sections from code is quite challenging, unlike typical code reviews.
Especially when making minor modifications, be sure to describe what was changed in the pull request comments.
Reviewers will find their work significantly streamlined by using comments along with preview images.
### Variables
I was curious about how panels requiring variables would appear, so I tried it out.
![CleanShot 2025-09-06 at 22.30.59@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/0y37VgnDRbWE.png)
As expected, it displayed with no values entered.
It seems best to input values beforehand if you want to check the display.
### Vertically long dashboards
I tested how images appear in pull requests when editing vertically long dashboards.
![CleanShot 2025-09-06 at 22.10.40@2x-min](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/QGdevOMtM9ns.png)
Vertically long dashboards are also fully converted to images.
![CleanShot 2025-09-06 at 22.11.46@2x](https://devio2024-2-media.developers.io/upload/5KaqdBkvl9MDCRX80FYmFh/2025-09-06/NcIRE8Y19Rwl.png)
## Summary
This time I tried out Git Sync's pull request preview feature.
The setup was more challenging than I expected.
I hope it becomes available in Grafana Cloud, which would eliminate the need to install the Image Renderer plugin and configure grok.
The feature itself feels very user-friendly. With GitHub integration, it becomes necessary to review dashboards before applying them when incorporating this into the development lifecycle.
Since it's difficult for humans to understand dashboard code, expressing it in image form significantly reduces the cognitive load during reviews.
		

Share this article

FacebookHatena blogX

Related articles