From a87ec9ed12e5e140ff1048262c7eee5a5e45148e Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Wed, 8 May 2024 11:35:38 -0700 Subject: [PATCH] [exporter/prometheus] add with_resource_constant_labels (#67) This add support for the following from the spec: > A Prometheus Exporter MAY offer configuration to add > resource attributes as metric attributes. By default, > it MUST NOT add any resource attributes as metric > attributes. The configuration SHOULD allow the user > to select which resource attributes to copy (e.g. > include / exclude or regular expression based). Copied > Resource attributes MUST NOT be excluded from target_info. Signed-off-by: Alex Boten Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> --- examples/kitchen-sink.yaml | 8 ++++++++ schema/common.json | 18 ++++++++++++++++++ schema/meter_provider.json | 3 +++ 3 files changed, 29 insertions(+) diff --git a/examples/kitchen-sink.yaml b/examples/kitchen-sink.yaml index 65ee8f2..e9758ac 100644 --- a/examples/kitchen-sink.yaml +++ b/examples/kitchen-sink.yaml @@ -134,6 +134,14 @@ meter_provider: without_type_suffix: false # Configure Prometheus Exporter to produce metrics without a scope info metric. without_scope_info: false + # Configure Prometheus Exporter to add resource attributes as metrics attributes. + with_resource_constant_labels: + # Configure resource attributes to be included, in this example attributes starting with service. + included: + - "service*" + # Configure resource attributes to be excluded, in this example attribute service.attr1. + excluded: + - "service.attr1" # Configure a periodic metric reader. - periodic: # Configure delay interval (in milliseconds) between start of two consecutive exports. diff --git a/schema/common.json b/schema/common.json index 48d48a0..8c488e8 100644 --- a/schema/common.json +++ b/schema/common.json @@ -13,6 +13,24 @@ } } }, + "IncludeExclude": { + "type": "object", + "additionalProperties": false, + "properties": { + "included": { + "type": "array", + "items": { + "type": "string" + } + }, + "excluded": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "Otlp": { "type": "object", "additionalProperties": false, diff --git a/schema/meter_provider.json b/schema/meter_provider.json index 7313ae0..e53372e 100644 --- a/schema/meter_provider.json +++ b/schema/meter_provider.json @@ -93,6 +93,9 @@ }, "without_scope_info": { "type": "boolean" + }, + "with_resource_constant_labels": { + "$ref": "common.json#/$defs/IncludeExclude" } } },