diff --git a/charts/k8s-monitoring/README.md b/charts/k8s-monitoring/README.md index d3a4d189b..2820a3ec8 100644 --- a/charts/k8s-monitoring/README.md +++ b/charts/k8s-monitoring/README.md @@ -146,6 +146,8 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely | externalServices.prometheus.processors.memoryLimiter.checkInterval | string | `"1s"` | How often to check memory usage. | | externalServices.prometheus.processors.memoryLimiter.enabled | bool | `false` | Use a memory limiter. | | externalServices.prometheus.processors.memoryLimiter.limit | string | `"0MiB"` | Maximum amount of memory targeted to be allocated by the process heap. | +| externalServices.prometheus.processors.transform.loki_resource_labels | string | `"pod, namespace, cluster, job"` | Comma-separated list of labels to be added to the Loki resource label set. | +| externalServices.prometheus.processors.transform.custom_log_statements | list | `[]` | Custom log statements to be added to the Loki resource label set. | | externalServices.prometheus.protocol | string | `"remote_write"` | The type of server protocol for writing metrics. Valid options: "remote_write" will use Prometheus Remote Write, "otlp" will use OTLP, "otlphttp" will use OTLP HTTP | | externalServices.prometheus.proxyURL | string | `""` | HTTP proxy to proxy requests to Prometheus through. | | externalServices.prometheus.queryEndpoint | string | `"/api/prom/api/v1/query"` | Prometheus metrics query endpoint. Preset for Grafana Cloud Metrics instances. | diff --git a/charts/k8s-monitoring/templates/agent_config/_processors.river.txt b/charts/k8s-monitoring/templates/agent_config/_processors.river.txt index 1d73c86ce..3c40461d4 100644 --- a/charts/k8s-monitoring/templates/agent_config/_processors.river.txt +++ b/charts/k8s-monitoring/templates/agent_config/_processors.river.txt @@ -69,8 +69,11 @@ otelcol.processor.transform "add_resource_attributes" { statements = [ "set(attributes[\"pod\"], attributes[\"k8s.pod.name\"])", "set(attributes[\"namespace\"], attributes[\"k8s.namespace.name\"])", - "set(attributes[\"loki.resource.labels\"], \"pod, namespace, cluster, job\")", + "set(attributes[\"loki.resource.labels\"], \"{{ .Values.externalServices.prometheus.processors.transform.loki_resource_labels }}\")", "set(attributes[\"k8s.cluster.name\"], \"{{ required ".Values.cluster.name is a required value. Please set it and try again." .Values.cluster.name }}\") where attributes[\"k8s.cluster.name\"] == nil", + {{- range $key, $value := .Values.externalServices.prometheus.processors.transform.custom_log_statements }} + "set(attributes[\"{{ $key }}\"], attributes[\"{{ $value }}\"])", + {{- end }} ] } {{- end }} diff --git a/charts/k8s-monitoring/values.schema.json b/charts/k8s-monitoring/values.schema.json index ba69ff2d5..3806b182d 100644 --- a/charts/k8s-monitoring/values.schema.json +++ b/charts/k8s-monitoring/values.schema.json @@ -185,6 +185,15 @@ "type": "string" } } + }, + "transform": { + "loki_resource_labels": "string", + "custom_log_statements": { + "type": "array", + "items": { + "type": "object" + } + } } } }, diff --git a/charts/k8s-monitoring/values.yaml b/charts/k8s-monitoring/values.yaml index 10a064968..5730e928d 100644 --- a/charts/k8s-monitoring/values.yaml +++ b/charts/k8s-monitoring/values.yaml @@ -83,6 +83,11 @@ externalServices: checkInterval: 1s # -- Maximum amount of memory targeted to be allocated by the process heap. limit: 0MiB + transform: + # -- Loki resource labels to add to metrics received via the OTLP or OTLP HTTP receivers. + loki_resource_labels: "pod, namespace, cluster, job" + # -- Custom log statements to add to metrics received via the OTLP or OTLP HTTP receivers. + custom_log_statements: [] # Write-Ahead Log (WAL) settings. Only applies when protocol is "remote_write" wal: