Skip to content

Conversation

@clementduveau
Copy link

@clementduveau clementduveau commented May 23, 2025

Hello there 👋

This is a "simple" implementation of Grafana Cloud Integrations in the Terraform provider.

Integrations don't have an OpenAPI specs (because they rely on the webclient to create the dashboards, it's a mix), nor they have a client (AFAIK). So the client relies on direct API calls for the "easy start" part.

What works and have been tested:

  • Installing integrations
  • Installing with/without alerts or logs
  • Disabling integration
  • import

What I didn't test or even tried:

  • Adding a datasource (because why ?)

What could be improved

  • Update integrations ? I guess it should be an option like always-try-update to consider than the resource needs a change, forcing the upgrade.
  • Unit tests. I tested manually everything as I didn't know how to write tests for Cloud

EDIT: tested more things

@clementduveau clementduveau requested a review from a team as a code owner May 23, 2025 17:38
@clementduveau
Copy link
Author

Solves #1917

@clementduveau
Copy link
Author

Since it's been a while, I just want to add some documentation around how it works, otherwise I will forget.

When someone wants to install the integration, they click on the "Install dashboard and alerts" button. The chain of action:

  • An API call is made to an endpoint. This endpoint will install the recording rules and alert rules as well as changing the integration status to enabled
  • Another API call is made to retrieve some metadata about the integrations (id, name, folder, a URL to find the dashboards)
  • The web client call the URL to get the dashboards JSON
  • The web client push the JSON into the folder

So the client is the one doing most of the installation. This terraform ressources does that the same way.

When uninstalling, it's pretty much the same thing, but instead of getting the JSON, it just removes the folder with the dashboards and call the endpoint to disable & remove alerts.

Comment on lines +21 to +24
* folders:read
* folders:write
* dashboards:read
* dashboards:write

Choose a reason for hiding this comment

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

It's also installing alerts and rules isn't it?

@@ -0,0 +1,371 @@
package integrations

Choose a reason for hiding this comment

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

I see the other clients in internal/common. Could you move it?

Comment on lines +101 to +102
// PostDashboards posts dashboards for an integration with the given configuration
func (c *Client) PostDashboards(ctx context.Context, slug string, config *InstallationConfig) (*GetDashboardsResponse, error) {

Choose a reason for hiding this comment

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

I thought the integrations API is doing that.

@Dasomeone
Copy link
Member

Thanks @jeschkies for reminding me this exists!

@clementduveau this is an interesting one, and it's related to work that we're picking up that may affect this.
You're spot on in that the integrations-api is more a resource/source of truth for grabbing the integration to install, and (currently) installing alerts/rules, while the frontend in Grafana Cloud handles the installation of the dashboards themselves.

With the rollout of Grafana Managed Alerts this will extend to alerts/rules as well, so we'll need to touch base on what all is needed and desired here in order to get all that added in :)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants