From cefc7cc989c2b4f319b58051d6f54dcbe0ff5b2d Mon Sep 17 00:00:00 2001 From: Andrew Dryga Date: Thu, 14 Sep 2023 01:22:52 -0600 Subject: [PATCH] Make sure metrics are not rejected due to reserved naming --- .../relay-app/templates/cloud-init.yaml | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/terraform/modules/relay-app/templates/cloud-init.yaml b/terraform/modules/relay-app/templates/cloud-init.yaml index d7438b896..132a19640 100644 --- a/terraform/modules/relay-app/templates/cloud-init.yaml +++ b/terraform/modules/relay-app/templates/cloud-init.yaml @@ -27,6 +27,24 @@ write_files: resourcedetection: detectors: [gcp] timeout: 10s + transform: + # "location", "cluster", "namespace", "job", "instance", and "project_id" are reserved, and + # metrics containing these labels will be rejected. Prefix them with exported_ to prevent this. + metric_statements: + - context: datapoint + statements: + - set(attributes["exported_location"], attributes["location"]) + - delete_key(attributes, "location") + - set(attributes["exported_cluster"], attributes["cluster"]) + - delete_key(attributes, "cluster") + - set(attributes["exported_namespace"], attributes["namespace"]) + - delete_key(attributes, "namespace") + - set(attributes["exported_job"], attributes["job"]) + - delete_key(attributes, "job") + - set(attributes["exported_instance"], attributes["instance"]) + - delete_key(attributes, "instance") + - set(attributes["exported_project_id"], attributes["project_id"]) + - delete_key(attributes, "project_id") service: pipelines: traces: @@ -35,7 +53,7 @@ write_files: exporters: [googlecloud] metrics: receivers: [otlp] - processors: [memory_limiter, batch] + processors: [memory_limiter, batch, transform] exporters: [googlecloud] logs: receivers: [otlp]