diff --git a/charts/feature-pod-logs/README.md b/charts/feature-pod-logs/README.md index 021398ac9c..78dacfb693 100644 --- a/charts/feature-pod-logs/README.md +++ b/charts/feature-pod-logs/README.md @@ -36,11 +36,21 @@ Actual integration testing in a live environment should be done in the main [k8s ## Values -### Logs Scrape: Pod Logs +### Log Processing + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| annotations | object | `{"job":"k8s.grafana.com/logs.job"}` | Log labels to set with values copied from the Kubernetes Pod annotations. Format: `: `. | +| extraLogProcessingStages | string | `""` | Stage blocks to be added to the loki.process component for pod logs. ([docs](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/#blocks)) This value is templated so that you can refer to other values from this file. | +| labels | object | `{"app_kubernetes_io_name":"app.kubernetes.io/name"}` | Log labels to set with values copied from the Kubernetes Pod labels. Format: `: `. | + +### Pod Discovery | Key | Type | Default | Description | |-----|------|---------|-------------| | excludeNamespaces | list | `[]` | Do not capture logs from any pods in these namespaces. | +| extraDiscoveryRules | string | `""` | Rules to filter pods for log gathering. Only used for "volumes" or "kubernetesApi" gather methods. | +| gatherMethod | string | `"volumes"` | The method to gather pod logs. Options are "volumes", "kubernetesApi", "OpenShiftClusterLogForwarder" (experimental). | | namespaces | list | `[]` | Only capture logs from pods in these namespaces (`[]` means all namespaces). | ### General settings @@ -55,11 +65,3 @@ Actual integration testing in a live environment should be done in the main [k8s | Key | Type | Default | Description | |-----|------|---------|-------------| | global.platform | string | `""` | The specific platform for this cluster. Will enable compatibility for some platforms. Supported options: (empty) or "openshift". | - -### Other Values - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| extraDiscoveryRules | string | `""` | Rules to filter pods for log gathering. Only used for "volumes" or "kubernetesApi" gather methods. | -| extraLogProcessingStages | string | `""` | Stage blocks to be added to the loki.process component for pod logs. ([docs](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/#blocks)) This value is templated so that you can refer to other values from this file. | -| gatherMethod | string | `"volumes"` | The method to gather pod logs. Options are "volumes", "kubernetesApi", "OpenShiftClusterLogForwarder" (experimental). | diff --git a/charts/feature-pod-logs/templates/_common_pod_discovery.alloy.tpl b/charts/feature-pod-logs/templates/_common_pod_discovery.alloy.tpl index 92fd6cc7cc..2969882d60 100644 --- a/charts/feature-pod-logs/templates/_common_pod_discovery.alloy.tpl +++ b/charts/feature-pod-logs/templates/_common_pod_discovery.alloy.tpl @@ -30,6 +30,20 @@ discovery.relabel "filtered_pods" { replacement = "$1" target_label = "job" } +{{- range $label, $podLabel := .Values.labels }} + rule { + source_labels = ["{{ include "pod_label" $podLabel }}"] + regex = "(.+)" + target_label = {{ $label | quote }} + } +{{- end }} +{{- range $label, $podAnnotation := .Values.annotations }} + rule { + source_labels = ["{{ include "pod_annotation" $podAnnotation }}"] + regex = "(.+)" + target_label = {{ $label | quote }} + } +{{- end }} // set the container runtime as a label rule { diff --git a/charts/feature-pod-logs/templates/_helpers.tpl b/charts/feature-pod-logs/templates/_helpers.tpl index 0de95d1cd1..0222e26759 100644 --- a/charts/feature-pod-logs/templates/_helpers.tpl +++ b/charts/feature-pod-logs/templates/_helpers.tpl @@ -15,3 +15,16 @@ If release name contains chart name it will be used as a full name. {{- end }} {{- end }} {{- end }} + +{{- define "escape_label" -}} +{{ . | replace "-" "_" | replace "." "_" | replace "/" "_" }} +{{- end }} + +{{- define "pod_label" -}} +{{ printf "__meta_kubernetes_pod_label_%s" (include "escape_label" .) }} +{{- end }} + +{{- define "pod_annotation" -}} +{{ printf "__meta_kubernetes_pod_annotation_%s" (include "escape_label" .) }} +{{- end }} + diff --git a/charts/feature-pod-logs/tests/default_test.yaml b/charts/feature-pod-logs/tests/default_test.yaml index 63b6c4cc47..dbe93a45d9 100644 --- a/charts/feature-pod-logs/tests/default_test.yaml +++ b/charts/feature-pod-logs/tests/default_test.yaml @@ -41,7 +41,17 @@ tests: replacement = "$1" target_label = "job" } - + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } + // set the container runtime as a label rule { action = "replace" diff --git a/charts/feature-pod-logs/values.schema.json b/charts/feature-pod-logs/values.schema.json index e22643ce40..9c59a97d5e 100644 --- a/charts/feature-pod-logs/values.schema.json +++ b/charts/feature-pod-logs/values.schema.json @@ -2,6 +2,14 @@ "$schema": "http://json-schema.org/schema#", "type": "object", "properties": { + "annotations": { + "type": "object", + "properties": { + "job": { + "type": "string" + } + } + }, "deployAsConfigMap": { "type": "boolean" }, @@ -32,6 +40,14 @@ } } }, + "labels": { + "type": "object", + "properties": { + "app_kubernetes_io_name": { + "type": "string" + } + } + }, "nameOverride": { "type": "string" }, diff --git a/charts/feature-pod-logs/values.yaml b/charts/feature-pod-logs/values.yaml index bd81d3ef51..7a5aab9727 100644 --- a/charts/feature-pod-logs/values.yaml +++ b/charts/feature-pod-logs/values.yaml @@ -13,22 +13,37 @@ global: platform: "" # -- The method to gather pod logs. Options are "volumes", "kubernetesApi", "OpenShiftClusterLogForwarder" (experimental). +# @section -- Pod Discovery gatherMethod: volumes # -- Only capture logs from pods in these namespaces (`[]` means all namespaces). -# @section -- Logs Scrape: Pod Logs +# @section -- Pod Discovery namespaces: [] # -- Do not capture logs from any pods in these namespaces. -# @section -- Logs Scrape: Pod Logs +# @section -- Pod Discovery excludeNamespaces: [] # -- Rules to filter pods for log gathering. Only used for "volumes" or "kubernetesApi" gather methods. +# @section -- Pod Discovery extraDiscoveryRules: "" +# -- Log labels to set with values copied from the Kubernetes Pod labels. +# Format: `: `. +# @section -- Log Processing +labels: + app_kubernetes_io_name: app.kubernetes.io/name + +# -- Log labels to set with values copied from the Kubernetes Pod annotations. +# Format: `: `. +# @section -- Log Processing +annotations: + job: k8s.grafana.com/logs.job + # -- Stage blocks to be added to the loki.process component for pod logs. # ([docs](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/#blocks)) # This value is templated so that you can refer to other values from this file. +# @section -- Log Processing extraLogProcessingStages: "" # @ignore diff --git a/charts/k8s-monitoring/Chart.lock b/charts/k8s-monitoring/Chart.lock index fb4ad4f9f5..611a87c842 100644 --- a/charts/k8s-monitoring/Chart.lock +++ b/charts/k8s-monitoring/Chart.lock @@ -42,4 +42,4 @@ dependencies: repository: https://grafana.github.io/helm-charts version: 0.10.0 digest: sha256:c42e09be38582ced6f973de7fd7d2f5d96c1e926e187936e0ee1d7ae295c9e0f -generated: "2024-11-19T10:59:04.581346-06:00" +generated: "2024-11-21T18:59:30.945426-06:00" diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-annotation-autodiscovery-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-annotation-autodiscovery-1.0.0.tgz index cd4660d611..99b4dc125f 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-annotation-autodiscovery-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-annotation-autodiscovery-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-application-observability-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-application-observability-1.0.0.tgz index 0904464bd0..750a809e0a 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-application-observability-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-application-observability-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-auto-instrumentation-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-auto-instrumentation-1.0.0.tgz index 6a77ae52af..6b67f2366a 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-auto-instrumentation-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-auto-instrumentation-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-cluster-events-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-cluster-events-1.0.0.tgz index fe4cb69d6b..8fe2824b1c 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-cluster-events-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-cluster-events-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-cluster-metrics-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-cluster-metrics-1.0.0.tgz index 3bbac97e03..2e840a2eeb 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-cluster-metrics-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-cluster-metrics-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-integrations-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-integrations-1.0.0.tgz index 35d830b55f..33a5bb037e 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-integrations-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-integrations-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-pod-logs-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-pod-logs-1.0.0.tgz index 055bd28253..925cc68070 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-pod-logs-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-pod-logs-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-profiling-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-profiling-1.0.0.tgz index 4c05fdb830..3b27d2653a 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-profiling-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-profiling-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/charts/k8s-monitoring-feature-prometheus-operator-objects-1.0.0.tgz b/charts/k8s-monitoring/charts/k8s-monitoring-feature-prometheus-operator-objects-1.0.0.tgz index f028023cc2..cc86426686 100644 Binary files a/charts/k8s-monitoring/charts/k8s-monitoring-feature-prometheus-operator-objects-1.0.0.tgz and b/charts/k8s-monitoring/charts/k8s-monitoring-feature-prometheus-operator-objects-1.0.0.tgz differ diff --git a/charts/k8s-monitoring/docs/examples/auth/bearer-token/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/auth/bearer-token/alloy-logs.alloy index 9783aec474..e5884606ce 100644 --- a/charts/k8s-monitoring/docs/examples/auth/bearer-token/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/auth/bearer-token/alloy-logs.alloy @@ -47,6 +47,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/auth/bearer-token/output.yaml b/charts/k8s-monitoring/docs/examples/auth/bearer-token/output.yaml index 97ab31e6e5..342e845581 100644 --- a/charts/k8s-monitoring/docs/examples/auth/bearer-token/output.yaml +++ b/charts/k8s-monitoring/docs/examples/auth/bearer-token/output.yaml @@ -270,6 +270,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/auth/embedded-secrets/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/auth/embedded-secrets/alloy-logs.alloy index 643718da8f..43afb85ecf 100644 --- a/charts/k8s-monitoring/docs/examples/auth/embedded-secrets/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/auth/embedded-secrets/alloy-logs.alloy @@ -47,6 +47,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/auth/embedded-secrets/output.yaml b/charts/k8s-monitoring/docs/examples/auth/embedded-secrets/output.yaml index c2ce52a89d..a6e121d543 100644 --- a/charts/k8s-monitoring/docs/examples/auth/embedded-secrets/output.yaml +++ b/charts/k8s-monitoring/docs/examples/auth/embedded-secrets/output.yaml @@ -259,6 +259,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/auth/external-secrets/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/auth/external-secrets/alloy-logs.alloy index 3659af42f5..91409b0b96 100644 --- a/charts/k8s-monitoring/docs/examples/auth/external-secrets/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/auth/external-secrets/alloy-logs.alloy @@ -59,6 +59,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/auth/external-secrets/output.yaml b/charts/k8s-monitoring/docs/examples/auth/external-secrets/output.yaml index a30afab414..fbd05582a0 100644 --- a/charts/k8s-monitoring/docs/examples/auth/external-secrets/output.yaml +++ b/charts/k8s-monitoring/docs/examples/auth/external-secrets/output.yaml @@ -279,6 +279,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/collector-storage/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/collector-storage/alloy-logs.alloy index 242f738e86..752171f216 100644 --- a/charts/k8s-monitoring/docs/examples/collector-storage/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/collector-storage/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/collector-storage/output.yaml b/charts/k8s-monitoring/docs/examples/collector-storage/output.yaml index fe91aace4a..0a32e7c8ec 100644 --- a/charts/k8s-monitoring/docs/examples/collector-storage/output.yaml +++ b/charts/k8s-monitoring/docs/examples/collector-storage/output.yaml @@ -483,6 +483,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/extra-rules/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/extra-rules/alloy-logs.alloy index 2a238b2df0..4bc4dac961 100644 --- a/charts/k8s-monitoring/docs/examples/extra-rules/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/extra-rules/alloy-logs.alloy @@ -48,6 +48,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/extra-rules/output.yaml b/charts/k8s-monitoring/docs/examples/extra-rules/output.yaml index 1a8ba2181c..5e7b6d4d93 100644 --- a/charts/k8s-monitoring/docs/examples/extra-rules/output.yaml +++ b/charts/k8s-monitoring/docs/examples/extra-rules/output.yaml @@ -635,6 +635,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/features/cluster-metrics/control-plane-monitoring/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/features/cluster-metrics/control-plane-monitoring/alloy-logs.alloy index 9b40fe8f0d..e36694cf60 100644 --- a/charts/k8s-monitoring/docs/examples/features/cluster-metrics/control-plane-monitoring/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/features/cluster-metrics/control-plane-monitoring/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/features/cluster-metrics/control-plane-monitoring/output.yaml b/charts/k8s-monitoring/docs/examples/features/cluster-metrics/control-plane-monitoring/output.yaml index e519158bd7..ae87148dca 100644 --- a/charts/k8s-monitoring/docs/examples/features/cluster-metrics/control-plane-monitoring/output.yaml +++ b/charts/k8s-monitoring/docs/examples/features/cluster-metrics/control-plane-monitoring/output.yaml @@ -733,6 +733,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/features/integrations/mysql/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/features/integrations/mysql/alloy-logs.alloy index d7a2d575d6..bc45555dad 100644 --- a/charts/k8s-monitoring/docs/examples/features/integrations/mysql/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/features/integrations/mysql/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/features/integrations/mysql/output.yaml b/charts/k8s-monitoring/docs/examples/features/integrations/mysql/output.yaml index 2c985e9df4..169507378b 100644 --- a/charts/k8s-monitoring/docs/examples/features/integrations/mysql/output.yaml +++ b/charts/k8s-monitoring/docs/examples/features/integrations/mysql/output.yaml @@ -261,6 +261,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/features/pod-logs/default/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/features/pod-logs/default/alloy-logs.alloy index 5745608167..a1855ab6a4 100644 --- a/charts/k8s-monitoring/docs/examples/features/pod-logs/default/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/features/pod-logs/default/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/features/pod-logs/default/output.yaml b/charts/k8s-monitoring/docs/examples/features/pod-logs/default/output.yaml index fc10d5a044..28f5b3282b 100644 --- a/charts/k8s-monitoring/docs/examples/features/pod-logs/default/output.yaml +++ b/charts/k8s-monitoring/docs/examples/features/pod-logs/default/output.yaml @@ -71,6 +71,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/platforms/azure-aks/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/platforms/azure-aks/alloy-logs.alloy index 197848bd3d..57885aa730 100644 --- a/charts/k8s-monitoring/docs/examples/platforms/azure-aks/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/platforms/azure-aks/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/platforms/azure-aks/output.yaml b/charts/k8s-monitoring/docs/examples/platforms/azure-aks/output.yaml index bae61678a7..8e080d8119 100644 --- a/charts/k8s-monitoring/docs/examples/platforms/azure-aks/output.yaml +++ b/charts/k8s-monitoring/docs/examples/platforms/azure-aks/output.yaml @@ -584,6 +584,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/platforms/eks-fargate/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/platforms/eks-fargate/alloy-logs.alloy index 300431f949..d985c2f2e4 100644 --- a/charts/k8s-monitoring/docs/examples/platforms/eks-fargate/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/platforms/eks-fargate/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/platforms/eks-fargate/output.yaml b/charts/k8s-monitoring/docs/examples/platforms/eks-fargate/output.yaml index 088e2dd25e..59de138f7f 100644 --- a/charts/k8s-monitoring/docs/examples/platforms/eks-fargate/output.yaml +++ b/charts/k8s-monitoring/docs/examples/platforms/eks-fargate/output.yaml @@ -532,6 +532,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/platforms/gke-autopilot/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/platforms/gke-autopilot/alloy-logs.alloy index 73c0498a13..50acf1f18d 100644 --- a/charts/k8s-monitoring/docs/examples/platforms/gke-autopilot/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/platforms/gke-autopilot/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/platforms/gke-autopilot/output.yaml b/charts/k8s-monitoring/docs/examples/platforms/gke-autopilot/output.yaml index 37f690a48a..e26b09e1b8 100644 --- a/charts/k8s-monitoring/docs/examples/platforms/gke-autopilot/output.yaml +++ b/charts/k8s-monitoring/docs/examples/platforms/gke-autopilot/output.yaml @@ -532,6 +532,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/platforms/openshift/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/platforms/openshift/alloy-logs.alloy index 2b9e71872d..422f664cb4 100644 --- a/charts/k8s-monitoring/docs/examples/platforms/openshift/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/platforms/openshift/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/platforms/openshift/output.yaml b/charts/k8s-monitoring/docs/examples/platforms/openshift/output.yaml index 5a92ba5f0d..77dda0f245 100644 --- a/charts/k8s-monitoring/docs/examples/platforms/openshift/output.yaml +++ b/charts/k8s-monitoring/docs/examples/platforms/openshift/output.yaml @@ -638,6 +638,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/private-image-registries/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/private-image-registries/alloy-logs.alloy index 90bfd9d515..faeba60f5d 100644 --- a/charts/k8s-monitoring/docs/examples/private-image-registries/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/private-image-registries/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/private-image-registries/output.yaml b/charts/k8s-monitoring/docs/examples/private-image-registries/output.yaml index 3c87e89830..b0b44d1c82 100644 --- a/charts/k8s-monitoring/docs/examples/private-image-registries/output.yaml +++ b/charts/k8s-monitoring/docs/examples/private-image-registries/output.yaml @@ -489,6 +489,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/proxies/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/proxies/alloy-logs.alloy index 25c2e752b4..9af103b29e 100644 --- a/charts/k8s-monitoring/docs/examples/proxies/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/proxies/alloy-logs.alloy @@ -46,6 +46,16 @@ declare "pod_logs" { replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule { diff --git a/charts/k8s-monitoring/docs/examples/proxies/output.yaml b/charts/k8s-monitoring/docs/examples/proxies/output.yaml index f1c5862278..493ecef658 100644 --- a/charts/k8s-monitoring/docs/examples/proxies/output.yaml +++ b/charts/k8s-monitoring/docs/examples/proxies/output.yaml @@ -620,6 +620,16 @@ data: replacement = "$1" target_label = "job" } + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + regex = "(.+)" + target_label = "app_kubernetes_io_name" + } + rule { + source_labels = ["__meta_kubernetes_pod_annotation_k8s_grafana_com_logs_job"] + regex = "(.+)" + target_label = "job" + } // set the container runtime as a label rule {