Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CONTP-48] Cluster Agent consistent tagging via global tags #30946

Merged
merged 8 commits into from
Nov 21, 2024

Conversation

gabedos
Copy link
Contributor

@gabedos gabedos commented Nov 11, 2024

What does this PR do?

This PR unifies the way that data is tagged from cluster checks. All data from a cluster check (including those that are technically not cluster checks but still executed on the DCA on the cluster level such as KSM check) will receive the global tags defined on the cluster agent (DD_TAGS, DD_EXTRA_TAGS, DD_CLUSTER_CHECKS_EXTRA_TAGS, DD_ORCHESTRATOR_EXPLORER_EXTRA_TAGS).

Motivation

Simplify the way users interact with cluster check tags. Currently we have 4 different environment variables that apply differently for some checks (KSM, Orchestrator, others) and also differently depending on where the check is executed (DCA, Node Agent, CLC runner).

Describe how to test/QA your changes

Case 1: DCA w/o CLC

  1. Deploy the Agent
datadog:
  kubelet:
    tlsVerify: false
  clusterName: <INSERT_CLUSTER_NAME>
  clusterChecks:
    enabled: true
  kubeStateMetricsCore:
    enabled: true
    # useClusterCheckRunners: true
  envDict:
    DD_TAGS: "source:node-tags"
    DD_EXTRA_TAGS: "source:node-extra"
    DD_CLUSTER_CHECKS_EXTRA_TAGS: "source:node-cluster_extra"       # Note: should never see these
    DD_ORCHESTRATOR_EXPLORER_EXTRA_TAGS: "source:node-orch_extra"   # Note: should never see these
agents:
  image:
    tag: <INSERT_RC_TAG>
# clusterChecksRunner:
#   replicas: 1
#   enabled: true
#   image:
#     tag: <INSERT_RC_TAG>
clusterAgent:
  envDict:
    DD_TAGS: "source:dca-tags"
    DD_EXTRA_TAGS: "source:dca-extra"
    DD_CLUSTER_CHECKS_EXTRA_TAGS: "source:dca-cluster_extra"
    DD_ORCHESTRATOR_EXPLORER_EXTRA_TAGS: "source:dca-orch_extra"
  image:
    tag: <INSERT_RC_TAG>
  enabled: true
  replicas: 1
  1. Deploy the nginx service with an autodiscovery http check
apiVersion: v1
kind: Service
metadata:
    name: my-nginx
    labels:
        run: my-nginx
        tags.datadoghq.com/env: "prod"
        tags.datadoghq.com/service: "my-nginx"
        tags.datadoghq.com/version: "1.19.0"
    annotations:
      ad.datadoghq.com/service.checks: |
        {
          "http_check": {
            "init_config": {},
            "instances": [
              {
                "url":"http://%%host%%",
                "name":"My Nginx",
                "timeout":1
              }
            ]
          }
        }        
spec:
    ports:
        - port: 80
          protocol: TCP
    selector:
        run: my-nginx
  1. Verify Global Tags are set
k exec -it datadog-agent-linux-cluster-agent-xxxxx -- agent tagger-list
=== Entity internal://global-entity-id ===
== Source workloadmeta-static =
=Tags: [kube_cluster_name:gabedos-cluster source:dca-cluster_extra source:dca-extra source:dca-orch_extra source:dca-tags]
===

k exec -it datadog-agent-linux-xxxxx -- agent tagger-list
=== Entity internal://global-entity-id ===
== Source workloadmeta-static =
=Tags: [source:node-extra source:node-tags]
===
  1. Confirm the following metrics tags:
  • network.http.cant_connect should contain all of the cluster agent tags and node agent tags because it was dispatched from the cluster agent where the DCA global tags are added to the check config and the node agent's own global tags and also enriched to the metric in the aggregator.
  • kubernetes_state.deployment.count should contain only the DCA tags since it's executed on the cluster agent.
  • check_run.kube_apiserver_controlplane.up.ok should contain both the DCA tags and Node Agent tags because the metric is produced from the kube_apiserver check that run on both the DCA and Node Agent.
  • container.cpu.limit should contain just the Node Agent tags. This is a sanity check that extra tags aren't being applied in the wrong places.
After-DCA-no-CLC

DCA w/ CLC

  1. Deploy the Agent. Uncomment out the KSM UseClusterCheckRunners and the clusterChecksRunners in the linux.yaml from above.
  2. Deploy the nginx service from above.
  3. Confirm the following metrics:
  • network.http.cant_connect: This one will be different. The check is now being executed on the clusterChecksRunner which will not have the Node Agent tags. When the DCA creates and dispatches a check config it will attach its own global tags.
  • kubernetes_state.deployment.count: DCA tags only
  • check_run.kube_apiserver_controlplane.up.ok: DCA + Node tags
  • container.cpu.limit: Node tags only
After-DCA-with-CLC
  1. Confirm the following events tags:

Go to the Events Management Explorer and search for events created by your cluster. This will just be a lot of pod creations. Click on them and you should see all of the cluster-agent tags as well as the node-agent tags. We expect both because the orchestrator check runs on both the node-agent and the cluster-agent. They detected the same event and send data to the datadog backend with their own tags and they end up being merged together into one entity.

OrchestratorPage

Possible Drawbacks / Trade-offs

Since these are low cardinality global tags, we don't expect to see a significant change in the number of unique metrics for customer billing.

This does in some ways limit the flexibility for some customers. For instance, they will not be able to use DD_ORCHESTRATOR_EXPLORER_EXTRA_TAGS to just add tags to the events emitted by the orchestrator check. Instead, the tag will be attached to all data from the cluster agent. This makes the tagging interface much simpler for customers.

Additional Notes

@github-actions github-actions bot added medium review PR review might take time team/container-platform The Container Platform Team labels Nov 11, 2024
@gabedos gabedos force-pushed the gabedos/cluster-agent-consistent-tagging branch from 6148a34 to 7997429 Compare November 11, 2024 20:30
@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Nov 11, 2024

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=49613788 --os-family=ubuntu

Note: This applies to commit 0e1801e

Copy link

cit-pr-commenter bot commented Nov 11, 2024

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 1fe5c2f9-88e4-4785-a2b2-c3ff2107d6be

Baseline: a166214
Comparison: 0e1801e
Diff

Optimization Goals: ❌ Significant changes detected

perf experiment goal Δ mean % Δ mean % CI trials links
pycheck_lots_of_tags % cpu utilization +8.86 [+5.23, +12.48] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
pycheck_lots_of_tags % cpu utilization +8.86 [+5.23, +12.48] 1 Logs
basic_py_check % cpu utilization +4.66 [+0.80, +8.51] 1 Logs
file_to_blackhole_500ms_latency egress throughput +0.26 [-0.51, +1.02] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization +0.11 [-0.61, +0.84] 1 Logs
file_to_blackhole_0ms_latency egress throughput +0.11 [-0.78, +0.99] 1 Logs
file_to_blackhole_1000ms_latency_linear_load egress throughput +0.10 [-0.36, +0.57] 1 Logs
quality_gate_idle memory utilization +0.06 [+0.02, +0.11] 1 Logs bounds checks dashboard
file_tree memory utilization +0.05 [-0.09, +0.20] 1 Logs
file_to_blackhole_300ms_latency egress throughput +0.01 [-0.61, +0.64] 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.11, +0.10] 1 Logs
quality_gate_idle_all_features memory utilization -0.01 [-0.12, +0.10] 1 Logs bounds checks dashboard
file_to_blackhole_100ms_latency egress throughput -0.04 [-0.76, +0.68] 1 Logs
otel_to_otel_logs ingress throughput -0.24 [-0.94, +0.46] 1 Logs
file_to_blackhole_1000ms_latency egress throughput -0.35 [-1.12, +0.42] 1 Logs
tcp_syslog_to_blackhole ingress throughput -1.74 [-1.81, -1.66] 1 Logs

Bounds Checks: ❌ Failed

perf experiment bounds_check_name replicates_passed links
file_to_blackhole_1000ms_latency lost_bytes 0/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_1000ms_latency_linear_load 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_300ms_latency lost_bytes 10/10
file_to_blackhole_300ms_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 memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features 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_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.

@gabedos gabedos changed the title Gabedos/cluster agent consistent tagging [CONTP-48] Cluster Agent consistent tagging via global tags Nov 11, 2024
@github-actions github-actions bot added long review PR is complex, plan time to review it and removed medium review PR review might take time labels Nov 12, 2024
@gabedos gabedos added this to the 7.61.0 milestone Nov 12, 2024
@gabedos gabedos force-pushed the gabedos/cluster-agent-consistent-tagging branch from 70220fb to a755ffd Compare November 13, 2024 04:16
@gabedos gabedos marked this pull request as ready for review November 13, 2024 14:26
@gabedos gabedos requested review from a team as code owners November 13, 2024 14:26
@gabedos gabedos requested a review from GustavoCaso November 13, 2024 14:26
@@ -57,7 +57,7 @@ type WorkloadMetaCollector struct {
containerEnvAsTags map[string]string
containerLabelsAsTags map[string]string

staticTags map[string]string
staticTags map[string][]string // for ECS and EKS Fargate
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was testing the static/global tags by setting the same tag key to different values such as the following:

    DD_TAGS: "source:dca-tags"
    DD_EXTRA_TAGS: "source:dca-extra"
    DD_CLUSTER_CHECKS_EXTRA_TAGS: "source:dca-cluster_extra"
    DD_ORCHESTRATOR_EXPLORER_EXTRA_TAGS: "source:dca-orch_extra"

Realized only the last value was being recorded because this struct was not considering that the same tag key could have multiple values so change the type to map[string][]string

tags := taglist.NewTagList()
// These are the global tags that should only be applied to the internal global entity
// Whereas the static tags are applied to containers and pods directly as well.
globalEnvTags := util.GetGlobalEnvTags()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to create a separate list of the global tags. This is because c.staticTags get applied directly to all of the containers and pods and we only want these global tags applied to the internal://global-entity-id. There will be some values duplicated in c.staticTags and globalEnvTags, however, the tagList removes duplicates and everything ends up being properly set on the GlobalEntity

@GustavoCaso
Copy link
Member

@gabedos you are going to need to rebase|merge main on the PR. We recently changed the file structure for the tagger component and it will create merge conflicts #30584.

Let me know if you need any help 😄

@gabedos gabedos force-pushed the gabedos/cluster-agent-consistent-tagging branch from e1cdd11 to 4ed7777 Compare November 15, 2024 18:11
@gabedos gabedos requested a review from GustavoCaso November 15, 2024 20:42
Copy link
Member

@GustavoCaso GustavoCaso left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks for refactoring the global tags helper function and pass the config component as part of the function arguments

@gabedos
Copy link
Contributor Author

gabedos commented Nov 20, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Nov 20, 2024

Devflow running: /merge

View all feedbacks in Devflow UI.


2024-11-20 18:25:18 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. 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.


2024-11-20 22:25:20 UTC ⚠️ MergeQueue: This merge request was unqueued

This merge request was unqueued

@gabedos
Copy link
Contributor Author

gabedos commented Nov 21, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Nov 21, 2024

Devflow running: /merge

View all feedbacks in Devflow UI.


2024-11-21 18:36:19 UTC ℹ️ MergeQueue: pull request added to the queue

The median merge time in main is 25m.

@dd-mergequeue dd-mergequeue bot merged commit 1683be9 into main Nov 21, 2024
226 checks passed
@dd-mergequeue dd-mergequeue bot deleted the gabedos/cluster-agent-consistent-tagging branch November 21, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
long review PR is complex, plan time to review it team/container-platform The Container Platform Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants