Skip to content

Commit

Permalink
datadog: metrics improvements and trace correlations (#2098)
Browse files Browse the repository at this point in the history
  • Loading branch information
edeNFed authored Jan 2, 2025
1 parent 7ad98e8 commit b3e7faa
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 8 deletions.
39 changes: 38 additions & 1 deletion autoscaler/controllers/datacollection/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,45 @@ func calculateConfigMapData(nodeCG *odigosv1.CollectorsGroup, sources *odigosv1.
"collection_interval": "10s",
}

cfg.Receivers["hostmetrics"] = config.GenericMap{
"collection_interval": "10s",
"root_path": "/hostfs",
"scrapers": config.GenericMap{
"paging": config.GenericMap{
"metrics": config.GenericMap{
"system.paging.utilization": config.GenericMap{
"enabled": true,
},
},
},
"cpu": config.GenericMap{
"metrics": config.GenericMap{
"system.cpu.utilization": config.GenericMap{
"enabled": true,
},
},
},
"disk": struct{}{},
"filesystem": config.GenericMap{
"metrics": config.GenericMap{
"system.filesystem.utilization": config.GenericMap{
"enabled": true,
},
},
"exclude_mount_points": config.GenericMap{
"match_type": "regexp",
"mount_points": []string{"/var/lib/kubelet/*"},
},
},
"load": struct{}{},
"memory": struct{}{},
"network": struct{}{},
"processes": struct{}{},
},
}

cfg.Service.Pipelines["metrics"] = config.Pipeline{
Receivers: []string{"otlp", "kubeletstats"},
Receivers: []string{"otlp", "kubeletstats", "hostmetrics"},
Processors: append(commonProcessors, metricsProcessors...),
Exporters: []string{"otlp/gateway"},
}
Expand Down
13 changes: 13 additions & 0 deletions autoscaler/controllers/datacollection/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ func getDesiredDaemonSet(datacollection *odigosv1.CollectorsGroup,
},
},
},
{
Name: "hostfs",
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/",
},
},
},
},
Containers: []corev1.Container{
{
Expand All @@ -287,6 +295,11 @@ func getDesiredDaemonSet(datacollection *odigosv1.CollectorsGroup,
MountPath: "/var/lib/kubelet/pod-resources",
ReadOnly: true,
},
{
Name: "hostfs",
MountPath: "/hostfs",
ReadOnly: true,
},
},
Env: []corev1.EnvVar{
{
Expand Down
1 change: 1 addition & 0 deletions collector/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ receivers:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.106.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.106.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver v0.106.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.106.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.106.0

# https://github.com/open-telemetry/opentelemetry-collector/issues/8127
Expand Down
3 changes: 3 additions & 0 deletions collector/odigosotelcol/components.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions collector/odigosotelcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.106.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.106.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.106.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.106.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver v0.106.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.106.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.106.0
Expand Down Expand Up @@ -451,6 +452,7 @@ require (
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
github.com/prometheus-community/windows_exporter v0.25.1 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
Expand Down
6 changes: 3 additions & 3 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ type Config struct {
Exporters GenericMap `json:"exporters"`
Processors GenericMap `json:"processors"`
Extensions GenericMap `json:"extensions"`
Connectors GenericMap `json:"connectors"`
Connectors GenericMap `json:"connectors,omitempty"`
Service Service `json:"service"`
}

type Telemetry struct {
Metrics GenericMap `json:"metrics"`
Metrics GenericMap `json:"metrics"`
Resource map[string]*string `json:"resource"`
}

type Service struct {
Extensions []string `json:"extensions"`
Pipelines map[string]Pipeline `json:"pipelines"`
Telemetry Telemetry `json:"telemetry,omitempty"`
Telemetry Telemetry `json:"telemetry,omitempty"`
}

type Pipeline struct {
Expand Down
19 changes: 18 additions & 1 deletion common/config/datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,33 @@ func (d *Datadog) ModifyConfig(dest ExporterConfigurer, currentConfig *Config) e
},
}

connectorEnabled := false
connectorName := "datadog/connector-" + dest.GetID()
if isTracingEnabled(dest) && isMetricsEnabled(dest) {
currentConfig.Connectors[connectorName] = struct{}{}
connectorEnabled = true
}

if isTracingEnabled(dest) {
tracesPipelineName := "traces/datadog-" + dest.GetID()
exporters := []string{exporterName}
if connectorEnabled {
exporters = append(exporters, connectorName)
}

currentConfig.Service.Pipelines[tracesPipelineName] = Pipeline{
Exporters: []string{exporterName},
Exporters: exporters,
}
}

if isMetricsEnabled(dest) {
metricsPipelineName := "metrics/datadog-" + dest.GetID()
var receivers []string
if connectorEnabled {
receivers = []string{connectorName}
}
currentConfig.Service.Pipelines[metricsPipelineName] = Pipeline{
Receivers: receivers,
Exporters: []string{exporterName},
}
}
Expand Down
1 change: 0 additions & 1 deletion common/config/testdata/debugexporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ extensions:
health_check:
endpoint: 0.0.0.0:13133
pprof: {}
connectors: {}
service:
extensions:
- health_check
Expand Down
1 change: 0 additions & 1 deletion common/config/testdata/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ extensions:
health_check:
endpoint: 0.0.0.0:13133
pprof: {}
connectors: {}
service:
extensions:
- health_check
Expand Down
1 change: 0 additions & 1 deletion common/config/testdata/withbaseminimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exporters: {}
processors:
batch: {}
extensions: {}
connectors: {}
service:
extensions: []
pipelines: {}
7 changes: 7 additions & 0 deletions tests/common/assert/pipeline-ready.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ spec:
- mountPath: /var/lib/kubelet/pod-resources
name: kubeletpodresources
readOnly: true
- mountPath: /hostfs
name: hostfs
readOnly: true
env:
- name: NODE_NAME
valueFrom:
Expand Down Expand Up @@ -193,6 +196,10 @@ spec:
path: /var/lib/kubelet/pod-resources
type: ""
name: kubeletpodresources
- hostPath:
path: /
type: ""
name: hostfs
status:
numberAvailable: 1
numberReady: 1

0 comments on commit b3e7faa

Please sign in to comment.