From 57036c5536837bfc2d83bbe4f18eae9ffff5ab2d Mon Sep 17 00:00:00 2001 From: Kristof Gyuracz Date: Tue, 7 May 2024 13:43:50 +0200 Subject: [PATCH 1/2] fix: install tagged image on kustomize install instead of latest Signed-off-by: Kristof Gyuracz --- config/manager/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 12146439..b5e16507 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -5,4 +5,4 @@ kind: Kustomization images: - name: controller newName: ghcr.io/kube-logging/telemetry-controller - newTag: latest + newTag: 0.0.4 From b31f899955fe4664153bbedf54715d32fcec9993 Mon Sep 17 00:00:00 2001 From: Kristof Gyuracz Date: Tue, 7 May 2024 14:13:31 +0200 Subject: [PATCH 2/2] feat(metrics): insert metric lables to enable streamlined filtering Signed-off-by: Kristof Gyuracz --- .../otel_col_conf_test_fixtures/complex.yaml | 21 ++++++++++-- .../controller/telemetry/otel_conf_gen.go | 34 +++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/internal/controller/telemetry/otel_col_conf_test_fixtures/complex.yaml b/internal/controller/telemetry/otel_col_conf_test_fixtures/complex.yaml index c7e6c8ed..86a83d95 100644 --- a/internal/controller/telemetry/otel_col_conf_test_fixtures/complex.yaml +++ b/internal/controller/telemetry/otel_col_conf_test_fixtures/complex.yaml @@ -158,6 +158,23 @@ processors: - action: insert key: loki.attribute.labels value: tenant + attributes/metricattributes: + actions: + - action: insert + key: app + from_attribute: k8s.pod.labels.app.kubernetes.io/name + - action: insert + key: host + from_attribute: k8s.node.name + - action: insert + key: namespace + from_attribute: k8s.namespace.name + - action: insert + key: container + from_attribute: k8s.container.name + - action: insert + key: pod + from_attribute: k8s.pod.name attributes/subscription_subscription-example-1: actions: - action: insert @@ -304,9 +321,9 @@ service: exporters: [routing/subscription_example-tenant-b-ns_subscription-example-3_outputs] metrics/output: receivers: [count/output_metrics] - processors: [memory_limiter, deltatocumulative] + processors: [memory_limiter, deltatocumulative, attributes/metricattributes] exporters: [prometheus/message_metrics_exporter] metrics/tenant: receivers: [count/tenant_metrics] - processors: [memory_limiter, deltatocumulative] + processors: [memory_limiter, deltatocumulative, attributes/metricattributes] exporters: [prometheus/message_metrics_exporter] diff --git a/internal/controller/telemetry/otel_conf_gen.go b/internal/controller/telemetry/otel_conf_gen.go index 48cc75a7..7e8dfafb 100644 --- a/internal/controller/telemetry/otel_conf_gen.go +++ b/internal/controller/telemetry/otel_conf_gen.go @@ -522,6 +522,36 @@ func generateMetricsProcessors() map[string]any { metricsProcessors["deltatocumulative"] = DeltatoCumulativeConfig{} + metricsProcessors["attributes/metricattributes"] = AttributesProcessor{ + Actions: []AttributesProcessorAction{ + { + Action: "insert", + Key: "app", + FromAttribute: "k8s.pod.labels.app.kubernetes.io/name", + }, + { + Action: "insert", + Key: "host", + FromAttribute: "k8s.node.name", + }, + { + Action: "insert", + Key: "namespace", + FromAttribute: "k8s.namespace.name", + }, + { + Action: "insert", + Key: "container", + FromAttribute: "k8s.container.name", + }, + { + Action: "insert", + Key: "pod", + FromAttribute: "k8s.pod.name", + }, + }, + } + return metricsProcessors } @@ -654,13 +684,13 @@ func generateMetricsPipelines() map[string]Pipeline { metricsPipelines["metrics/tenant"] = Pipeline{ Receivers: []string{"count/tenant_metrics"}, - Processors: []string{"deltatocumulative"}, + Processors: []string{"deltatocumulative", "attributes/metricattributes"}, Exporters: []string{"prometheus/message_metrics_exporter"}, } metricsPipelines["metrics/output"] = Pipeline{ Receivers: []string{"count/output_metrics"}, - Processors: []string{"deltatocumulative"}, + Processors: []string{"deltatocumulative", "attributes/metricattributes"}, Exporters: []string{"prometheus/message_metrics_exporter"}, }