Skip to content

chore: backport #5183#5184

Merged
dehaansa merged 1 commit intorelease/v1.12from
backport/pr-5183-to-v1.12
Jan 6, 2026
Merged

chore: backport #5183#5184
dehaansa merged 1 commit intorelease/v1.12from
backport/pr-5183-to-v1.12

Conversation

@grafana-alloybot
Copy link
Contributor

@grafana-alloybot grafana-alloybot bot commented Jan 6, 2026

Backport of #5183

This PR backports #5183 to release/v1.12.

Original PR Title

feat: Add missing configuration parameter deployment_name_from_replicaset to k8sattributes processor

Original PR Author

@dehaansa

Description

Brief description of Pull Request

Add deployment_name_from_replicaset attribute to k8sattributes processor supporting extraction of deployment name from replica set.

Pull Request Details

Issue(s) fixed by this Pull Request

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

This backport was created automatically.

BEGIN_COMMIT_OVERRIDE
fix: Add missing configuration parameter deployment_name_from_replicaset to k8sattributes processor
END_COMMIT_OVERRIDE

…caset` to k8sattributes processor (#5183)

Add missing configuration parameter to k8sattributes processor

(cherry picked from commit b54ca77)
@grafana-alloybot grafana-alloybot bot requested review from a team and clayton-cornell as code owners January 6, 2026 20:46
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

💻 Deploy preview available (chore: Backport #5183):

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

🔍 Dependency Review

github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor (grafana fork replacement) → github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.139.0 — ⚠️ Needs Review

Summary:

  • The custom replace to Grafana’s fork has been removed, switching back to upstream k8sattributesprocessor at v0.139.0.
  • Upstream includes a new config option to infer deployment name directly from ReplicaSet names, avoiding ReplicaSet watches.
  • Your PR already includes the required integration changes: config type, conversion, tests, and docs.

Potential impacts to verify:

  • If you relied on any fork-specific behavior beyond client-go compatibility, confirm upstream parity. The new upstream option helps in restricted RBAC environments by avoiding ReplicaSet list/watch.

Relevant upstream config (evidence):

// (From k8sattributesprocessor config in upstream contrib v0.139.0)
type ExtractConfig struct {
    // ...
    DeploymentNameFromReplicaSet bool `mapstructure:"deployment_name_from_replicaset"`
}

Code changes to adopt (already present in this PR):

  • Add the new field to your component config and pass it through to the processor config:
--- a/internal/component/otelcol/processor/k8sattributes/types.go
+++ b/internal/component/otelcol/processor/k8sattributes/types.go
@@ -17,10 +17,11 @@
 type ExtractConfig struct {
-   Metadata        []string             `alloy:"metadata,attr,optional"`
-   Annotations     []FieldExtractConfig `alloy:"annotation,block,optional"`
-   Labels          []FieldExtractConfig `alloy:"label,block,optional"`
-   OtelAnnotations bool                 `alloy:"otel_annotations,attr,optional"`
+   Metadata                     []string             `alloy:"metadata,attr,optional"`
+   Annotations                  []FieldExtractConfig `alloy:"annotation,block,optional"`
+   Labels                       []FieldExtractConfig `alloy:"label,block,optional"`
+   OtelAnnotations              bool                 `alloy:"otel_annotations,attr,optional"`
+   DeploymentNameFromReplicaSet bool                 `alloy:"deployment_name_from_replicaset,attr,optional"`
 }
 
 func (args ExtractConfig) convert() map[string]interface{} {
@@ -36,10 +37,11 @@ func (args ExtractConfig) convert() map[string]interface{} {
     return map[string]interface{}{
-       "metadata":         args.Metadata,
-       "annotations":      annotations,
-       "labels":           labels,
-       "otel_annotations": args.OtelAnnotations,
+       "metadata":                        args.Metadata,
+       "annotations":                     annotations,
+       "labels":                          labels,
+       "otel_annotations":                args.OtelAnnotations,
+       "deployment_name_from_replicaset": args.DeploymentNameFromReplicaSet,
     }
 }
  • Ensure the converter passes the field through:
--- a/internal/converter/internal/otelcolconvert/converter_k8sattributesprocessor.go
+++ b/internal/converter/internal/otelcolconvert/converter_k8sattributesprocessor.go
@@ -55,10 +55,11 @@ func toK8SAttributesProcessor(...){
        ExtractConfig: k8sattributes.ExtractConfig{
-           Metadata:        cfg.Extract.Metadata,
-           Annotations:     toFilterExtract(cfg.Extract.Annotations),
-           Labels:          toFilterExtract(cfg.Extract.Labels),
-           OtelAnnotations: cfg.Extract.OtelAnnotations,
+           Metadata:                     cfg.Extract.Metadata,
+           Annotations:                  toFilterExtract(cfg.Extract.Annotations),
+           Labels:                       toFilterExtract(cfg.Extract.Labels),
+           OtelAnnotations:              cfg.Extract.OtelAnnotations,
+           DeploymentNameFromReplicaSet: cfg.Extract.DeploymentNameFromReplicaSet,
        },
  • Test coverage adjustments (already added in this PR):
--- a/internal/component/otelcol/processor/k8sattributes/k8sattributes_test.go
+++ b/internal/component/otelcol/processor/k8sattributes/k8sattributes_test.go
@@ -26,6 +26,8 @@ func Test_Extract(t *testing.T) {
            "k8s.node.name",
        ]
+
+       deployment_name_from_replicaset = true
     }
@@ -44,6 +46,8 @@ func Test_Extract(t *testing.T) {
     extract := &otelObj.Extract
     require.Equal(t, []string{"k8s.namespace.name", "k8s.job.name", "k8s.node.name"}, extract.Metadata)
+
+    require.True(t, extract.DeploymentNameFromReplicaSet)
 }
  • Documentation updates (already added in this PR):
    • New option: deployment_name_from_replicaset with behavior and RBAC implications.

Operational note:

  • When deployment_name_from_replicaset = true, you can reduce RBAC for ReplicaSets (no get/watch/list needed), relying on name parsing of ReplicaSet to infer the Deployment name. Verify this matches your cluster naming and RBAC constraints.

Action items for maintainers:

  • Confirm there is no remaining reliance on Grafana-fork-only behavior.
  • Validate in environments with restricted RBAC that setting the new option preserves expected attributes.
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/xk8stest v0.138.0 → v0.139.0 — ✅ Safe

Summary:

  • Test helper package version bump aligned with upstream contrib release.
  • No production code changes required in this repository.

Notes:

  • This is typically used by upstream for testing; your repository does not appear to import it directly. No action needed.

Notes

  • The replace directive to the Grafana fork of k8sattributesprocessor has been removed, consolidating on upstream. Ensure your CI runs cover scenarios that previously motivated the fork (e.g., client-go compatibility and RBAC-restricted clusters).

@dehaansa dehaansa changed the title chore: Backport #5183 chore: backport #5183 Jan 6, 2026
@dehaansa dehaansa merged commit 5b90a9d into release/v1.12 Jan 6, 2026
43 of 44 checks passed
@dehaansa dehaansa deleted the backport/pr-5183-to-v1.12 branch January 6, 2026 21:07
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

💻 Deploy preview deleted (chore: backport #5183).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant