terraform-provider-grafana icon indicating copy to clipboard operation
terraform-provider-grafana copied to clipboard

`grafana_synthetic_monitoring_probe` could not get labels

Open anhdle14 opened this issue 3 years ago • 6 comments

Terraform Version

  • Terraform: 1.2.0
  • Terraform Grafana Provider: 1.24.0
  • Grafana: 8.0+

Affected Resource(s)

Please list the resources as a list, for example:

  • grafana_synthetic_monitoring_probe
  • data.grafana_synthetic_monitoring_probes

Terraform Configuration Files

data "grafana_synthetic_monitoring_probes" "this" {}

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.

  • Running from CI so if you need I can show the output later.

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?

  • No issues

Actual Behavior

What actually happened?

│ Error: probe list request: status="500 Internal Server Error", msg="status: Internal Server Error, error: loading probe 2432: extracting probe labels: extracting label "0": expected name=value", err="loading probe 2432: extracting probe labels: extracting label "0": expected name=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? N/A

References

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

anhdle14 avatar Jul 01 '22 04:07 anhdle14

This one looks like something we need to fix in the terraform provider.

It seems like it's passing invalid labels to the API.

mem avatar Jul 14 '22 20:07 mem

I tried a test here: https://github.com/grafana/terraform-provider-grafana/pull/573 and I couldn't reproduce it. Do you have a custom probe? And if so can you post its configuration here?

julienduchesne avatar Aug 01 '22 16:08 julienduchesne

@julienduchesne yes I am using private probes right now. It is a little bit complex but can be summarized with this one.

# terraform.tfvars
probes = [
  {
    name      = probe.name
    latitude  = probe.latitude
    longitude = probe.longitude
    region    = probe.region

    uuid       = probe.uuid
    alt_region = lookup( # convert AZ to Region via probe's name.
      {
        "aws" = substr(regex("(.*)_(.*)_(.*)", probe.name)[2], 0, length(regex("(.*)_(.*)_(.*)", probe.name)[2]) - 1)
        "gcp" = substr(regex("(.*)_(.*)_(.*)", probe.name)[2], 0, length(regex("(.*)_(.*)_(.*)", probe.name)[2]) - 2)
      },
      regex("(.*)_(.*)_(.*)", probe.name)[1], probe.region
    )
  },
  ...
]

# main.tf
resource "grafana_synthetic_monitoring_probe" "private" {
  for_each = { for probe in var.probes : probe.name => probe }

  name      = lower(each.value.name)
  latitude  = each.value.latitude
  longitude = each.value.longitude
  region    = each.value.region
  public    = false # Private probe is not public by default
  labels = merge(each.value.labels, {
    "uuid"       = each.value.uuid
    "alt_region" = each.value.alt_region
  })

  lifecycle {
    create_before_destroy = true
  }
}

anhdle14 avatar Aug 02 '22 08:08 anhdle14

Hey @anhdle14. This is probably caused by a comma in your label's value. The API has a bit of trouble with it. It will be fixed, but in the meantime, if you sanitize your label value, it should work. Let me know if that helps!

julienduchesne avatar Aug 03 '22 18:08 julienduchesne

Hey @julienduchesne, we do not have comma or custom characters anywhere I think, except for _ and -. So I am not sure how to fix.

anhdle14 avatar Aug 06 '22 01:08 anhdle14

Do you still have the issue? I believe a fix was implemented on the API side

julienduchesne avatar Aug 25 '22 13:08 julienduchesne

Right, we recently deployed a new version of the API that addresses this.

mem avatar Aug 29 '22 15:08 mem

I'll close this until there is confirmation that this is still happening. Feel free to reopen!

julienduchesne avatar Aug 30 '22 12:08 julienduchesne

Sorry, it is fixed now. Thank you for the support ^^!

anhdle14 avatar Sep 02 '22 02:09 anhdle14

No worries. Thanks for reporting!

julienduchesne avatar Sep 02 '22 02:09 julienduchesne