Skip to content

Commit f966c49

Browse files
feat: Add service name and namespace to the k8sattributes processor (#3954)
* feat: Add service name and namespace to the k8sattributes processor * Add the service name and namespace to the expected labels * Increasing resources for testing the logs daemonset
1 parent 7f5eb42 commit f966c49

File tree

6 files changed

+36
-1
lines changed

6 files changed

+36
-1
lines changed

.changelog/3954.added.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: Add service name and namespace to the k8sattributes processor

deploy/helm/sumologic/conf/logs/otelcol/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ processors:
347347
- k8s.statefulset.name
348348
- k8s.namespace.name
349349
- k8s.node.name
350+
- service.name
351+
- service.namespace
350352
## Has to be false to enrich metadata
351353
passthrough: false
352354
pod_association:

deploy/helm/sumologic/conf/metrics/otelcol/processors.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ k8sattributes:
7272
- k8s.statefulset.name
7373
- k8s.namespace.name
7474
- k8s.node.name
75+
- service.name
76+
- service.namespace
7577
## Has to be false to enrich metadata
7678
passthrough: false
7779
pod_association:

tests/helm/testdata/goldenfile/metadata_logs_otc/k8sattributes.output.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ data:
180180
- k8s.statefulset.name
181181
- k8s.namespace.name
182182
- k8s.node.name
183+
- service.name
184+
- service.namespace
183185
passthrough: false
184186
pod_association:
185187
- sources:

tests/integration/features.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type MetricsCollector string
3232

3333
const (
3434
tickDuration = 3 * time.Second
35-
waitDuration = 1 * time.Minute
35+
waitDuration = 2 * time.Minute
3636
// number determined experimentally
3737
expectedEventCount uint = 50
3838
logsGeneratorCount uint = 1000
@@ -107,6 +107,8 @@ func GetMetricsK8sattributes(expectedMetrics []string, metricsCollector MetricsC
107107
"pod_labels_pod-template-hash": ".+",
108108
"pod": podList.Items[0].Name,
109109
"replicaset": fmt.Sprintf("%s-.*", deployment),
110+
"service": deployment,
111+
"service.namespace": ctxopts.Namespace(ctx),
110112
}
111113
expectedLabels = addCollectorSpecificMetricLabels(expectedLabels, releaseName, namespace, metricsCollector)
112114

tests/integration/values/values_common.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,28 @@ otellogs:
123123
journald:
124124
directory: /run/log/journal
125125
daemonset:
126+
containers:
127+
otelcol:
128+
livenessProbe:
129+
initialDelaySeconds: 15
130+
periodSeconds: 15
131+
timeoutSeconds: 10
132+
failureThreshold: 3
133+
readinessProbe:
134+
initialDelaySeconds: 5
135+
periodSeconds: 10
136+
timeoutSeconds: 3
137+
failureThreshold: 3
138+
startupProbe:
139+
periodSeconds: 3
140+
failureThreshold: 60
141+
resources:
142+
limits:
143+
memory: 1Gi
144+
cpu: 1000m
145+
requests:
146+
memory: 64Mi
147+
cpu: 500m
126148
extraVolumeMounts:
127149
- mountPath: /run/log/journal
128150
name: run-log-journal
@@ -159,4 +181,8 @@ debug:
159181
resources:
160182
limits:
161183
memory: 5Gi # unlimited
184+
cpu: 1000m
185+
requests:
186+
memory: 1000Mi
187+
cpu: 500m
162188
enableLocalMode: true

0 commit comments

Comments
 (0)