Skip to content

coralogix_events2metric could overwrite internal event2metrics #421

@aelmekeev

Description

@aelmekeev

Affected Resource(s)

  • coralogix_events2metric

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

locals {
  only_count_aggregation = merge({ for agg in ["min", "max", "avg", "sum"] : agg => { enable = false } }, {
    samples = { type = "Max", enable = false }
  })
}

resource "coralogix_events2metric" "pass" {
  name        = "checkly_check_pass"
  description = "Count of passed Checkly synthetics checks"

  spans_query = {
    lucene       = "tags.checkly.check.status:\"PASSED\""
    applications = ["checkly-browser-check", "checkly-multistep-check"]
  }

  metric_fields = {
    checkly_check_pass = {
      source_field = "duration"
      aggregations = local.only_count_aggregation
    },
  }

  metric_labels = {
    check_name = "tags.checkly.check.name"
  }

  permutations = {
    limit = 1000
  }
}

Expected Behavior

Terraform creates new events2metrics.

Actual Behavior

Terraform tries to override existing internal events2metrics:

  # module.synthetics[0].coralogix_events2metric.pass must be replaced
-/+ resource "coralogix_events2metric" "pass" {
      ~ description   = "faas executions" -> "Count of passed Checkly synthetics checks"
      ~ id            = "47f71b88-42e3-4e99-879c-c62324fa07bc" -> (known after apply)
      - logs_query    = {
          - lucene     = "platform_event_type:\"runtime_done\" AND _exists_:cx_metadata.faas_id" -> null
          - severities = [
              - "Error",
              - "Info",
            ] -> null
        } -> null
      + metric_fields = {
          + "checkly_check_pass" = {
              + aggregations = {
                  + avg       = {
                      + enable             = false
                      + target_metric_name = (known after apply)
                    }
                  + count     = (known after apply)
                  + histogram = (known after apply)
                  + max       = {
                      + enable             = false
                      + target_metric_name = (known after apply)
                    }
                  + min       = {
                      + enable             = false
                      + target_metric_name = (known after apply)
                    }
                  + samples   = {
                      + enable             = false
                      + target_metric_name = (known after apply)
                      + type               = "Max"
                    }
                  + sum       = {
                      + enable             = false
                      + target_metric_name = (known after apply)
                    }
                }
              + source_field = "duration"
            },
        }
      ~ metric_labels = {
          + "check_name" = "tags.checkly.check.name"
          - "faas_id"    = "cx_metadata.faas_id" -> null
        }
      ~ name          = "cx_serverless_runtime_done" -> "checkly_check_pass"
      ~ permutations  = {
          ~ has_exceed_limit = false -> (known after apply)
          ~ limit            = 5000 -> 1000
        }
      + spans_query   = {
          + applications = [
              + "checkly-browser-check",
              + "checkly-multistep-check",
            ]
          + lucene       = "tags.checkly.check.status:\"PASSED\""
        }
    }

Steps to Reproduce

  1. Modify the provided example by changing metric_fields key from checkly_check_duration to any existing metric (non internal)
  2. terraform apply - it will fail with Error creating Events2Metric
  3. subsequent terraform apply will show an attempt to override existing events2metrics

It looks like during failed apply "random" resource somehow get imported in the state.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions