Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions dependency-replacements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ replaces:
dependency: github.com/openshift/client-go
replacement: github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235

- comment: Use Grafana's patched k8sattributesprocessor with support for k8s.io/client-go v0.34.1
dependency: github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor
replacement: github.com/grafana/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.0.0-20251021125353-73458b01ab23

Comment on lines -104 to -107
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay for one less replacement, did this happen because upstream was on a lower version that has since been upgraded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Happened ~a couple months ago open-telemetry/opentelemetry-collector-contrib#43890

- comment: >
Do not remove until bug in walqueue backwards compatibility is resolved:
https://github.com/deneonet/benc/issues/13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ The `extract` block configures which metadata, annotations, and labels to extrac

The following attributes are supported:

| Name | Type | Description | Default | Required |
|--------------------|----------------|-----------------------------------------------------------------------------|-------------|----------|
| `metadata` | `list(string)` | Pre-configured metadata keys to add. | _See below_ | no |
| `otel_annotations` | `bool` | Whether to set the [recommended resource attributes][semantic conventions]. | `false` | no |
| Name | Type | Description | Default | Required |
|-----------------------------------|----------------|------------------------------------------------------------------------------------------|-------------|----------|
| `deployment_name_from_replicaset` | `bool` | Whether to set the deployment name by trimming the hash from the end of the replica set. | `false` | no |
| `metadata` | `list(string)` | Pre-configured metadata keys to add. | _See below_ | no |
| `otel_annotations` | `bool` | Whether to set the [recommended resource attributes][semantic conventions]. | `false` | no |

The supported `metadata` keys are:

Expand Down Expand Up @@ -194,6 +195,8 @@ By default, if `metadata` isn't specified, the following fields are extracted an

When `otel_annotations` is set to `true`, annotations such as `resource.opentelemetry.io/exampleResource` will be translated to the `exampleResource` resource attribute, etc.

When `deployment_name_from_replicaset` is set to `true`, the processor will extract deployment name from replicaset name by trimming pod template hash. This will disable watching for replicaset resources, which can be useful in environments with limited RBAC permissions as the processor will not need `get`, `watch`, and `list` permissions for replicasets.

[semantic conventions]: https://opentelemetry.io/docs/specs/semconv/non-normative/k8s-attributes

### `annotation`
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,6 @@ replace go.opentelemetry.io/ebpf-profiler => github.com/grafana/opentelemetry-eb
// Update openshift/client-go to version compatible with structured-merge-diff v6
replace github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235

// Use Grafana's patched k8sattributesprocessor with support for k8s.io/client-go v0.34.1
replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor => github.com/grafana/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.0.0-20251021125353-73458b01ab23

// Do not remove until bug in walqueue backwards compatibility is resolved: https://github.com/deneonet/benc/issues/13
replace github.com/deneonet/benc => github.com/deneonet/benc v1.1.7

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1158,8 +1158,6 @@ github.com/grafana/mysqld_exporter v0.17.2-0.20250226152553-be612e3fdedd h1:FW1K
github.com/grafana/mysqld_exporter v0.17.2-0.20250226152553-be612e3fdedd/go.mod h1:iEFA+REkm+0WRvVxy0cA1bBhJlFcQB998yymb45TqMU=
github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20251024135609-318b01780c89 h1:Ab3Z4AXC1Hffr4NbeYq0vTQhJbiGTTO2xd0ZV0kC1v8=
github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20251024135609-318b01780c89/go.mod h1:BUJCdmzfsndvLKeFuONqMPsEA0fkeVuAyt8II4Lk0Dg=
github.com/grafana/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.0.0-20251021125353-73458b01ab23 h1:Im1l5kbKfi61ySivYhUBkyWTqHNyAKiWO6rNKQJoNmU=
github.com/grafana/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.0.0-20251021125353-73458b01ab23/go.mod h1:7+xyIHr2PJNE9kic/D91c9SMxACdGIGCJykzTcqsYv0=
github.com/grafana/opentelemetry-collector/featuregate v0.0.0-20240325174506-2fd1623b2ca0 h1:i/Ne0XwoRokYj52ZcSmnvuyID3h/uA91n0Ycg/grHU8=
github.com/grafana/opentelemetry-collector/featuregate v0.0.0-20240325174506-2fd1623b2ca0/go.mod h1:mm8+xyQfgDmqhyegZRNIQmoKsNnDTwWKFLsdMoXAb7A=
github.com/grafana/opentelemetry-ebpf-instrumentation v1.3.13 h1:za+TpC0g0Iu7UYz0Q7rLbIzhsRLItZCuPr2pFeVhW/U=
Expand Down Expand Up @@ -1854,8 +1852,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometh
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.139.0/go.mod h1:/NDwJwHP4yBFL4B+vDah49ROKH1cro8BS7ThezFZinA=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.139.0 h1:ctfs8S1cQuhbXJVqSlAx8SxPmgFq2eOcllc7Pdpr9RE=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.139.0/go.mod h1:BduGmN98+nV2KObW0woovcuNwkSvSVLiPG6+Ww95uSk=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/xk8stest v0.138.0 h1:Fec1dyH3wRPjrvGN5qYLwkuXCAk4cAUcS5qGgDmT5OM=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/xk8stest v0.138.0/go.mod h1:o6eRn8JV22jyCPJcZ/NS3IeSB90E+0xBaL9Y/4NtPmY=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/xk8stest v0.139.0 h1:r2x9V8N8237yRfjqcboHinSQDYyFahQLpVAlrbNyf2Y=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/xk8stest v0.139.0/go.mod h1:UFk787D+Yk19nIthQqfznRz2tao4YF3WpdZ2+wBMDj0=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.139.0 h1:dhXq+slRSV2xt3sXA43jQgltM5qYF3vsOJkYyIir8Ws=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.139.0/go.mod h1:zFDjfoufAQFSxDP4FqY5HJv0xUVIV1sZm0mmfcCkUzY=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumulativetodeltaprocessor v0.139.0 h1:Wt1OMsFL4Ts1VoYNKISPsNeTlKsCD2//Fnhbm0oG/tY=
Expand All @@ -1868,6 +1866,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrs
github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor v0.139.0/go.mod h1:G3WduXLMn48lLkO6fNuBPhO3xPkEDJOJXGRcdGDewVM=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/intervalprocessor v0.139.0 h1:upeoL/u8sNMv2wILr0tJjS8D10PFbIZXhtmSvcTRzdU=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/intervalprocessor v0.139.0/go.mod h1:/YGA2DC8VSLBFAsycUPul9dkL5n8CcGXJ2rkKEyvNVg=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.139.0 h1:+/Tn0RTacKwmjtwl+dQiuIeYf3S5g9Aoqcq6u+jxoqY=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.139.0/go.mod h1:eaC5oqWFYOe/xDImeJkw3E5NIQ9Uf93wLxqrR7kKHKg=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor v0.139.0 h1:yMINTAhwrAFBg+4dmR2241egJAdOjD3x9BSnyMkwNiM=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor v0.139.0/go.mod h1:rZJSbBQCdMjBmxTwTwaXpStHOyB0lWa5nP8JKqD0ME0=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.139.0 h1:ODYstgINw1NuHiUdUPJOSkRfaJTvRvyqEzCF4m2XGLg=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func Test_Extract(t *testing.T) {
"k8s.job.name",
"k8s.node.name",
]
deployment_name_from_replicaset = true
}
output {
Expand All @@ -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)
}

func Test_ExtractAnnotations(t *testing.T) {
Expand Down
18 changes: 10 additions & 8 deletions internal/component/otelcol/processor/k8sattributes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ func (args FieldExtractConfig) convert() map[string]interface{} {
}

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{} {
Expand All @@ -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,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ func toK8SAttributesProcessor(state *State, id componentstatus.InstanceID, cfg *
AuthType: string(cfg.AuthType),
Passthrough: cfg.Passthrough,
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,
},
Filter: k8sattributes.FilterConfig{
Node: cfg.Filter.Node,
Expand Down
Loading