Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to share Grafana dashboards between Coralogix teams using Terraform #198

Open
astarche opened this issue Feb 5, 2024 · 0 comments

Comments

@astarche
Copy link

astarche commented Feb 5, 2024

Affected Resource(s)

  • coralogix_hosted_dashboard

Terraform Configuration Files

# Comments describe behavior applying to our "dev" Team/tier.

# Applies and loads successfully.
resource "coralogix_hosted_dashboard" "bug_dashboard_copied_from_dev" {
  grafana {
    config_json = file("${path.module}/grafana-bug-dev.json")
  }
}

# Dashboard loads broken with "Datasource XFs7pbK4z was not found",
resource "coralogix_hosted_dashboard" "bug_dashboard_copied_from_test" {
  grafana {
    config_json = file("${path.module}/grafana-bug-test.json")
  }
}

# Dashboard loads broken with "Datasource ${DS_LOGS} was not found"
resource "coralogix_hosted_dashboard" "bug_dashboard_exported_for_sharing" {
  grafana {
    config_json = file("${path.module}/grafana-bug-exported-for-sharing.json")
  }
}

# Dashboard loads without errors but NO Data. Widget is linked to "Metrics" (the default?) instead of "Logs" as expected.
resource "coralogix_hosted_dashboard" "bug_dashboard_delete_elastic_datasource_uid" {
  grafana {
    config_json = file("${path.module}/grafana-bug-delete-datasource-uid.json")
  }
}

See gist for json files: https://gist.github.com/astarche/5d84f939328959975d997e50dabc52b6

The Grafana json includes a "datasource uid" for each data source (Logs or Metrics). This uid is not the same for each Coralogix instance, so the dashboard does not import correctly to a different Coralogix Team.

Debug Output

There is no debug output. The dashboards are created successfully but have errors when loading in Grafana.

Panic Output

None.

Expected Behavior

I don't know if these options should "magically work", but there should be a recommended way to apply the same Grafana dashboards to different Coralogix teams. This could be something explicit like detecting the datasource ID as a Terraform Data source and passing it as a parameter. Or it could be automatic.

The Grafana "export for sharing externally" feature was created for this purpose but it's implemented in the Grafana UI.

Actual Behavior

The failure in grafana is either:

  • "Datasource <some_name> was not found"
  • Dashboard loads linked to default Metrics datasource instead of logs.

See comments in the terraform config for more details.

Steps to Reproduce

  1. Create a grafana dashboard in the Grafana instance for Coralogix Team "test"
  2. Export the dashboard json either by (a) copying the JSON Model or (b) using the "Export for sharing externally" option or (c) delete the datasource uid.
  3. terraform apply to a different Coralogix Team "dev"
  4. Open the created dashboard(s) on dev to see errors.

Note that in the example terrraform I have manually changed the dashboard uid and name to allow deploying multiple versions of the same dashboard.

Important Factoids

We use a separate Coralogix Team for each environment (i.e. dev/test/astarche-demo) with common Terraform to apply the configuration.

References

None.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant