Skip to content

Commit

Permalink
Merge pull request #34 from kube-logging/all-labels
Browse files Browse the repository at this point in the history
feat: extract all labels from pods
  • Loading branch information
kristofgyuracz authored Feb 14, 2024
2 parents cc58a64 + 883574a commit 7524a91
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/controller/telemetry/collector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (r *CollectorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

collector.Status.Tenants = tenantNames

if reflect.DeepEqual(*originalCollectorStatus, collector.Status) {
if !reflect.DeepEqual(*originalCollectorStatus, collector.Status) {
logger.Info("updating collector status")
err = r.Status().Update(ctx, collector)
if err != nil {
Expand Down
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 7524a91

Please sign in to comment.