diff --git a/charts/k8s-monitoring/charts/feature-pod-logs/README.md b/charts/k8s-monitoring/charts/feature-pod-logs/README.md index 848c64a20e..58f91b3597 100644 --- a/charts/k8s-monitoring/charts/feature-pod-logs/README.md +++ b/charts/k8s-monitoring/charts/feature-pod-logs/README.md @@ -53,7 +53,7 @@ Be sure perform actual integration testing in a live environment in the main [k8 | namespaceAnnotations | object | `{}` | Log labels to set with values copied from the Kubernetes Namespace annotations. Only used for "filelog" gather method. Format: `: `. | | namespaceLabels | object | `{}` | Log labels to set with values copied from the Kubernetes Namespace labels. Only used for "filelog" gather method. Format: `: `. | | nodeAnnotations | object | `{}` | Log labels to set with values copied from the Kubernetes Node annotations. Only used for "filelog" gather method. Format: `: `. | -| nodeLabels | object | `{}` | Log labels to set with values copied from the Kubernetes Node labels. Only used for "filelog" gather method. Format: `: `. | +| nodeLabels | object | `{}` | Log labels to set with values copied from the Kubernetes Node labels. Format: `: `. | | staticLabels | object | `{}` | Log labels to set with static values. | | staticLabelsFrom | object | `{}` | Log labels to set with static values, not quoted so it can reference config components. | diff --git a/charts/k8s-monitoring/charts/feature-pod-logs/templates/_nodes_common.tpl b/charts/k8s-monitoring/charts/feature-pod-logs/templates/_nodes_common.tpl index d4b6a05916..ac130328dd 100644 --- a/charts/k8s-monitoring/charts/feature-pod-logs/templates/_nodes_common.tpl +++ b/charts/k8s-monitoring/charts/feature-pod-logs/templates/_nodes_common.tpl @@ -7,6 +7,7 @@ {{- $attachMetadata = or $attachMetadata .Values.nodeLabels.nodeOS -}} {{- $attachMetadata = or $attachMetadata .Values.nodeLabels.nodeArchitecture -}} {{- $attachMetadata = or $attachMetadata .Values.nodeLabels.instanceType -}} +{{- $attachMetadata = or $attachMetadata (gt (keys .Values.nodeLabels | len) 0) -}} {{- if eq $attachMetadata true }} attach_metadata { node = true @@ -99,4 +100,11 @@ rule { target_label = "instance_type" } {{- end }} +{{- range $attribute, $label := (omit .Values.nodeLabels "nodePool" "region" "availabilityZone" "nodeRole" "nodeOS" "nodeArchitecture" "instanceType")}} + +rule { + source_labels = [{{ $label | quote }}] + target_label = {{ $attribute | quote }} +} +{{- end }} {{- end }} diff --git a/charts/k8s-monitoring/charts/feature-pod-logs/values.yaml b/charts/k8s-monitoring/charts/feature-pod-logs/values.yaml index ac35376a45..a449783b14 100644 --- a/charts/k8s-monitoring/charts/feature-pod-logs/values.yaml +++ b/charts/k8s-monitoring/charts/feature-pod-logs/values.yaml @@ -27,7 +27,6 @@ labels: app_kubernetes_io_name: app.kubernetes.io/name # -- Log labels to set with values copied from the Kubernetes Node labels. -# Only used for "filelog" gather method. # Format: `: `. # @section -- Log Processing nodeLabels: {} diff --git a/charts/k8s-monitoring/docs/examples/meta-monitoring/README.md b/charts/k8s-monitoring/docs/examples/meta-monitoring/README.md index 9caf29f526..542c6beb1c 100644 --- a/charts/k8s-monitoring/docs/examples/meta-monitoring/README.md +++ b/charts/k8s-monitoring/docs/examples/meta-monitoring/README.md @@ -35,8 +35,8 @@ integrations: region: true availability_zone: true node_role: true - os: true - architecture: true + nodeOS: true + nodeArchitecture: true instance_type: true alloy: @@ -111,8 +111,8 @@ clusterMetrics: region: true availabilityZone: true nodeRole: true - os: true - architecture: true + nodeOS: true + nodeArchitecture: true instanceType: true kubelet: @@ -169,8 +169,8 @@ podLogs: region: true availabilityZone: true nodeRole: true - os: true - architecture: true + nodeOS: true + nodeArchitecture: true instanceType: true structuredMetadata: diff --git a/charts/k8s-monitoring/docs/examples/meta-monitoring/alloy-singleton.alloy b/charts/k8s-monitoring/docs/examples/meta-monitoring/alloy-singleton.alloy index 951934fd2d..7bef1a8f6a 100644 --- a/charts/k8s-monitoring/docs/examples/meta-monitoring/alloy-singleton.alloy +++ b/charts/k8s-monitoring/docs/examples/meta-monitoring/alloy-singleton.alloy @@ -62,6 +62,25 @@ declare "cluster_metrics" { target_label = "node_role" } + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } + rule { source_labels = [ "__meta_kubernetes_node_label_node_kubernetes_io_instance_type", @@ -392,6 +411,25 @@ declare "cluster_metrics" { target_label = "node_role" } + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } + rule { source_labels = [ "__meta_kubernetes_node_label_node_kubernetes_io_instance_type", @@ -698,6 +736,25 @@ declare "pod_logs" { target_label = "node_role" } + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } + rule { source_labels = [ "__meta_kubernetes_node_label_node_kubernetes_io_instance_type", @@ -1137,6 +1194,25 @@ declare "alloy_integration" { regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } } export "output" { @@ -1478,6 +1554,25 @@ declare "grafana_integration" { regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } } export "output" { @@ -1753,6 +1848,25 @@ declare "loki_integration" { regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } } export "output" { @@ -2036,6 +2150,25 @@ declare "mimir_integration" { regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } } export "output" { diff --git a/charts/k8s-monitoring/docs/examples/meta-monitoring/output.yaml b/charts/k8s-monitoring/docs/examples/meta-monitoring/output.yaml index 299b5ae968..b4798d0e72 100644 --- a/charts/k8s-monitoring/docs/examples/meta-monitoring/output.yaml +++ b/charts/k8s-monitoring/docs/examples/meta-monitoring/output.yaml @@ -119,6 +119,25 @@ data: target_label = "node_role" } + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } + rule { source_labels = [ "__meta_kubernetes_node_label_node_kubernetes_io_instance_type", @@ -449,6 +468,25 @@ data: target_label = "node_role" } + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } + rule { source_labels = [ "__meta_kubernetes_node_label_node_kubernetes_io_instance_type", @@ -755,6 +793,25 @@ data: target_label = "node_role" } + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } + rule { source_labels = [ "__meta_kubernetes_node_label_node_kubernetes_io_instance_type", @@ -1194,6 +1251,25 @@ data: regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } } export "output" { @@ -1535,6 +1611,25 @@ data: regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } } export "output" { @@ -1810,6 +1905,25 @@ data: regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } } export "output" { @@ -2093,6 +2207,25 @@ data: regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } } export "output" { diff --git a/charts/k8s-monitoring/docs/examples/meta-monitoring/values.yaml b/charts/k8s-monitoring/docs/examples/meta-monitoring/values.yaml index f79ba496f1..bfc2aa1e75 100644 --- a/charts/k8s-monitoring/docs/examples/meta-monitoring/values.yaml +++ b/charts/k8s-monitoring/docs/examples/meta-monitoring/values.yaml @@ -25,8 +25,8 @@ integrations: region: true availability_zone: true node_role: true - os: true - architecture: true + nodeOS: true + nodeArchitecture: true instance_type: true alloy: @@ -101,8 +101,8 @@ clusterMetrics: region: true availabilityZone: true nodeRole: true - os: true - architecture: true + nodeOS: true + nodeArchitecture: true instanceType: true kubelet: @@ -159,8 +159,8 @@ podLogs: region: true availabilityZone: true nodeRole: true - os: true - architecture: true + nodeOS: true + nodeArchitecture: true instanceType: true structuredMetadata: diff --git a/charts/k8s-monitoring/docs/examples/node-labels/README.md b/charts/k8s-monitoring/docs/examples/node-labels/README.md index 08ce82e467..4ff09c3522 100644 --- a/charts/k8s-monitoring/docs/examples/node-labels/README.md +++ b/charts/k8s-monitoring/docs/examples/node-labels/README.md @@ -42,13 +42,13 @@ clusterMetrics: podLogs: enabled: true nodeLabels: - nodepool: true + nodePool: true region: true - availability_zone: true - node_role: true - os: true - architecture: true - instance_type: true + availabilityZone: true + nodeRole: true + nodeOS: true + nodeArchitecture: true + instanceType: true structuredMetadata: node_pool: nodepool region: diff --git a/charts/k8s-monitoring/docs/examples/node-labels/alloy-logs.alloy b/charts/k8s-monitoring/docs/examples/node-labels/alloy-logs.alloy index d5fe06615a..6b921fa4b4 100644 --- a/charts/k8s-monitoring/docs/examples/node-labels/alloy-logs.alloy +++ b/charts/k8s-monitoring/docs/examples/node-labels/alloy-logs.alloy @@ -122,6 +122,18 @@ declare "pod_logs" { target_label = "app_kubernetes_io_name" } + rule { + source_labels = [ + "__meta_kubernetes_node_label_karpenter_sh_nodepool", + "__meta_kubernetes_node_label_cloud_google_com_gke_nodepool", + "__meta_kubernetes_node_label_eks_amazonaws_com_nodegroup", + "__meta_kubernetes_node_label_kubernetes_azure_com_agentpool", + "__meta_kubernetes_node_label_agentpool", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "nodepool" + } + rule { source_labels = [ "__meta_kubernetes_node_label_topology_kubernetes_io_region", @@ -130,6 +142,55 @@ declare "pod_logs" { regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_topology_kubernetes_io_zone", + "__meta_kubernetes_node_label_failure_domain_beta_kubernetes_io_zone", + "__meta_kubernetes_node_label_topology_gke_io_zone", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "availability_zone" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_role", + "__meta_kubernetes_node_label_node_kubernetes_io_role", + "__meta_kubernetes_node_label_node_role", + "__meta_kubernetes_node_label_role", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "node_role" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_node_kubernetes_io_instance_type", + "__meta_kubernetes_node_label_beta_kubernetes_io_instance_type", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "instance_type" + } } discovery.kubernetes "pods" { diff --git a/charts/k8s-monitoring/docs/examples/node-labels/output.yaml b/charts/k8s-monitoring/docs/examples/node-labels/output.yaml index 67439e6725..1656dd2670 100644 --- a/charts/k8s-monitoring/docs/examples/node-labels/output.yaml +++ b/charts/k8s-monitoring/docs/examples/node-labels/output.yaml @@ -1353,6 +1353,18 @@ data: target_label = "app_kubernetes_io_name" } + rule { + source_labels = [ + "__meta_kubernetes_node_label_karpenter_sh_nodepool", + "__meta_kubernetes_node_label_cloud_google_com_gke_nodepool", + "__meta_kubernetes_node_label_eks_amazonaws_com_nodegroup", + "__meta_kubernetes_node_label_kubernetes_azure_com_agentpool", + "__meta_kubernetes_node_label_agentpool", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "nodepool" + } + rule { source_labels = [ "__meta_kubernetes_node_label_topology_kubernetes_io_region", @@ -1361,6 +1373,55 @@ data: regex = "^(?:;*)?([^;]+).*$" target_label = "region" } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_topology_kubernetes_io_zone", + "__meta_kubernetes_node_label_failure_domain_beta_kubernetes_io_zone", + "__meta_kubernetes_node_label_topology_gke_io_zone", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "availability_zone" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_role", + "__meta_kubernetes_node_label_node_kubernetes_io_role", + "__meta_kubernetes_node_label_node_role", + "__meta_kubernetes_node_label_role", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "node_role" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_os", + "__meta_kubernetes_node_label_os_kubernetes_io", + "__meta_kubernetes_node_label_os", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "os" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_kubernetes_io_arch", + "__meta_kubernetes_node_label_beta_kubernetes_io_arch", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "architecture" + } + + rule { + source_labels = [ + "__meta_kubernetes_node_label_node_kubernetes_io_instance_type", + "__meta_kubernetes_node_label_beta_kubernetes_io_instance_type", + ] + regex = "^(?:;*)?([^;]+).*$" + target_label = "instance_type" + } } discovery.kubernetes "pods" { diff --git a/charts/k8s-monitoring/docs/examples/node-labels/values.yaml b/charts/k8s-monitoring/docs/examples/node-labels/values.yaml index f92e9e43ba..9fff243ac2 100644 --- a/charts/k8s-monitoring/docs/examples/node-labels/values.yaml +++ b/charts/k8s-monitoring/docs/examples/node-labels/values.yaml @@ -30,13 +30,13 @@ clusterMetrics: podLogs: enabled: true nodeLabels: - nodepool: true + nodePool: true region: true - availability_zone: true - node_role: true - os: true - architecture: true - instance_type: true + availabilityZone: true + nodeRole: true + nodeOS: true + nodeArchitecture: true + instanceType: true structuredMetadata: node_pool: nodepool region: