Skip to content

Commit

Permalink
[Backport 7.61.x] [incident-33304] Expect container tags on dogstatsd…
Browse files Browse the repository at this point in the history
… metrics (#32268)

Co-authored-by: L3n41c <[email protected]>
  • Loading branch information
agent-platform-auto-pr[bot] and L3n41c authored Dec 17, 2024
1 parent 8c991a8 commit c3a01f3
Showing 1 changed file with 22 additions and 47 deletions.
69 changes: 22 additions & 47 deletions test/new-e2e/tests/containers/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
kubeNamespaceDogstatsWorkload = "workload-dogstatsd"
kubeNamespaceDogstatsStandaloneWorkload = "workload-dogstatsd-standalone"
kubeNamespaceTracegenWorkload = "workload-tracegen"
kubeDeploymentDogstatsdUDP = "dogstatsd-udp"
kubeDeploymentDogstatsdUDPOrigin = "dogstatsd-udp-origin-detection"
kubeDeploymentDogstatsdUDPExternalData = "dogstatsd-udp-external-data-only"
kubeDeploymentDogstatsdUDS = "dogstatsd-uds"
Expand Down Expand Up @@ -796,44 +797,53 @@ func (suite *k8sSuite) TestCPU() {

func (suite *k8sSuite) TestDogstatsdInAgent() {
// Test with UDS
suite.testDogstatsdContainerID(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDS)
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDS)
// Test with UDP + Origin detection
suite.testDogstatsdContainerID(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDPOrigin)
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDPOrigin)
// Test with UDP + DD_ENTITY_ID
suite.testDogstatsdPodUID(kubeNamespaceDogstatsWorkload)
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDP)
// Test with UDP + External Data
suite.testDogstatsdExternalData(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDPExternalData)
}

func (suite *k8sSuite) TestDogstatsdStandalone() {
// Test with UDS
suite.testDogstatsdContainerID(kubeNamespaceDogstatsStandaloneWorkload, kubeDeploymentDogstatsdUDS)
suite.testDogstatsd(kubeNamespaceDogstatsStandaloneWorkload, kubeDeploymentDogstatsdUDS)
// Dogstatsd standalone does not support origin detection
// Test with UDP + DD_ENTITY_ID
suite.testDogstatsdPodUID(kubeNamespaceDogstatsWorkload)
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDP)
}

func (suite *k8sSuite) testDogstatsdPodUID(kubeNamespace string) {
// Test dogstatsd origin detection with UDP + DD_ENTITY_ID
func (suite *k8sSuite) testDogstatsd(kubeNamespace, kubeDeployment string) {
suite.testMetric(&testMetricArgs{
Filter: testMetricFilterArgs{
Name: "custom.metric",
Tags: []string{
"^kube_deployment:dogstatsd-udp$",
"^kube_deployment:" + regexp.QuoteMeta(kubeDeployment) + "$",
"^kube_namespace:" + regexp.QuoteMeta(kubeNamespace) + "$",
},
},
Expect: testMetricExpectArgs{
Tags: &[]string{
`^kube_deployment:dogstatsd-udp$`,
`^container_id:`,
`^container_name:dogstatsd$`,
`^display_container_name:dogstatsd`,
`^git.commit.sha:`, // org.opencontainers.image.revision docker image label
`^git.repository_url:https://github.com/DataDog/test-infra-definitions$`, // org.opencontainers.image.source docker image label
`^image_id:ghcr.io/datadog/apps-dogstatsd@sha256:`,
`^image_name:ghcr.io/datadog/apps-dogstatsd$`,
`^image_tag:main$`,
`^kube_container_name:dogstatsd$`,
`^kube_deployment:` + regexp.QuoteMeta(kubeDeployment) + `$`,
"^kube_namespace:" + regexp.QuoteMeta(kubeNamespace) + "$",
`^kube_ownerref_kind:replicaset$`,
`^kube_ownerref_name:dogstatsd-udp-[[:alnum:]]+$`,
`^kube_ownerref_name:` + regexp.QuoteMeta(kubeDeployment) + `-[[:alnum:]]+$`,
`^kube_qos:Burstable$`,
`^kube_replica_set:dogstatsd-udp-[[:alnum:]]+$`,
`^pod_name:dogstatsd-udp-[[:alnum:]]+-[[:alnum:]]+$`,
`^kube_replica_set:` + regexp.QuoteMeta(kubeDeployment) + `-[[:alnum:]]+$`,
`^pod_name:` + regexp.QuoteMeta(kubeDeployment) + `-[[:alnum:]]+-[[:alnum:]]+$`,
`^pod_phase:running$`,
`^series:`,
`^short_image:apps-dogstatsd$`,
},
},
})
Expand Down Expand Up @@ -911,41 +921,6 @@ func (suite *k8sSuite) testDogstatsdExternalData(kubeNamespace, kubeDeployment s
})
}

func (suite *k8sSuite) testDogstatsdContainerID(kubeNamespace, kubeDeployment string) {
suite.testMetric(&testMetricArgs{
Filter: testMetricFilterArgs{
Name: "custom.metric",
Tags: []string{
"^kube_deployment:" + regexp.QuoteMeta(kubeDeployment) + "$",
"^kube_namespace:" + regexp.QuoteMeta(kubeNamespace) + "$",
},
},
Expect: testMetricExpectArgs{
Tags: &[]string{
`^container_id:`,
`^container_name:dogstatsd$`,
`^display_container_name:dogstatsd`,
`^git.commit.sha:`, // org.opencontainers.image.revision docker image label
`^git.repository_url:https://github.com/DataDog/test-infra-definitions$`, // org.opencontainers.image.source docker image label
`^image_id:ghcr.io/datadog/apps-dogstatsd@sha256:`,
`^image_name:ghcr.io/datadog/apps-dogstatsd$`,
`^image_tag:main$`,
`^kube_container_name:dogstatsd$`,
`^kube_deployment:` + regexp.QuoteMeta(kubeDeployment) + `$`,
"^kube_namespace:" + regexp.QuoteMeta(kubeNamespace) + "$",
`^kube_ownerref_kind:replicaset$`,
`^kube_ownerref_name:` + regexp.QuoteMeta(kubeDeployment) + `-[[:alnum:]]+$`,
`^kube_qos:Burstable$`,
`^kube_replica_set:` + regexp.QuoteMeta(kubeDeployment) + `-[[:alnum:]]+$`,
`^pod_name:` + regexp.QuoteMeta(kubeDeployment) + `-[[:alnum:]]+-[[:alnum:]]+$`,
`^pod_phase:running$`,
`^series:`,
`^short_image:apps-dogstatsd$`,
},
},
})
}

func (suite *k8sSuite) TestPrometheus() {
// Test Prometheus check
suite.testMetric(&testMetricArgs{
Expand Down

0 comments on commit c3a01f3

Please sign in to comment.