Skip to content

feat: Add Grafana integration#3040

Open
mfuzailzubari wants to merge 28 commits intosuperplanehq:mainfrom
mfuzailzubari:feat/grafana-integration
Open

feat: Add Grafana integration#3040
mfuzailzubari wants to merge 28 commits intosuperplanehq:mainfrom
mfuzailzubari:feat/grafana-integration

Conversation

@mfuzailzubari
Copy link

Implements #1945

This PR implements the Grafana integration with:

  • Query Data Source action (Grafana Query API via POST /api/ds/query)

Authorization:

  • Grafana API key/service account token for API calls
  • Optional Shared Secret for the alert webhook via Authorization: Bearer

Implementation notes:

  • Query Data Source now sends datasource as { uid: "" } to match Grafana’s Query API.
  • Grafana alert trigger now creates a unique webhook per trigger node (not a shared integration webhook).
  • Added unit tests for Query Data Source and On Alert Firing auth handling.

Demo video: https://drive.google.com/file/d/117GAjLWyp2pic79nzOqDvvDm64-qA094/view?usp=sharing

@AleksandarCole AleksandarCole added pr:stage-1/3 Needs to pass basic review. wfh labels Feb 11, 2026
@AleksandarCole AleksandarCole added pr:stage-2/3 Needs to pass functional review and removed pr:stage-1/3 Needs to pass basic review. labels Feb 12, 2026
@AleksandarCole
Copy link
Collaborator

@mfuzailzubari thank you for submitting this one!
Can you please resolve the branch conflicts. I will move on to the functional testing in the meantime, one thing I can see from the video is that integration and components do not use Grafana icon, please address that one when you get the chance and I will share more details after functional review.

@mfuzailzubari
Copy link
Author

@mfuzailzubari thank you for submitting this one! Can you please resolve the branch conflicts. I will move on to the functional testing in the meantime, one thing I can see from the video is that integration and components do not use Grafana icon, please address that one when you get the chance and I will share more details after functional review.

Conflits are resolved, moving on to other findings.

@mfuzailzubari
Copy link
Author

Fixed all the issues raised in the thread.

@AleksandarCole
Copy link
Collaborator

@mfuzailzubari I have not managed to set this up fully - I tested the query component and it worked, but the trigger one is not good. We need to avoid user having to configure these webhooks manually if there are API endpoints through which we can do this.

@mfuzailzubari
Copy link
Author

@mfuzailzubari I have not managed to set this up fully - I tested the query component and it worked, but the trigger one is not good. We need to avoid user having to configure these webhooks manually if there are API endpoints through which we can do this.

fixed it. please check.

@AleksandarCole AleksandarCole added pr:stage-3/3 Ready for full, in-depth, review and removed pr:stage-2/3 Needs to pass functional review labels Feb 17, 2026
@AleksandarCole
Copy link
Collaborator

@mfuzailzubari managed to get it to work.
Before I request any UI, assigning to engineering to evaluate the approach and do a code review.
@forestileao can you take this one?

@forestileao
Copy link
Collaborator

Also, the CI tests should pass

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@mfuzailzubari
Copy link
Author

Also, the CI tests should pass

all passed.

@forestileao
Copy link
Collaborator

forestileao commented Feb 18, 2026

@mfuzailzubari
We still need to resolve this:
image

Meanwhile I am testing your implementation

{
Name: "dataSourceUid",
Label: "Data Source UID",
Type: configuration.FieldTypeString,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use FieldTypeIntegrationResource. And we should be able to get the avaiable resources. Check dash0 or Discord integration

Comment on lines +94 to +115
return (
<div className="border-t-1 border-gray-200 pt-4">
<div className="space-y-3">
<div>
<span className="text-sm font-medium text-gray-700 dark:text-gray-300">Grafana Contact Point Setup</span>
<div className="text-xs text-gray-800 dark:text-gray-100 mt-2 border-1 border-gray-300 dark:border-gray-600 px-2.5 py-2 bg-gray-50 dark:bg-gray-800 rounded-md">
<ol className="list-decimal ml-4 space-y-1">
<li>Save the canvas to generate the webhook URL.</li>
<li>SuperPlane will try to auto-provision a Grafana webhook contact point.</li>
<li>If auto-provisioning fails, create/update the contact point manually using the URL below.</li>
</ol>
<div className="mt-3">
<span className="text-xs font-medium text-gray-700 dark:text-gray-200">Webhook URL</span>
<pre className="mt-1 text-xs text-gray-800 dark:text-gray-100 border-1 border-gray-300 dark:border-gray-600 px-2.5 py-2 bg-white dark:bg-gray-900 rounded-md font-mono whitespace-pre-wrap break-all">
{webhookUrl}
</pre>
</div>
</div>
</div>
</div>
</div>
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not able to make it automatically create a contact point. Do you know why exactly?

It should be able to create automatically, since the Sync confirmed we are connected, if it is not provisioning, then there is an error in the webhook handler. So we can remove this fallback message too, no?

Copy link
Collaborator

@forestileao forestileao Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I undertood why I was not able to automatic provision

app-1  | 2026/02/18 22:09:27 [WebhookProvisioner] Webhook 0e3e8e5e-c025-4a4d-b89c-6a8f74b17c50 provisioning failed (attempt 1/3): grafana webhook setup: contact point provisioning will be retried: error listing contact points: error executing request: Get "http://host.docker.internal:3000/api/v1/provisioning/contact-points": dial tcp 192.168.65.254:3000: connection blocked: access to private IP address 192.168.65.254 is not allowed

@mfuzailzubari
Lets lets do this: lets enhance this message box, and also add a copy text button in this container, since I need to select it currently. Check webhook.tsx

Comment on lines +33 to +42
To connect Grafana:
1. Create a Service Account token or API key in Grafana (Configuration > API Keys or Service Accounts).
2. Set the Base URL to your Grafana instance (e.g. https://grafana.example.com).
3. Paste the API token into SuperPlane and save.

For the alert trigger:
1. SuperPlane will attempt to automatically create/update a Grafana Webhook contact point.
2. Route your alert rule to the contact point created by SuperPlane.
3. If auto-provisioning is not available (permissions/API limitations), create a Webhook contact point manually using the webhook URL from SuperPlane.
`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this docs is currently incorrect, since grafana now has service accounts,
so the docs should be like:

Steps to Create Service Accounts and Tokens (UI)

  • Navigate: Go to Administration > Users and access > Service accounts.
  • Create Account: Click Add Service Account, enter a name, and assign a role (e.g., Viewer, Editor, Admin).
  • Generate Token: Click the new service account, select Add service account token, name it, and optionally set an expiration date.
  • Secure Token: Click Generate token and copy the token immediately; it will not be displayed again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:stage-3/3 Ready for full, in-depth, review wfh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments