Giter Club home page Giter Club logo

terraform-provider-grafana's Introduction

Terraform Provider for Grafana

Acceptance Tests Unit Tests Cloud Acceptance Tests

Requirements

Development

If you're new to provider development, a good place to start is the Extending Terraform docs.

Set up your local environment by installing Go. Also Docker can be used for running tests.

Local Development with Grafana

If you develop the provider and want to test locally with your grafana provider

  1. create a .terraformrc file in your operating system user directory and paste the following
provider_installation {
   dev_overrides {
      "grafana/grafana" = "/path/to/your/terraform-provider-grafana" # this path is the directory where the binary is built
  }
  # For all other providers, install them directly from their origin provider
  # registries as normal. If you omit this, Terraform will _only_ use
  # the dev_overrides block, and so no other providers will be available.
  direct {}
}
  1. Run go build in this directory to get the binary, Terraform will use the binary you just built for every terraform plan/apply (it should print out a warning). No need to run terraform init.

Running Tests

Acceptance tests require a running instance of Grafana. You can either handle running an instance of Grafana yourself or use docker-compose.

If you choose docker-compose, run make testacc-docker. This is the simplest option, but often not the quickest.

Alternatively you can use the testacc target which will use your local go installation:

# Assuming Grafana was run with:
# docker run --rm -p 3000:3000 grafana/grafana

GRAFANA_URL=http://localhost:3000 \
GRAFANA_AUTH=admin:admin \
make testacc

Running enterprise tests

To run tests for resources which are available only for Grafana Enterprise, running instance of Grafana Enterprise is required. It is only possible to run tests for Grafana Enterprise using local environment.

# Assuming Grafana was run with:
# docker run --rm -p 3000:3000 grafana/grafana

GRAFANA_URL=http://localhost:3000 \
GRAFANA_AUTH=admin:admin \
make testacc-enterprise

Documentation

Documentation is generated with tfplugindocs. Generated files are in docs/ and should not be updated manually. They are derived from:

Use go generate to update generated docs.

Releasing

Builds and releases are automated with GitHub Actions and GoReleaser.

Currently there are a few manual steps to this:

  1. Kick off the release:

    RELEASE_VERSION=v... \
    make release
  2. Publish release:

    The Action creates the release, but leaves it in "draft" state. Open it up in a browser and if all looks well, click the Auto-generate release notes button and mash the publish button.

terraform-provider-grafana's People

Contributors

alexweav avatar apparentlymart avatar appilon avatar cleymax avatar dependabot[bot] avatar dmihai avatar elainevuong avatar eleijonmarck avatar grubernaut avatar ievavasiljeva avatar inkel avatar jonathan-dorsey avatar julienduchesne avatar justintm avatar konstantinov-innokentii avatar mdb avatar medains avatar mem avatar mlclmj avatar paultyng avatar pearkes avatar puneeth-n avatar radeksimko avatar sa-githubcloudtesting avatar skatsaounis avatar spinillos avatar tonglil avatar trotttrotttrott avatar vtorosyan avatar yuri-tceretian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-grafana's Issues

Editing Dashboard 'title' creates new dashboard - leaving old dashboard behind

Terraform Version

Terraform v0.12.9

  • provider.grafana v1.5.0

Affected Resource(s)

  • grafana_dashboard

Terraform Configuration Files

provider "grafana" {
  url = "https://grafana.${var.platform_domain_name}"
  auth = "${var.grafana_admin_username}:${var.grafana_admin_password}"
}

resource "grafana_dashboard" "test" {
  config_json = "${file("basic_graph.json")}"
}

Expected Behavior

Based on understanding of how the Grafana provider works, running terraform plan would have shown that my dashboard resource was going to be replaced. After running terraform apply I would see only the renamed dashboard in Grafana UI rather than both new and old named dashboards.

Actual Behavior

Running terraform plan shows that grafana_dashboard.test will be updated in-place. Running terraform apply performs the indicated name change for dashboard - in place.
When viewing results within Grafana UI, the new dashboard exists with its rename (and a different uid. The old dashboard is still there as well.

Steps to Reproduce

  1. Create visualization through Grafana
  2. Export .json file
  3. Remove dashboard from Grafana UI
  4. Add resource to terraform config file
  5. Run terraform plan and confirm a new dashboard resource will be added
  6. Run terraform apply and see new dashboard in Grafana UI
  7. Update .json config file to change "title" of dashboard
  8. Run terraform plan
  9. Run terraform apply
  10. View both new and old dashboards on Grafana UI

Cannot create/delete multiple dashboards resources at once

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform version v0.11.11
Grafana provider v1.4.0

Affected Resource(s)

grafana_dashboard

Expected Behavior

What should have happened?
Updated the two json files used by template files, which are used by two different grafana_dashboard resources. Should have deleted existing dashboards and created with new dashboards with updated json.

Actual Behavior

What actually happened?
Only one dashboard was deleted and created, the other failed to delete and returned an '500 Internal server error'

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Deploy two dashboard resources through terraform
  2. Update json of these template files in some way
  3. terraform apply and get 500 back for one of the dashboards.

Resources to configure grafana server (installation) configuration?

Terraform Version

Terraform v0.11.7

  • provider.grafana - I'm unaware of the version our org is using at the moment. How to find out?

I looked around the docs for the grafana provider: https://www.terraform.io/docs/providers/grafana/index.html.

I see options to configure dashboards, alert notification channels, data sources, and org stuff. But nothing with respect to SMTP email configuration (needed for the email alert notification channels if creating those) nor external image storage (to s3/webdav) configuration that's also an option for alert notification channels.

Are uses expected to configure those out of band outside of the grafana provider using alternate means?

Would be nice if the provider in the future had ways to configure those options. I'm referring to these:

Grafana 5 datasource for variables/templating/panels are not assigned

Hi there,

I've noticed that creating a dashboard with the terraform grafana provider has an issue with assigning a datasource to variables/templates/panels. After the dashboard has been created with terraform, I still have to assign the datasource manually.

Terraform Version

$ terraform -v
Terraform v0.11.5
+ provider.grafana v1.0.1

Affected Resource(s)

  • grafana_dashboard

Terraform Configuration Files

provider "grafana" {
  url  = "http://localhost:3001"
  auth = "eyJrIjoiUlZ1Vjd2UlE3MU8ydkJCNVZEcTgwWlMyaXphWEpXUXgiLCJuIjoiYXNkZiIsImlkIjoxfQ=="
}

resource "grafana_data_source" "cloudwatch" {
  type          = "cloudwatch"
  name          = "DATASOURCE"
  url           = "http://localhost:3001"
  json_data {
    default_region = "us-east-1"
    auth_type      = "keys"
  }
}

resource "grafana_dashboard" "billing" {
  config_json = "${file("billing.json")}"
  depends_on  = [ "grafana_data_source.cloudwatch" ]
}

Expected Behavior

I expect the dashboard to assign its datasource for variables/templating and panels as specified in the billing.json file.

Actual Behavior

After terraform apply, I have to manually assign the datasource to the variables and panels. Just loading the dashboard without assigning the datasource returns Templating init failed Datasource named ${DS_DATASOURCE} was not found.

Steps to Reproduce

  1. terraform apply
  2. Open the Grafana Web UI and load the specified dashboard.

Important Factoids

I'm using the grafana/grafana docker without a tag to reproduce this behavior. Also, some examples of datasource, panel and templating as declared in billing.json:

  "__inputs": [
    {
      "name": "DS_DATASOURCE",
      "label": "DATASOURCE",
      "description": "",
      "type": "datasource",
      "pluginId": "cloudwatch",
      "pluginName": "CloudWatch"
    }
  ],
    {
      "aliasColors": {},
      "bars": true,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_DATASOURCE}",
      "description": "Select accounts with the LinkedAccounts drop-down menu.",
      "fill": 1,
      "gridPos": {
        "h": 10,
        "w": 7,
        "x": 0,
        "y": 0
      },
      "id": 9,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": false,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "repeat": null,
      "repeatDirection": "h",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "Total on account: {{LinkedAccount}}",
          "dimensions": {
            "Currency": "USD",
            "LinkedAccount": "$LinkedAccounts"
          },
          "metricName": "EstimatedCharges",
          "namespace": "AWS/Billing",
          "period": "",
          "refId": "A",
          "region": "us-east-1",
          "statistics": [
            "Average"
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeShift": null,
      "title": "Total cost per account: $LinkedAccounts",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "series",
        "name": null,
        "show": false,
        "values": [
          "current"
        ]
      },
      "yaxes": [
        {
          "format": "currencyUSD",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": "0",
          "show": true
        },
        {
          "decimals": 2,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ]
    },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_DATASOURCE}",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "LinkedAccounts",
        "options": [],
        "query": "dimension_values(us-east-1, AWS/Billing, EstimatedCharges, LinkedAccount)",
        "refresh": 1,
        "regex": "",
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },

[Feature request] Have Grafana dashboards be stored by uid instead of slug

Hi there,

Currently Grafana dashboards are stored by their slug instead of uid using one of the newer versions of Grafana. This causes failures with having multiple dashboards being named the same under different folders in the same Grafana instance. With changing to uid for dashboards, this should resolve the issue.

Affected Resource(s)

  • resource_dashboard

Upstream Library Ownership

Hi there,

I'm interested in adding additional functionality to this provider, and have hit a bit of a roadblock: it isn't clear who the maintaining party of the upstream library is.

From what I can gather, it appears that the library was changed in #16, and @apparentlymart voiced that he's no longer able to maintain it.
I haven't had any success reaching out to @teemupo who is the owner of the current fork, and judging by the fact that his PR remains open, I'd presume he doesn't have a strong interest in maintaining it either.

It appears to me that the upstream library is in need of a more permanent home, any ideas on what would be the best course of action here?

If no one else is in a position to do so, we'd like to offer to take ownership of the upstream library and maintain it, pulling back in contributions that have been made on other forks as well.

cc @sbower @msuterski @tonglil

Allow for org_id field in resource definitions

I think a basic feature that is missing in this provider is the ability to specify to which org you would like a resource to belong. I understand this is in part due to the construction of the Grafana API. The Grafana API is not RESTful, since it maintains an internal state variable of the current_org between API calls. This is makes implementing this feature slightly more difficult.

This is a crucial feature since internally, each Grafana API object is implicitly linked to an org_id. Therefore, in order to align the Terraform Provider with the data-model used by Grafana, the resources should also have an org_id field.

Affected Resource(s)

Please list the resources as a list, for example:

  • All resources except for grafana_organization

Expected Behavior

The below example is just done with grafana_data_source but applies to every resource in the provider.

Given a sample resource configuration like this:

provider "grafana" {
  url  = "http://localhost:3000/"
  auth = "admin:admin"
}


resource "grafana_organization" "org1" {
  name         = "test-provider1"
  admin_user   = "admin"
}

resource "grafana_organization" "org2" {
  name         = "test-provider2"
  admin_user   = "admin"
}

resource "grafana_data_source" "metrics" {
  type          = "graphite"
  name          = "myapp-metrics-test"
  org_id        = "${grafana_organization.org1.id}"  
}

resource "grafana_data_source" "metrics2" {
  type          = "graphite"
  name          = "myapp-metrics-test2"
  org_id        = "${grafana_organization.org2.id}"  
}

resource "grafana_data_source" "metrics3" {
  type          = "graphite"
  name          = "myapp-metrics-test3"
  org_id        = "${grafana_organization.org1.id}"  
}

resource "grafana_data_source" "metrics4" {
  type          = "graphite"
  name          = "myapp-metrics-test4"
  org_id        = "${grafana_organization.org2.id}"  
}

We should expect for 2 datasources to be created in 2 different orgs, like so:
image

and

image

Actual Behavior

An error because these fields are not available in the current version of the provider

References

Related issues: https://github.com/terraform-providers/terraform-provider-grafana/issues/31#issuecomment-491044905

Unable to deploy azure monitor because of unknown key

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.11.13

  • provider.grafana v1.4.0

Affected Resource(s)

Please list the resources as a list, for example:

grafana_data_source

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "grafana_data_source" "events"{
  type = "grafana-azure-monitor-datasource"
  name = "${var.prefix}-gds-ai-AK"

  secure_json_data{
    appInsightsApiKey = "${azurerm_application_insights_api_key.aik.api_key}"
    appInsightsAppId = "${azurerm_application_insights.ai.app_id}"
  }
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Expected Behavior

What should have happened?
Grafana Azure Monitor Datasource should be created with the the Application Insights details filled in

Actual Behavior

What actually happened?
Error about unknown keys

`Error: grafana_data_source.events: secure_json_data.0: invalid or unknown key: appInsightsApiKey

Error: grafana_data_source.events: secure_json_data.0: invalid or unknown key: appInsightsAppId`

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

Allow anonymous access to Grafana

In Grafana it is possible to open access to everyone. By doing so, you don't need to provide an Authorization header with your POST call.

The terraform-provider-grafana does not support this concept yet. The auth field must be provided and even when keeping it empty, the provider always sends an Authorization header with every request.

Can we make it optional to send the auth token or at least give us the option to disable auth completely within the provider?

Sync Terraform state with Grafana backend

TF will fail updating Grafana data sources and dashboards in case they've been manually deleted.

Affected Resource(s)

  • grafana_dashboard
  • grafana_data_source

Expected Behavior

Grafana provider syncs state with the Grafana backend and detects that the resources have been deleted and re-creates them

Actual Behavior

Grafana provider fails with a HTTP 404 Not Found error because the resources are gone

Grafana provider ENV variables as preferred

Hi there,

I would like to ask why ENV variables are used as default and not as the 1st preference for url and auth?

Use-case:
I would like to keep grafana url defined through load balancers for when I need to apply terraform from our local laptops, but having a CD/CD running inside kubernetes I would like it uses the services address instead. If we define the ENV variable I would expect that could be the preferred option instead of being only the default. So, I would only need to set the GRAFANA_URL variable in my CI/CD, and it would run smoothly without any more terraform resources with if conditions.
I would say that most of the services always use ENV variables as the preferred method if they are defined, otherwise they check files and other sources.

Thanks a lot and keep the good work

grafana_data_source does not set the service account key for the stackdriver datasource

Terraform Version

0.12.24

Affected Resource(s)

Please list the resources as a list, for example:

  • grafana_data_source

Terraform Configuration Files

resource "grafana_data_source" "stackdriver-datasource" {
name = local.datasource_name
type = "stackdriver"
secure_json_data {
access_key = local.service_account_key
secret_key = ""
}
}

Expected Behavior

What should have happened?
The stackdriver datasource is created in Grafana with the service account key defined.

Actual Behavior

What actually happened?
The stackdriver datasource is created, however, no key is defined. Manually setting the key in the datasource works, and allows the datasource to work. Terraform does not give any indication of failure before or after manually setting the key.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Unable to use provider with Let's Encrypt certificate

Terraform Version

Terraform v0.12.16
+ provider.aws v2.38.0
+ provider.grafana v1.5.0
+ provider.local v1.4.0
+ provider.mongodbatlas v0.3.1
+ provider.null v2.1.2
+ provider.random v2.2.1
+ provider.template v2.1.2

Affected Resource(s)

  • grafana_*

Basically all grafana resources are affected because nothing works due to SSL Certificate issues.

Terraform Configuration Files

resource "grafana_folder" "project_folder" {
  title = "${var.customer}"
}

resource "grafana_dashboard" "konekti" {
  provider = grafana.customer
  
  folder = grafana_folder.project_folder.id
  config_json = templatefile("grafana/dashboard.json", {
      traefik_url = local.traefik_url,
      customer_name = var.customer,
      env = local.env
  })
}

Expected Behavior

I expect the terraform provider to accept Let's Encrypt certificates

Actual Behavior

I am unable to use any grafana resource because it always ends with this error:

Error: Post https://grafana.xxx.xxx/api/folders: x509: certificate signed by unknown authority

My computer (Mac) in trusts Let's Encrypt certificates and when I connect to Grafana using my browser or curl I also see no issues. Running the following command with a valid token works perfectly fine.

curl -H "Authorization: Bearer my-token-here" https://grafana.xxx.xxx/api/dashboards/home

Steps to Reproduce

Run provider against a grafana instance using by Let's Encrypt certs.

References

[Feature Request] Manage Grafana playlists through Terraform

Hi there,

This is a request to add Grafana playlist resource to the provider
http://docs.grafana.org/reference/playlist/

Terraform Version

Terraform v0.11.7

  • provider.grafana v1.0.2

Affected Resource(s)

Please list the resources as a list, for example:

  • grafana_dashboard

Expected Behavior

Terraform provider is playlist aware

Actual Behavior

Terraform managed dashboards are often recreated with a new ID. Playlists reference dashboards by ID and will lose previously managed dashboards. If terraform was playlist-aware, the playlist resource could reference a list of dashboards.

A grafana "bug" that has been exposed with this - if a playlist ends up empty (no dashboards attached), it becomes broken/undeletable/uneditable. To fix this, we've manually editable the database.

Setting the alert notification channel uid

Hello,

According to grafana API docs, an alert notification channel can be set with a UID. I'd be happy to be able to set that with the grafana_alert_notification resource or for the very least get the auto-generated UID pulled and made available for me to refer to (as in id).

The reason for that is that when I create a dashboard that contains an alert, I need to refer to the alert by that uid - and there's no way for me to tell what the uid of the notification channel I created otherwise.

Thanks,
Yosi

[Feature Request] Support Bigquery datasource

Hello,

It will'd be great to be able to use configure the version grafana_data_source to create a new doitintl-bigquery-datasource.
Today it's possible to create it but it's not possible to add the JSON key of the GCP Service account to use.

Affected Resource(s)

  • grafana_data_source

[Feature Request] Support dashboard overwriting

It doesn't look like overwriting dashboards is supported via this library, but it is a supported by the Grafana Dashboard API.

Admittedly I'm a bit torn on this issue, because it seems like by default Grafana wants you to ensure that when you make updates it expects a JSON file with a version number higher than what is currently loaded. This seems like a good practice. On the other hand, my team frequently makes live tweaks to dashboards but we'd like to use terraform as the source of truth. This also helps us deploy dashboards to multiple environments in an automated fashion. In that case we could just export the dashboard and then have terraform recreate it. In that workflow we'd actually have to bump the version number because the version numbers would be identical.

What do you all think? Should this be supported?

Allow skipping TLS verify in datasources

Please add support for setting the skip TLS verify flag via the grafana_data_source resource for Prometheus datasources. Our test environment is using LE staging certificates which will cause Grafana to fail fetching data due to an untrusted certificate.

Affected Resource(s)

Please list the resources as a list, for example:

  • grafana_data_source

Prompted for 'auth' on terraform plan execution

Terraform Version

Terraform v0.11.14 ( via Visual Studio Team Services extension)

Affected Resource(s)

Provider grafana

Terraform Configuration Files

provider "grafana" {
  version = "~> 1.5.0"
  alias    = "default"
  url       = "${var.grafana_url}"
  auth    = "${var.grafana_auth_token}"
}

Debug Output

Debug output from Plan: https://github.com/ocastle/gist/blob/master/grafana-provider.gist

Expected Behavior

Access to the Grafana API granted using the 'url' and 'auth' values provided.

Testing the auth token/url combination I was able to confirm that the api is accessible and working.

Working command:

curl -k -X GET 'https://my_url/api/folders' -H "Authorization: Bearer **************"

Actual Behavior

Referenced tf variables are set, but the provider.grafana prompts for .auth

provider.grafana.auth‌
  Credentials for accessing the Grafana API.

  Enter a Value:

[DEBUG] command: asking for input: "provider.grafana.auth"

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Visual Studio Team Services task extension to call terraform commands.

References

Not explicitly encountering this behavior that I found.

Provider cannot connect to Grafana instance, throws 401 Unauthorized

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.12.16

  • provider.aws v2.39.0
  • provider.grafana v1.4.0
  • provider.null v2.1.2
  • provider.random v2.2.1

Affected Resource(s)

  • grafana_data_source

Issue seems to be with Grafana provider itself, it cannot seem to authenticate.

Terraform Configuration Files

provider "grafana" {
  url = "https://grafana.${var.platform_domain_name}"
  auth = "${var.grafana_admin_username};${var.grafana_admin_password}"
  version = "1.4"
}

resource "grafana_data_source" "staging" {
  name                = "Staging"
  type                = "cloudwatch"

  json_data {
    auth_type       = "arn"
    default_region  = var.region
    assume_role_arn = "arn:aws:iam::${lookup(var.aws_account_ids, "staging")}:role/grafana"
  }
}

resource "grafana_data_source" "qa" {
  name                = "QA"
  type                = "cloudwatch"

  json_data {
    auth_type       = "arn"
    default_region  = var.region
    assume_role_arn = "arn:aws:iam::${lookup(var.aws_account_ids, "qa")}:role/grafana"
  }
}

Debug Output

https://gist.github.com/neocorp/72468d6c33c34dafabc6c97f6cc662cf

Panic Output

N/A

Expected Behavior

Grafana provider should be able to connect to Grafana and create the data sources.

Actual Behavior

Terraform throws 401 Unauthorized error. Using username/password combination or API Token from Grafana doesn't make a difference, produces the same error.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Important Factoids

Grafana instance is running on ECS Fargate and accessible for terraform environment.
Issue can also be reproduced with 1.5 Grafana provider version.

[Feature Request] Support teams, admin users, users

In current implementation, it appears terraform-provider-grafana does not support Grafana teams, admin users, users . It would be great to be able to create them

/api/org/users PATCH to add native admin not role
/api/admin/users
/api/users
/api/teams

grafana_dashboard metadata being lost

Hi there,

Terraform Version

Terraform v0.11.7

  • provider.grafana v1.0.2

Affected Resource(s)

Please list the resources as a list, for example:

  • grafana_dashboard

Expected Behavior

Grafana dashboards use the metadata of the dashboard to reproduce placement in folders, etc.
This is all of the data for a dashboard given by the Grafana API. Note that the Grafana UI does not yet allow exporting the metadata. Grafana maintainers do not intend on allowing users to export the dashboard metadata through the UI. The proper method to get all of the dashboard data is through the API.
{ "meta": { "type": "db", "canSave": true, "canEdit": true, "canAdmin": false, "canStar": true, "slug": "dashboard-name", "url": "/d/XckjVRNik/dashboard-name", "expires": "0001-01-01T00:00:00Z", "created": "2018-06-13T20:50:54Z", "updated": "2018-06-13T21:19:15Z", "updatedBy": "bljordan", "createdBy": "Anonymous", "version": 2, "hasAcl": false, "isFolder": false, "folderId": 82, "folderTitle": "dashboard-name", "folderUrl": "/dashboards/f/kdhl-0Sik/dashboard-name" }, "dashboard": { "annotations": { "list": [ { <snip>

Actual Behavior

The terraform provider expects only the dashboard json blob and metadata is lost (folder placement, folder permissioning).

Steps to Reproduce

Use the terraform provider with Grafana 5.0.4 and folders. Make changes, apply, watch metadata be lost.

References

See corresponding issue in Grafana: grafana/grafana#12266

Provider not finding super fresh dashboards

Hi there,
I found an inconsistent behaviour in the provider that I believe to be a bug.

Terraform Version

Terraform v0.11.8

Affected Resource(s)

Please list the resources as a list, for example:

  • grafana_dashboard

Terraform Configuration Files

resource "grafana_dashboard" "nodes" {
  config_json = "${file("dashboards/Nodes.json")}"
}

(and another dozen of this)

Debug Output

2018-10-08T00:49:02.715Z [DEBUG] plugin.terraform-provider-grafana_v1.2.0_x4: 2018/10/08 00:49:02 [WARN] removing dashboard nodes from state because it no longer exists in grafana
grafana_dashboard.nodes: Creation complete after 3s

Expected Behavior

Grafana dashboard should be created in grafana and also in terraform's state

Actual Behavior

In some circumstances, the dashboard gets created in Grafana, but not in terraform's state

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create around 12 different dashboards with a total payload of at least ~800k
  2. terraform plan
  3. terraform apply
  4. terraform plan

At step 4, terraform might refresh just a subset of the created dashboards (as some were not created in terraform state). And when it tries to create the 'missing' ones, it fails due to an id clash (error code 412 - precondition)

Important Factoids

The pipeline was working fine until it reached a certain size threshold. After this point, sometimes it works, but most of the times it fails. And it skips different number of resources (the worst I've seen was missing 6 dashboards, which is half of them)

My personal theory is that the code is querying grafana faster than it can handle the initial create command.

References

Maybe if we just give it more time (or more opportunities) to the check below the issue would go away.

ReadDashboard function

[Feature Request] Import existing dashboards into terraform

Hi there,

This is a request to add import functionality to the grafana provider, specifically for the grafana_dashboard resource.

Terraform Version

Terraform v0.11.7

  • provider.grafana v1.0.2

Affected Resource(s)

Please list the resources as a list, for example:

  • grafana_dashboard

Expected Behavior

Import existing dashboards into terraform state:
terraform import grafana_dashboard.my_dashboard <slug|id|?>

Actual Behavior

grafana_dashboard.my_dashboard: Importing from ID "<dashboard_id>"...

Error: grafana_dashboard.my_dashboard (import id: <dashboard_id>): import grafana_dashboard.my_dashboard (id: <dashboard_id>): resource grafana_dashboard doesn't support import

Steps to Reproduce

terraform import grafana_dashboard.my_dashboard

Terraform not able to destroy resources in order to recreate them after Grafana folder name change

Terraform Version

Terraform v0.12.18

  • provider.grafana v1.5.0

Have also tried:

Terraform v0.12.9

  • provider.grafana v1.5.0

Affected Resource(s)

(in separate instances)

  • grafana_dashboard
  • grafana_folder

Terraform Configuration Files

terraform {
  backend "s3" {
    bucket = "example-bucket"
    key    = "rest-of/path-to/dashboards-statefile.tfstate"
    region = "us-east-1"
  }
}

locals {
  dashboard_dir = "${path.module}/../../dashboard_directory"
}

provider "grafana" {
  url  = "https://grafana.url.here.com"
  auth = var.grafana_api_key
}

resource "grafana_folder" "grafana_folder" {
  title = "Grafana Folder"
}

resource "grafana_dashboard" "dashboard" {
  for_each    = fileset("${local.dashboard_dir}/", "*")
  config_json = jsonencode(jsondecode(file("${local.dashboard_dir}/${each.value}")))
  folder      = grafana_folder.grafana_folder.id
}

Debug Output

Omitting majority for brevity but here is an example of what I'm seeing. Note that this is not happening to all dashboards. For some reason there are a couple that seem to not have a problem.

2020/01/08 15:54:40 [DEBUG] grafana_dashboard.grafana_dashboard["dashboard_config.json"]: apply errored, but we're indicating that via the Error pointer rather than returning it: 412 Precondition Failed
2020/01/08 15:54:40 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/01/08 15:54:40 [TRACE] EvalWriteState: writing current state object for grafana_dashboard.grafana_dashboard["dashboard_config.json"]
2020/01/08 15:54:40 [TRACE] <root>: eval: *terraform.EvalApplyPost
2020/01/08 15:54:40 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: 412 Precondition Failed
2020/01/08 15:54:40 [ERROR] <root>: eval: *terraform.EvalSequence, err: 412 Precondition Failed
2020/01/08 15:54:40 [ERROR] <root>: eval: *terraform.EvalOpFilter, err: 412 Precondition Failed
2020/01/08 15:54:40 [TRACE] [walkApply] Exiting eval tree: grafana_dashboard.grafana_dashboard["dashboard_config.json"] (destroy)
2020/01/08 15:54:40 [TRACE] vertex "grafana_dashboard.grafana_dashboard[\"dashboard_config.json\"] (destroy)": visit complete

Panic Output

N/A

Expected Behavior

All dashboard resources (8 in total) should have been destroyed and recreated with the state being updated.

Actual Behavior

Majority of the dashboards fail to destroy (in order to be recreated), 412 Precondition failed errors appear and the statefile is not updated.

Steps to Reproduce

  1. Have statefile in good condition with a folder and dashboard(s) in said folder.
  2. Change name of grafana folder in terraform file.
  3. Run terraform plan and see dashboards and folder will all be destroyed and then created.
  4. Run terraform apply and get 412 Precondition Failed errors (sometimes one for each dashboard, but I've also seen some dashboards not have any problem for some reason).

Important Factoids

Steps and behaviors laid out above are when editing the grafana_folder resource. The same has happened with grafana_dashboard resources as well. We were having issues adding new dashboards to our existing folder (in statefile), but this was fixed by encoding and decoding the json to cause it to not find any changes with the config file (there never were changes with it, but terraform thought there were).

References

N/A

Invalid CA

Dear,
trying to apply I get the error below.
But the certificate and CA is valid.
How to add this CA or skip the CA test??
Thanks

`Error: Error applying plan:

1 error(s) occurred:

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.`

POSTing to Comodo-certified grafana URL fails with x509: certificate signed by unknown authority

Hi there,

I'm trying to setup grafana using the terraform provider and my commands are all returning with the following error:

grafana_data_source.prometheus: Post https://<user_redacted>:<password_redacted>@<grafana_url_redacted>/api/datasources: x509: certificate signed by unknown authority

Manually POSTing to the same Grafana URL using the same credentials works from the same machine terraform is running on, so it seems like the issue lies somewhere with terraform or the grafana-provider. The host machine is running MacOS 10.13.4.

The certificate the site uses is issued by COMODO so should be well trusted!

Terraform Version

Terraform v0.11.8

  • provider.grafana v1.2.0

Affected Resource(s)

grafana_alert_notification
grafana_data_source
grafana_dashboard (presumed, haven't got this far is the above two resources fail to create)

Terraform Configuration Files

Since the above resources have no ssl/security/credentials fields available to them, I assume the problem is with the provider, here's an example of what I have defined:

provider "grafana" {
  url = "https://${var.grafana_url}"
}

resource "grafana_data_source" "prometheus" {
  type = "prometheus"
  name = "Prometheus"
  url = "http://${var.prometheus_ilb}:9090/"
}

Expected Behavior

Terraform should be able to create data sources, notification channels, and dashboards using the grafana provider

Actual Behavior

All POSTs to Grafana API endpoints return x509: certificate signed by unknown authority

Steps to Reproduce

  1. terraform apply

Important Factoids

The grafana server is managed by terraform in GCE

References

I've found a number of issues where Mac terraform users seem to have trouble with terraform loading local certs, but these issues appear to have been fixed in terraform v0.10.02 (upgraded to go 1.9). I am on terraform v0.11.8.

hashicorp/terraform#15713

[feature request] Terraform should able to read the auth from a file ~/.grafana-auth

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v0.11.14

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

Expected Behavior

auth - (Required) The API token or username/password to use to authenticate to the Grafana server. If username/password is used, they are provided in a single string and separated by a colon. May alternatively be set via the GRAFANA_AUTH environment variable.

If none supplied, Terraform should to read it from ~/.grafana-auth

Actual Behavior

auth - (Required) The API token or username/password to use to authenticate to the Grafana server. If username/password is used, they are provided in a single string and separated by a colon. May alternatively be set via the GRAFANA_AUTH environment variable.

provider.grafana.auth
Credentials for accessing the Grafana API.

Enter a value:

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

Grafana 5.0 Dashboard Support

Terraform Version

Terraform v0.11.1

Affected Resource(s)

Please list the resources as a list, for example:
grafana_dashboard

Terraform Configuration Files

Grafana has added a new uid field in the dashboard JSON spec (http://docs.grafana.org/reference/dashboard/) which is a user specified string id. If not provided externally the system will generate one. This causes a dashboard created via terraform to be recreated everytime if it's not provided, a precondition failed error if the value is left in from an export and multiple instances of our module are included, to handle this we've added a random_string resource and used that to provide the uid via a tempalte so that multiple instances of our module still work.

Ideally the behaviour of the UID field would be handled by the provider similar to how id is handled.
https://github.com/terraform-providers/terraform-provider-grafana/blob/master/grafana/resource_dashboard.go#L96
https://github.com/terraform-providers/terraform-provider-grafana/blob/master/grafana/resource_dashboard.go#L124

Thanks

ReadDataSource fails if the data source is not there

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v0.11.13

Affected Resource(s)

  • grafana_data_source

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource grafana_data_source "derp" {
  type = "cloudwatch"
  name = "DERP"

  json_data {
    assume_role_arn = "arn:aws:iam::123456789012:role/Derp"
    auth_type       = "arn"
    default_region  = "ap-southeast-2"
  }
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

What should have happened?

Terraform should nuke the data source from its state file.

Actual Behavior

What actually happened?

Terraform exits with a "404 Not Found" error

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

[Feature Request] Support Annotations

In current implementation, it appears terraform-provider-grafana does not support Grafana annotations. It would be great to be able to annotate dashboards from a terraform apply, thus empowering Grafana dashboard visualization of events -- such as deployments -- and the events' impact on key metrics.

Note that apparentlymart/go-grafana-api PR #6 seeks to add annotation support to apparentlymart/go-grafana-api, such that annotation support could then be addressed here in terraform-provider-grafana.

Thanks!

Make url field optional for grafana_data_source to support Cloudwatch

Hi,

The url field is marked as required at the moment. However, it's not required/available when using Cloudwatch as a datasource. Could you make it optional please?

Terraform Version

Terraform v0.11.2
+ provider.grafana v1.0.1

Affected Resource(s)

  • grafana_data_source

Terraform Configuration Files

N/A

Debug Output

N/A

Panic Output

N/A

Expected Behavior

User doesn't need to specify an url value for datasource of cloudwatch type.

Actual Behavior

User needs to specify a value, even though any value would suffice, including invalid URLs

Steps to Reproduce

Run terraform apply with the following configuration

resource "grafana_data_source" "cloudwatch_metrics" {
  type          = "cloudwatch"
  name          = "default-cloudwatch-metrics"

  # not required by cloudwatch datasource but still need to be provided
  url           = "foo"
  json_data {
    default_region = "${var.aws_region}"
    auth_type      = "arn"
  }
}

Error: Arguments must not be quoted

This issue was originally opened by @ashishsarkar as hashicorp/terraform#22881. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.7

Terraform Configuration Files

resource "grafana_alert_notification" "email_notification" {
  name = "email_notification"
  type = "email"
  is_default = false

  settings = {
    addresses = "[email protected];[email protected]"
    uploadImage = "false"
  }
}

Debug Output

$ terraform plan
Error: Argument names must not be quoted...

Crash Output

Expected Behavior

Actual Behavior

Steps to Reproduce

provider "grafana" {
url = "http://:3000"
auth = "admin:admin"
}
resource "grafana_alert_notification" "email_someteam" {
name = "Email that team"
type = "email"
is_default = false

settings {
"addresses" = "[email protected];[email protected]"
"uploadImage" = "false"
}
}

$ terraform init
$ terraform apply

Additional Context

I am using Terraform v0.12.7, and I am not sure, which version is this docs updated for. I would request you to kindly update the Grafana_Alert docs [https://www.terraform.io/docs/providers/grafana/r/alert_notification.html] with the below provided. I have tested it out and its working seamlessly.

resource "grafana_alert_notification" "email_notification" {
name = "email_notification"
type = "email"
is_default = false

settings = {
addresses = "[email protected];[email protected]"
uploadImage = "false"
}
}

References

Idea from GitHub hashicorp/terraform#22095
It gave me idea to figure it out regarding the quotes, part which really helped me to rectify this.

Have errors from Grafana API print full response message

Hi there,

When are error occurs from the Grafana API, the full response message is not being printed to the terraform logs no matter the log level. This makes it very hard for users to understand why are error is occurring because we are only getting the response code and a top level message. Instead if this could print the whole response, then the user could resolve issue faster instead of having to recreate the API call manually.

Affected Resource(s)

All Grafana resources

Debug Output

Error: 422 422 Unprocessable Entity

Terraform apply fails if it can't hit the grafana front end

Summary

The way that terraform checks Grafana resources (e.g. a data source or a dashboard) relies on the front-end grafana API. This causes it to fail in cases where the resources themselves are actually fine, e.g. because the DNS record is currently down.

In my case, I was making a change that involved deleting and recreating an instance of Traefik in our Kubernetes cluster, which was responsible for routing to Grafana (among other things). I deleted our Traefik helm release, then ran terraform apply (in order to reinstate it) but was blocked because of the grafana resources timing out during the check.

Ideally, the check would not rely on front-end availability. If this isn't possible, providing some option to say "yeah, I was expecting that, please carry on and ignore those resources" would be acceptable. As things currently stand, I ended up:

  • Running terraform state rm to purge all the affected Grafana resources.
  • Running terraform apply to provision Traefik (which obviously then got errors trying to create grafana resources that actually already existed)
  • Manually resolved the conflict I had now created by deleting the whole grafana release and letting terraform reprovision it.

This was far from ideal!

Terraform Version

Terraform v0.11.13
+ provider.grafana v1.3.0

Affected Resource(s)

  • grafana_alert_notification
  • grafana_data_source
  • grafana_dashboard

Terraform Configuration Files

provider "grafana" {
  url  = "my_url"
  auth = "admin:${var.grafana_password}"
  version = "~> 1.3"
}

resource "grafana_data_source" "elasticsearch" {
  type          = "elasticsearch"
  name          = "elasticsearch"
  url           = "http://elasticsearch-master.elasticsearch:9200"
  is_default    = true
  depends_on    = ["helm_release.elasticsearch", "helm_release.grafana"]
}

resource "grafana_dashboard" "my_dashboard" {
  config_json   = "${file("my-dashboard.json")}"
  depends_on    = ["helm_release.elasticsearch", "helm_release.grafana"]
}

Debug Output

I've copied out a subset of the errors and redacted IPs/passwords etc, but you get the idea:

Error: Error refreshing state: 2 error(s) occurred:

* grafana_alert_notification.slack: 1 error(s) occurred:

* grafana_alert_notification.slack: grafana_alert_notification.slack: Get https://admin:<password>@my_url/api/alert-notifications/1: dial tcp <IP>:443: i/o timeout

* module.efk_prod.grafana_data_source.elasticsearch: 1 error(s) occurred:

* module.efk_prod.grafana_data_source.elasticsearch: grafana_data_source.elasticsearch: Get https://admin:<password>@my_url/api/datasources/1: dial tcp <IP>:443: i/o timeout

Expected Behavior

Terraform should have queried the grafana resources directly (not over the front-end connection) and found that all the resources were still fine.

Actual Behavior

Terraform checked the status of the various grafana resources by connecting via the frontend, which was down due to a deliberate config change being made to Traefik. These checks timed out and the terraform apply was aborted.

Steps to Reproduce

  1. Provision grafana with one of the listed resources (e.g. a data source).
  2. Do something that causes the front end to be unavailable (in my case, I deleted the traefik helm release used for routing, but you could also delete the relevant DNS record etc)
  3. Attempt to do a terraform apply - you're not able to because terraform times out trying to hit the invalid endpoint.

Grafana Dashboard doesn't support folder_id and org_id

Terraform Version

Terraform v0.11.2

  • provider.grafana v1.0.2

Affected Resource(s)

  • grafana_dashboard

Terraform Configuration Files

provider "grafana" {
}

data "template_file" "helloworld" {


  template = "${file("${path.module}/helloworld.json")}"

  vars {
    dashboard_name = "hello_world"
  }

}

resource "grafana_dashboard" "helloworld" {
  config_json = "${data.template_file.helloworld.rendered}"
  org_id = 1
  folder_id = axS1XHVmk
}

The code is working and the grafana dashboard will be created. But in wrong Grafana Organization and Folder because I'm not able to set following parameters:

  • org_id - ID of the Organisation in Grafana
  • folder_id - ID of Folder in Grafana Organization

I use a grafana version 5.2.1 (2040f61)

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. create a provider with Grafana and credentials
  2. terraform apply

Grafana Datasource Cloudwatch ARN missing attributes

Terraform Version

Terraform v0.11.2

  • provider.grafana v1.0.1

Affected Resource(s)

  • grafana_data_source

Terraform Configuration Files

resource "grafana_data_source" "dev_datasourcees" {

  name = "terraform-test"
  type = "cloudwatch"
  url = "arn:aws:iam:::role/myrole"
  access_mode = "proxy"

  basic_auth_enabled = false
  is_default = false

  json_data {
    auth_type = "arn"
    default_region = "eu-central-1"
  }

}

The code is working and the grafana datasource will be created but I'm not able to set the following parameters:

  • assumeRoleARN - Role which should be used
  • orgId - ID of the Organisation in Grafana
  • customMetrics - Namespaces of the Custom Metrics

image

I use a grafana version 4.6.3

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. create a provider with Grafana and credentials
  2. terraform apply

Document and support non-InfluxDB datasources

Hi - Thanks for your work here. It would be great if terraform-provider-grafana documented and supported additional data sources. I may be mistaken, but it appears terraform-provider-grafana only supports the InfluxDB datasource at present.

PagerDuty setting for grafana_alert_notification is coerced into an invalid value

While trying to set grafana_alert_notifications I ran into a problem with the setting for PagerDuty type setting of autoResolve being set to a value that didn't work for Grafana.

Terraform Version

0.11.7

Affected Resource(s)

  • grafana_alert_notification

Terraform Configuration Files

resource "grafana_alert_notification" "pagerduty" {
  name = "${var.service_name} - PagerDuty"
  type = "pagerduty"
  is_default = false

  settings {
    "integrationKey" = "${pagerduty_service_integration.grafana.integration_key}"
    "autoResolve" = true
  }
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Expected Behavior

The alert notification should have an enabled autoResolve.

Actual Behavior

The value in Grafana appears to be a "1" even when the HCL has true. This results in a defaulted false for the behavior. The "1" is stored in the Grafana DB (as relayed to me by a Grafana.com staff member.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Using hosted grafana.com

References

I'll add more debug information as I can gain access to it.

expand json_data field usage.

Data sources have more that already defined json_data. Elasticsearch have own set of variables, tlsSkipVerify also is not supported,

Grafana provider does not allow to add settings to the alert notification

This issue was originally opened by @edevost as hashicorp/terraform#24537. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.24
+ provider.aws v2.55.0
+ provider.grafana v1.5.0

Terraform Configuration Files

resource "grafana_alert_notification" "slack" {
  name = "Slack team"
  type = "slack"

  settings {
    slack = "xxx"
  }
}

Debug Output

Crash Output

Error: Unsupported block type

on main.tf line 39, in resource "grafana_alert_notification" "slack":
39: settings {

Blocks of type "settings" are not expected here. Did you mean to define
argument "settings"? If so, use the equals sign to assign it a value.

Expected Behavior

The alerting notification channel should be added.

Actual Behavior

Unexpected block "settings"

Steps to Reproduce

Additional Context

The config is taken straight from the Terraform documentation.

References

Creating a dashboard should use /api/dashboards/import

👋 Hi! Playing around with the module a bit, I noticed that attempting to create a dashboard with alerts preconfigured always returns a 422 Unprocesssable Entity. However, making the same dashboard without the alerts works as expected. The dashboard JSON with alerts is importable via the UI with no problem. I've tested this on Grafana 5.0.1 and 5.4.3, though it looks to be a continual (and undocumented) issue based on this closed issue. I'd propose that we switch this provider to use api/dashboards/import API as recommended in that issue.

I think this would be the intended use of that API since it has the same format and is specifically for uploading JSON dashboard configs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.