How to add datasource to Managed Grafana via Terraform

Herbst Stefanie (PS/PJ-SOFC-CPS) 20 Reputation points
2023-07-06T10:24:52.69+00:00

We're about to set up Azure Managed Grafana. First we've tried by using the Terraform resource azurerm_dashboard_grafana which does work, but we can't configure anything like e.g. datasources. We don't want to configure this manually or by creating further CLI scripts, but want to stick to our Terraform rollout that we use for all our Azure environments.

According to those docs, the azapi resource would be able to pass exactly such information with "grafanaIntegrations":

GrafanaIntegrations is a bundled observability experience (e.g. pre-configured data source, tailored Grafana dashboards, alerting defaults) for common monitoring scenarios.

So I'm wondering how a data source or even a default dashboard could be added to this resource? Unfortunately I haven't found any sample.

Azure Managed Grafana
Azure Managed Grafana
An Azure service used to deploy Grafana dashboards for analytics and monitoring solutions.
83 questions
{count} votes

Accepted answer
  1. Monalla-MSFT 11,876 Reputation points
    2023-07-12T14:18:54.2466667+00:00

    @Herbst Stefanie (PS/PJ-SOFC-CPS) - Welcome to Microsoft Q&A and thanks for reaching out to us.

    In order to add a datasource to Grafana using Terraform, you can use grafana_data_source resource. Have you tried using that?

    If not, please look at the example configuration and see if it helps.

    resource "grafana_data_source" "example" {
      name = "Example Datasource"
      type = "prometheus"
      url = "http://prometheus.example.com"
      access_mode = "proxy"
      basic_auth_username = "username"
      basic_auth_password = "password"
      is_default = true
    }
    
    

    Here in the above example, we are creating a Prometheus DataSource named "Example Datasource" with the URL "http://prometheus.example.com", also setting the access mode to "proxy" and providing basic authentication credentials. Finally, we are setting this DataSource as the default DataSource.

    You can customize this configuration to match your specific DataSource requirements. For more information about the grafana_data_source resource and its properties, refer this doc: ttps://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/data_source

    Hope this helps. and please feel free to reach out if you have any further questions.


    If the above response was helpful, please feel free to "Accept as Answer" and click "Yes" so it can be beneficial to the community.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful