|
| 1 | +# Copyright The OpenTelemetry Authors |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +# Helm values override for testing the experimental Prometheus info() function |
| 5 | +# This configuration uses Prometheus v3.10.0+ with the info() function fix |
| 6 | +# and removes workaround resource attribute promotions. |
| 7 | +# |
| 8 | +# Usage: |
| 9 | +# helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts |
| 10 | +# helm repo update |
| 11 | +# helm install opentelemetry-demo open-telemetry/opentelemetry-demo \ |
| 12 | +# --namespace otel-demo --create-namespace \ |
| 13 | +# -f kubernetes/values-info-function.yaml |
| 14 | +# |
| 15 | +# Note: This requires Prometheus v3.10.0+ which includes the info() function fix. |
| 16 | +# See https://github.com/prometheus/prometheus/pull/17817 |
| 17 | + |
| 18 | +# OTel Collector configuration overrides |
| 19 | +opentelemetry-collector: |
| 20 | + config: |
| 21 | + processors: |
| 22 | + # Don't override host.name from the original service with the collector's hostname |
| 23 | + resourcedetection: |
| 24 | + detectors: [env, system] |
| 25 | + override: false |
| 26 | + # Set host.name from k8s.pod.name since the resourcedetection processor |
| 27 | + # would otherwise set it to the collector's hostname. |
| 28 | + # Also preserve the existing service.instance.id setting from the chart. |
| 29 | + resource: |
| 30 | + attributes: |
| 31 | + - key: service.instance.id |
| 32 | + from_attribute: k8s.pod.uid |
| 33 | + action: insert |
| 34 | + - key: host.name |
| 35 | + from_attribute: k8s.pod.name |
| 36 | + action: upsert |
| 37 | + # Add metric_statements to the transform processor for info() support: |
| 38 | + # 1. Set service.name for PostgreSQL receiver metrics (which lack it) |
| 39 | + # 2. Construct unique service.instance.id per PostgreSQL resource scope |
| 40 | + # to prevent duplicate target_info entries |
| 41 | + # 3. Set default service.instance.id for any service missing it |
| 42 | + # Add metric_statements to the transform processor for info() support: |
| 43 | + # 1. Drop attributes that k8sattributes adds inconsistently across resource |
| 44 | + # scopes, which causes duplicate target_info entries with the same |
| 45 | + # identifying labels but different non-identifying attributes |
| 46 | + # 2. Set service.name for PostgreSQL receiver metrics (which lack it) |
| 47 | + # 3. Construct unique service.instance.id per PostgreSQL resource scope |
| 48 | + # to prevent duplicate target_info entries |
| 49 | + # 4. Set default service.instance.id for any service missing it |
| 50 | + transform: |
| 51 | + metric_statements: |
| 52 | + - context: resource |
| 53 | + statements: |
| 54 | + - delete_key(attributes, "container.id") |
| 55 | + - delete_key(attributes, "process.command") |
| 56 | + - delete_key(attributes, "process.pid") |
| 57 | + - delete_key(attributes, "process.runtime.description") |
| 58 | + - delete_key(attributes, "process.runtime.name") |
| 59 | + - delete_key(attributes, "process.runtime.version") |
| 60 | + - delete_key(attributes, "telemetry.sdk.language") |
| 61 | + - delete_key(attributes, "telemetry.sdk.name") |
| 62 | + - delete_key(attributes, "telemetry.sdk.version") |
| 63 | + - >- |
| 64 | + set(attributes["service.name"], "postgresql") |
| 65 | + where attributes["service.name"] == nil |
| 66 | + and attributes["postgresql.database.name"] != nil |
| 67 | + - >- |
| 68 | + set(attributes["service.instance.id"], |
| 69 | + Concat([attributes["service.name"], "/", |
| 70 | + attributes["postgresql.database.name"], "/", |
| 71 | + attributes["postgresql.table.name"], "/", |
| 72 | + attributes["postgresql.index.name"]], "")) |
| 73 | + where attributes["service.name"] == "postgresql" |
| 74 | + and attributes["postgresql.index.name"] != nil |
| 75 | + - >- |
| 76 | + set(attributes["service.instance.id"], |
| 77 | + Concat([attributes["service.name"], "/", |
| 78 | + attributes["postgresql.database.name"], "/", |
| 79 | + attributes["postgresql.table.name"]], "")) |
| 80 | + where attributes["service.name"] == "postgresql" |
| 81 | + and attributes["postgresql.table.name"] != nil |
| 82 | + and attributes["postgresql.index.name"] == nil |
| 83 | + - >- |
| 84 | + set(attributes["service.instance.id"], |
| 85 | + Concat([attributes["service.name"], "/", |
| 86 | + attributes["postgresql.database.name"]], "")) |
| 87 | + where attributes["service.name"] == "postgresql" |
| 88 | + and attributes["postgresql.database.name"] != nil |
| 89 | + and attributes["postgresql.table.name"] == nil |
| 90 | + - >- |
| 91 | + set(attributes["service.instance.id"], |
| 92 | + attributes["service.name"]) |
| 93 | + where attributes["service.instance.id"] == nil |
| 94 | + and attributes["service.name"] != nil |
| 95 | + service: |
| 96 | + pipelines: |
| 97 | + metrics: |
| 98 | + processors: [k8sattributes, memory_limiter, resourcedetection, resource, transform, batch] |
| 99 | + |
| 100 | +prometheus: |
| 101 | + server: |
| 102 | + # Use Prometheus v3.10.0+ which includes the info() function bug fix |
| 103 | + # (https://github.com/prometheus/prometheus/pull/17817) |
| 104 | + image: |
| 105 | + repository: quay.io/prometheus/prometheus |
| 106 | + tag: v3.11.1 |
| 107 | + |
| 108 | + # Enable experimental PromQL functions including info() |
| 109 | + extraFlags: |
| 110 | + - "enable-feature=exemplar-storage" |
| 111 | + - "enable-feature=promql-experimental-functions" |
| 112 | + - "web.enable-otlp-receiver" |
| 113 | + |
| 114 | + # OTLP receiver configuration |
| 115 | + # Resource attributes are NOT promoted to labels on metrics. |
| 116 | + # Instead, use the experimental info() PromQL function to enrich metrics with |
| 117 | + # labels from target_info at query time. This reduces label cardinality while |
| 118 | + # still allowing access to resource attributes in queries. |
| 119 | + otlp: |
| 120 | + keep_identifying_resource_attributes: true |
| 121 | + promote_resource_attributes: |
| 122 | + # Kafka resource attributes produced by the OTel Collector Kafka receiver |
| 123 | + # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/kafkametricsreceiver |
| 124 | + - kafka.cluster.alias |
| 125 | + |
| 126 | + # See https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.142.0/connector/spanmetricsconnector/README.md#known-limitation-the-single-writer-principle |
| 127 | + - collector.instance.id |
| 128 | + |
| 129 | + # host.name is needed for system/host metrics from the hostmetrics receiver, |
| 130 | + # which cannot use info() because they lack service.name to match target_info. |
| 131 | + - host.name |
| 132 | + |
| 133 | + # Allow out-of-order ingestion for metrics that may arrive late |
| 134 | + tsdb: |
| 135 | + out_of_order_time_window: 30m |
| 136 | + |
| 137 | +# Grafana configuration with custom dashboards |
| 138 | +grafana: |
| 139 | + # Enable the sidecar to load dashboards from ConfigMaps |
| 140 | + sidecar: |
| 141 | + dashboards: |
| 142 | + enabled: true |
| 143 | + # Label that ConfigMaps must have to be picked up |
| 144 | + label: grafana_dashboard |
| 145 | + # Search in all namespaces |
| 146 | + searchNamespace: ALL |
| 147 | + |
| 148 | + # Dashboard providers configuration |
| 149 | + dashboardProviders: |
| 150 | + dashboardproviders.yaml: |
| 151 | + apiVersion: 1 |
| 152 | + providers: |
| 153 | + - name: 'custom' |
| 154 | + orgId: 1 |
| 155 | + folder: 'Custom' |
| 156 | + type: file |
| 157 | + disableDeletion: false |
| 158 | + editable: true |
| 159 | + options: |
| 160 | + path: /var/lib/grafana/dashboards/custom |
| 161 | + |
| 162 | +# Note: The APM and PostgreSQL dashboards with info() function queries |
| 163 | +# need to be deployed as ConfigMaps. See the dashboards in: |
| 164 | +# - src/grafana/provisioning/dashboards/demo/apm-dashboard.json |
| 165 | +# - src/grafana/provisioning/dashboards/demo/postgresql-dashboard.json |
| 166 | +# |
| 167 | +# To deploy them, create ConfigMaps like: |
| 168 | +# |
| 169 | +# kubectl create configmap apm-dashboard \ |
| 170 | +# --from-file=apm-dashboard.json=src/grafana/provisioning/dashboards/demo/apm-dashboard.json \ |
| 171 | +# -n otel-demo |
| 172 | +# kubectl label configmap apm-dashboard grafana_dashboard=1 -n otel-demo |
| 173 | +# |
| 174 | +# kubectl create configmap postgresql-dashboard \ |
| 175 | +# --from-file=postgresql-dashboard.json=src/grafana/provisioning/dashboards/demo/postgresql-dashboard.json \ |
| 176 | +# -n otel-demo |
| 177 | +# kubectl label configmap postgresql-dashboard grafana_dashboard=1 -n otel-demo |
0 commit comments