Skip to content

Commit

Permalink
feat: extract all labels from pods
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofgyuracz committed Feb 14, 2024
1 parent cc58a64 commit 6e8c122
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ processors:
k8sattributes:
auth_type: serviceAccount
extract:
labels:
- from: pod
key_regex: .*
tag_name: all_labels
metadata:
- k8s.pod.name
- k8s.pod.uid
Expand Down
9 changes: 9 additions & 0 deletions internal/controller/telemetry/otel_conf_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,20 @@ func (cfgInput *OtelColConfigInput) generateDefaultKubernetesProcessor() map[str
"k8s.pod.start_time",
}

var defaultLabels = []map[string]string{
{
"from": "pod",
"tag_name": "all_labels",
"key_regex": ".*",
},
}

k8sProcessor := map[string]any{
"auth_type": "serviceAccount",
"passthrough": false,
"extract": map[string]any{
"metadata": defaultMetadata,
"labels": defaultLabels,
},
"pod_association": defaultPodAssociation,
}
Expand Down
6 changes: 1 addition & 5 deletions internal/controller/telemetry/otel_conf_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,10 @@ func TestOtelColConfComplex(t *testing.T) {
generatedIR := inputCfg.ToIntermediateRepresentation()

// Final YAML
generatedYAML, err := generatedIR.ToYAML()
_, err := generatedIR.ToYAML()
if err != nil {
t.Fatalf("YAML formatting failed, err=%v", err)
}
t.Logf(`the generated YAML is:
---
%v
---`, generatedYAML)

actualYAMLBytes, err := generatedIR.ToYAMLRepresentation()
if err != nil {
Expand Down

0 comments on commit 6e8c122

Please sign in to comment.