Skip to content

Conversation

@triviajon
Copy link
Contributor

What does this PR do?

This PR adds support for using a wildcard to collect all resource labels/annotations as tags for metrics emitted by the KSM check. Previously, we only supported explicit label/annotation mappings for tag extraction.

Motivation

https://datadoghq.atlassian.net/browse/CONTINT-4854

More directly, our public documentation states we support this feature in general, expect for the KSM check: https://docs.datadoghq.com/containers/kubernetes/tag/?tab=datadogoperator#tag-extraction

Describe how you validated your changes

Added unit tests ✅
Additionally:

  1. Created a minikube cluster.
  2. Added some labels and annotations to pods and nodes.
# pod/dummy
apiVersion: v1
kind: Pod
metadata:
  annotations:
    arora: cc
  creationTimestamp: "2025-10-16T20:05:00Z"
  generation: 1
  labels:
    run: dummy
  name: dummy
  namespace: default
  resourceVersion: "1494"
  uid: a2ba5925-6e1f-441b-a4cb-24becc8f18a7
---
# node/wildcard-tag-collection-ksm
apiVersion: v1
kind: Node
metadata:
  annotations:
    node.alpha.kubernetes.io/ttl: "0"
    volumes.kubernetes.io/controller-managed-attach-detach: "true"
  creationTimestamp: "2025-10-16T19:42:46Z"
  labels:
    beta.kubernetes.io/arch: arm64
    beta.kubernetes.io/os: linux
    kubernetes.io/arch: arm64
    kubernetes.io/hostname: wildcard-tag-collection-ksm
    kubernetes.io/os: linux
    minikube.k8s.io/commit: 65318f4cfff9c12cc87ec9eb8f4cdd57b25047f3
    minikube.k8s.io/name: wildcard-tag-collection-ksm
    minikube.k8s.io/primary: "true"
    minikube.k8s.io/updated_at: 2025_10_16T15_42_49_0700
    minikube.k8s.io/version: v1.37.0
    node-role.kubernetes.io/control-plane: ""
    node.kubernetes.io/exclude-from-external-load-balancers: ""
    test.special/value: "67"
  name: wildcard-tag-collection-ksm
  resourceVersion: "1474"
  uid: ade3fea9-37bc-4968-9847-86960fbe4683
  1. Deploy a datadog agent including the following config:
  kubernetesResourcesLabelsAsTags:
    nodes:
      kubernetes.io/arch: arch
      "*": "my_%%label%%"
  kubernetesResourcesAnnotationsAsTags:
    pods:
      arora: barak
  1. Running agent check kubernetes_state_core in the cluster agent shows that metrics are being correctly tagged with tag keys being transformed as specified:
# node metric:
{
    "metric": "kubernetes_state.node.memory_capacity",
    "points": [
      [
        1760648147,
        2.5161904128e+10
      ]
    ],
    "tags": [
      "kube_cluster_name:jon-rosario-dev-12670",
      "arch:arm64", # <- originally was a node label kubernetes.io/arch=arm64
      "container_runtime_version:docker://28.4.0",
      "kernel_version:6.10.14-linuxkit",
      "unit:byte",
      "kubelet_version:v1.34.0",
      "my_beta_kubernetes_io_arch:arm64", # <- these are all node labels as tags
      "my_beta_kubernetes_io_os:linux",
      "my_kubernetes_io_hostname:wildcard-tag-collection-ksm",
      "my_kubernetes_io_os:linux",
      "my_minikube_k8s_io_commit:65318f4cfff9c12cc87ec9eb8f4cdd57b25047f3",
      "my_minikube_k8s_io_name:wildcard-tag-collection-ksm",
      "my_minikube_k8s_io_primary:true",
      "my_minikube_k8s_io_updated_at:2025_10_16T15_42_49_0700",
      "my_minikube_k8s_io_version:v1.37.0",
      "my_node_kubernetes_io_exclude_from_external_load_balancers:",
      "my_node_role_kubernetes_io_control_plane:",
      "my_test_special_value:67",
      "node:wildcard-tag-collection-ksm",
      "orch_cluster_id:4b88e928-9da4-4833-aa6b-f7149eb6981d",
      "os_image:Ubuntu 22.04.5 LTS",
      "resource:memory"
    ],
    "host": "wildcard-tag-collection-ksm-jon-rosario-dev-12670",
    "type": "gauge",
    "interval": 0,
    "source_type_name": "System"
  },
...
# dummy pod metric
{
    "metric": "kubernetes_state.pod.ready",
    "points": [
      [
        1760648419,
        0
      ]
    ],
    "tags": [
      "kube_cluster_name:jon-rosario-dev-12670",
      "barak:cc", # <- was a pod annotation "arora"
      "condition:false",
      "uid:a2ba5925-6e1f-441b-a4cb-24becc8f18a7",
      "kube_namespace:default",
      "node:wildcard-tag-collection-ksm",
      "orch_cluster_id:4b88e928-9da4-4833-aa6b-f7149eb6981d",
      "pod_name:dummy",
      "pod_phase:Running"
    ],
    "host": "wildcard-tag-collection-ksm-jon-rosario-dev-12670",
    "type": "gauge",
    "interval": 0,
    "source_type_name": "System"
  },

We can also see this on Datadog:
image

Additional Notes

@triviajon triviajon requested a review from a team as a code owner October 16, 2025 21:12
@github-actions github-actions bot added the medium review PR review might take time label Oct 16, 2025
@cit-pr-commenter
Copy link

cit-pr-commenter bot commented Oct 16, 2025

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 0dea5bbe-0726-4751-b6a0-5163df258fe3

Baseline: 418cfd7
Comparison: 27ec799
Diff

Optimization Goals: ✅ Improvement(s) detected

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_memory memory utilization -6.19 [-6.62, -5.76] 1 Logs

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization -26.88 [-28.86, -24.91] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
ddot_metrics_sum_delta memory utilization +0.41 [+0.24, +0.57] 1 Logs
otlp_ingest_metrics memory utilization +0.36 [+0.23, +0.48] 1 Logs
ddot_logs memory utilization +0.23 [+0.17, +0.29] 1 Logs
otlp_ingest_logs memory utilization +0.21 [+0.08, +0.34] 1 Logs
uds_dogstatsd_20mb_12k_contexts_20_senders memory utilization +0.18 [+0.14, +0.23] 1 Logs
ddot_metrics memory utilization +0.02 [-0.15, +0.19] 1 Logs
file_to_blackhole_100ms_latency egress throughput +0.01 [-0.60, +0.62] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.01, +0.01] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.00 [-0.23, +0.22] 1 Logs
file_to_blackhole_1000ms_latency egress throughput -0.01 [-0.64, +0.61] 1 Logs
file_to_blackhole_500ms_latency egress throughput -0.04 [-0.64, +0.57] 1 Logs
ddot_metrics_sum_cumulative memory utilization -0.04 [-0.16, +0.08] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.06 [-0.67, +0.55] 1 Logs
quality_gate_idle_all_features memory utilization -0.21 [-0.25, -0.17] 1 Logs bounds checks dashboard
file_tree memory utilization -0.22 [-0.28, -0.17] 1 Logs
tcp_syslog_to_blackhole ingress throughput -0.46 [-0.53, -0.38] 1 Logs
quality_gate_idle memory utilization -0.50 [-0.54, -0.46] 1 Logs bounds checks dashboard
quality_gate_metrics_logs memory utilization -0.51 [-0.72, -0.31] 1 Logs bounds checks dashboard
ddot_metrics_sum_cumulativetodelta_exporter memory utilization -0.53 [-0.72, -0.33] 1 Logs
quality_gate_logs % cpu utilization -4.04 [-6.71, -1.36] 1 Logs bounds checks dashboard
docker_containers_memory memory utilization -6.19 [-6.62, -5.76] 1 Logs
docker_containers_cpu % cpu utilization -26.88 [-28.86, -24.91] 1 Logs

Bounds Checks: ❌ Failed

perf experiment bounds_check_name replicates_passed links
docker_containers_cpu simple_check_run 10/10
docker_containers_memory memory_usage 9/10
docker_containers_memory simple_check_run 10/10
file_to_blackhole_0ms_latency lost_bytes 10/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_100ms_latency lost_bytes 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency lost_bytes 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle intake_connections 10/10 bounds checks dashboard
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 bounds checks dashboard
quality_gate_logs intake_connections 10/10 bounds checks dashboard
quality_gate_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_logs memory_usage 10/10 bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 bounds checks dashboard
quality_gate_metrics_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.

@triviajon triviajon requested a review from a team as a code owner October 17, 2025 19:02
@triviajon triviajon added the qa/done QA done before merge and regressions are covered by tests label Oct 17, 2025
@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Oct 17, 2025

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 418cfd7

Successful checks

Info

Quality gate Delta On disk size (MiB) Delta On wire size (MiB)
agent_deb_amd64 $${+0.02}$$ $${676.34}$$ < $${702.15}$$ $${+0.02}$$ $${165.25}$$ < $${177.79}$$
agent_deb_amd64_fips $${+0.02}$$ $${670.86}$$ < $${696.65}$$ $${+0}$$ $${164.64}$$ < $${176.53}$$
agent_heroku_amd64 $${+0.01}$$ $${336.64}$$ < $${340.18}$$ $${-0}$$ $${89.84}$$ < $${91.08}$$
agent_msi $${+0.07}$$ $${1013.88}$$ < $${1015.38}$$ $${-0.02}$$ $${148.41}$$ < $${150.78}$$
agent_rpm_amd64 $${+0.02}$$ $${676.32}$$ < $${702.14}$$ $${-0.04}$$ $${167.43}$$ < $${180.53}$$
agent_rpm_amd64_fips $${+0.02}$$ $${670.85}$$ < $${696.64}$$ $${+0.03}$$ $${166.08}$$ < $${178.79}$$
agent_rpm_arm64 $${+0.02}$$ $${666.14}$$ < $${686.31}$$ $${+0.06}$$ $${153.36}$$ < $${161.22}$$
agent_rpm_arm64_fips $${+0.02}$$ $${661.67}$$ < $${681.84}$$ $${-0}$$ $${152.59}$$ < $${160.18}$$
agent_suse_amd64 $${+0.02}$$ $${676.32}$$ < $${702.14}$$ $${-0.04}$$ $${167.43}$$ < $${180.53}$$
agent_suse_amd64_fips $${+0.02}$$ $${670.85}$$ < $${696.64}$$ $${+0.03}$$ $${166.08}$$ < $${178.79}$$
agent_suse_arm64 $${+0.02}$$ $${666.14}$$ < $${686.31}$$ $${+0.06}$$ $${153.36}$$ < $${161.22}$$
agent_suse_arm64_fips $${+0.02}$$ $${661.67}$$ < $${681.84}$$ $${-0}$$ $${152.59}$$ < $${160.18}$$
docker_agent_amd64 $${+0.02}$$ $${746.89}$$ < $${773.59}$$ $${+0.02}$$ $${251.86}$$ < $${266.06}$$
docker_agent_arm64 $${+0.02}$$ $${760.65}$$ < $${781.7}$$ $${+0.01}$$ $${242.47}$$ < $${251.85}$$
docker_agent_jmx_amd64 $${+0.02}$$ $${937.76}$$ < $${964.45}$$ $${+0.03}$$ $${320.51}$$ < $${334.68}$$
docker_agent_jmx_arm64 $${+0.02}$$ $${940.11}$$ < $${961.17}$$ $${+0.01}$$ $${307.08}$$ < $${316.44}$$
docker_cluster_agent_amd64 $${+0.02}$$ $${213.04}$$ < $${213.74}$$ $${+0.01}$$ $${72.28}$$ < $${73.14}$$
docker_cluster_agent_arm64 $${+0.06}$$ $${228.99}$$ < $${229.68}$$ $${+0.02}$$ $${68.54}$$ < $${69.41}$$
docker_cws_instrumentation_amd64 $${0}$$ $${7.07}$$ < $${7.12}$$ $${+0}$$ $${2.95}$$ < $${3.29}$$
docker_cws_instrumentation_arm64 $${+0}$$ $${6.69}$$ < $${6.92}$$ $${+0}$$ $${2.7}$$ < $${3.07}$$
docker_dogstatsd_amd64 $${0}$$ $${38.45}$$ < $${39.3}$$ $${+0}$$ $${14.84}$$ < $${15.76}$$
docker_dogstatsd_arm64 $${0}$$ $${37.12}$$ < $${37.94}$$ $${-0}$$ $${14.28}$$ < $${14.83}$$
dogstatsd_deb_amd64 $${+0}$$ $${29.67}$$ < $${30.53}$$ $${+0}$$ $${7.82}$$ < $${8.75}$$
dogstatsd_deb_arm64 $${+0}$$ $${28.25}$$ < $${29.11}$$ $${+0}$$ $${6.77}$$ < $${7.71}$$
dogstatsd_rpm_amd64 $${+0}$$ $${29.67}$$ < $${30.53}$$ $${-0}$$ $${7.83}$$ < $${8.76}$$
dogstatsd_suse_amd64 $${+0}$$ $${29.67}$$ < $${30.53}$$ $${-0}$$ $${7.83}$$ < $${8.76}$$
iot_agent_deb_amd64 $${+0.01}$$ $${41.93}$$ < $${54.97}$$ $${+0}$$ $${10.91}$$ < $${14.45}$$
iot_agent_deb_arm64 $${+0.01}$$ $${39.75}$$ < $${51.9}$$ $${+0.01}$$ $${9.42}$$ < $${12.63}$$
iot_agent_deb_armhf $${+0.01}$$ $${39.62}$$ < $${51.84}$$ $${+0}$$ $${9.5}$$ < $${12.74}$$
iot_agent_rpm_amd64 $${+0.01}$$ $${41.93}$$ < $${54.97}$$ $${+0}$$ $${10.93}$$ < $${14.47}$$
iot_agent_suse_amd64 $${+0.01}$$ $${41.93}$$ < $${54.97}$$ $${+0}$$ $${10.93}$$ < $${14.47}$$

Copy link
Contributor

@hestonhoffman hestonhoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small edit to release note

@triviajon
Copy link
Contributor Author

/merge

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Oct 21, 2025

View all feedbacks in Devflow UI.

2025-10-21 18:15:33 UTC ℹ️ Start processing command /merge


2025-10-21 18:15:40 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-10-21 19:22:30 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 41m (p90).


2025-10-21 19:36:15 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit cd20358 into main Oct 21, 2025
275 checks passed
@dd-mergequeue dd-mergequeue bot deleted the triviajon/CONTINT-4854/wildcard-tag-collection-ksm branch October 21, 2025 19:36
@github-actions github-actions bot added this to the 7.73.0 milestone Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

medium review PR review might take time qa/done QA done before merge and regressions are covered by tests team/container-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants