diff --git a/components/datadog/agent/kubernetes_helm.go b/components/datadog/agent/kubernetes_helm.go index 4f476ba9d..c5e42d32b 100644 --- a/components/datadog/agent/kubernetes_helm.go +++ b/components/datadog/agent/kubernetes_helm.go @@ -223,6 +223,9 @@ func buildLinuxHelmValues(baseName, agentImagePath, agentImageTag, clusterAgentI "namespaceLabelsAsTags": pulumi.Map{ "related_team": pulumi.String("team"), }, + "originDetectionUnified": pulumi.Map{ + "enabled": pulumi.Bool(true), + }, "namespaceAnnotationsAsTags": pulumi.Map{ "related_email": pulumi.String("email"), // should be overridden by kubernetesResourcesAnnotationsAsTags }, diff --git a/components/datadog/apps/dogstatsd/images/dogstatsd/main.go b/components/datadog/apps/dogstatsd/images/dogstatsd/main.go index b43ff2c90..1112c914c 100644 --- a/components/datadog/apps/dogstatsd/images/dogstatsd/main.go +++ b/components/datadog/apps/dogstatsd/images/dogstatsd/main.go @@ -6,6 +6,7 @@ import ( "io" "log" "math" + "net" "net/http" "os" "os/signal" @@ -48,6 +49,30 @@ func main() { nbSeries := flag.Uint("nb-series", 10, "Number of time series to emit") flag.Parse() + // To test only the external data, we can set the DD_EXTERNAL_DATA_ONLY environment variable to true. + // Instead of using the DogStatsD client, we will send data directly to the agent. + // We need to do this as is it not possible to disable local data in the DogStatsD client. + if v, ok := os.LookupEnv("DD_EXTERNAL_DATA_ONLY"); ok && v == "true" { + conn, err := net.Dial("udp", os.Getenv("STATSD_URL")) + if err != nil { + log.Fatal(err) + return + } + defer conn.Close() + + for { + for i := uint(0); i < *nbSeries; i++ { + value := math.Sin(2 * math.Pi * (float64(time.Now().Unix())/period.Seconds() + float64(i)/float64(*nbSeries))) + _, err = conn.Write([]byte(fmt.Sprintf("custom.metric:%f|g|e:%s|series:%d", value, os.Getenv("DD_EXTERNAL_ENV"), i))) + if err != nil { + log.Fatal(err) + return + } + time.Sleep(1 * time.Second) + } + } + } + c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR1, syscall.SIGUSR2) diff --git a/components/datadog/apps/dogstatsd/k8s.go b/components/datadog/apps/dogstatsd/k8s.go index 73c2a3770..8b2cd3aa5 100644 --- a/components/datadog/apps/dogstatsd/k8s.go +++ b/components/datadog/apps/dogstatsd/k8s.go @@ -298,5 +298,77 @@ func K8sAppDefinition(e config.Env, kubeProvider *kubernetes.Provider, namespace return nil, err } + if _, err := appsv1.NewDeployment(e.Ctx(), fmt.Sprintf("dogstatsd-udp-external-data-only-%d", statsdPort), &appsv1.DeploymentArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Name: pulumi.String("dogstatsd-udp-external-data-only"), + Namespace: pulumi.String(namespace), + Labels: pulumi.StringMap{ + "app": pulumi.String("dogstatsd-udp-external-data-only"), + }, + }, + Spec: &appsv1.DeploymentSpecArgs{ + Replicas: pulumi.Int(1), + Selector: &metav1.LabelSelectorArgs{ + MatchLabels: pulumi.StringMap{ + "app": pulumi.String("dogstatsd-udp-external-data-only"), + }, + }, + Template: &corev1.PodTemplateSpecArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Labels: pulumi.StringMap{ + "app": pulumi.String("dogstatsd-udp-external-data-only"), + "admission.datadoghq.com/enabled": pulumi.String("true"), + }, + }, + Spec: &corev1.PodSpecArgs{ + Containers: corev1.ContainerArray{ + &corev1.ContainerArgs{ + Name: pulumi.String("dogstatsd"), + Image: pulumi.String("ghcr.io/datadog/apps-dogstatsd:main"), + Env: &corev1.EnvVarArray{ + &corev1.EnvVarArgs{ + Name: pulumi.String("HOST_IP"), + ValueFrom: &corev1.EnvVarSourceArgs{ + FieldRef: &corev1.ObjectFieldSelectorArgs{ + FieldPath: pulumi.String("status.hostIP"), + }, + }, + }, + &corev1.EnvVarArgs{ + Name: pulumi.String("STATSD_URL"), + Value: pulumi.Sprintf("$(HOST_IP):%d", statsdPort), + }, + &corev1.EnvVarArgs{ + Name: pulumi.String("DD_ENTITY_ID"), + ValueFrom: &corev1.EnvVarSourceArgs{ + FieldRef: &corev1.ObjectFieldSelectorArgs{ + FieldPath: pulumi.String("metadata.uid"), + }, + }, + }, + &corev1.EnvVarArgs{ + Name: pulumi.String("DD_EXTERNAL_DATA_ONLY"), + Value: pulumi.String("true"), + }, + }, + Resources: &corev1.ResourceRequirementsArgs{ + Limits: pulumi.StringMap{ + "cpu": pulumi.String("10m"), + "memory": pulumi.String("32Mi"), + }, + Requests: pulumi.StringMap{ + "cpu": pulumi.String("2m"), + "memory": pulumi.String("32Mi"), + }, + }, + }, + }, + }, + }, + }, + }, opts...); err != nil { + return nil, err + } + return k8sComponent, nil }