Add resources under spec.telemetry.metrics.sinks.openTelemetry to inject custom OTEL resource attributes
#6,978 创建于 2025年9月16日
仓库指标
- Star
- (2,871 star)
- PR 合并指标
- (PR 指标待抓取)
描述
Context / Discussion
This was discussed in Slack with @arkodg and @JianpengHe. Maintainers confirmed that it’s fine to add this field and suggested raising a GitHub issue to track.
Problem
Currently, the EnvoyProxy CRD supports custom OpenTelemetry resource attributes for access logs:
spec.telemetry.accessLog.settings.sinks.openTelemetry.resources
However, there is no equivalent for metrics under spec.telemetry.metrics. Users who want consistent resource attributes (e.g., service.name, team, environment) in metrics must mutate them downstream in the OpenTelemetry Collector using resource or attributes processors. This adds operational complexity and can lead to inconsistency across clusters.
Proposed Solution Introduce a new optional resources field under spec.telemetry.metrics.sinks.openTelemetry, similar to access logs.
Example:
spec:
telemetry:
metrics:
sinks:
- type: OpenTelemetry
openTelemetry:
host: otel-collector.monitoring.svc.cluster.local
port: 4317
resources:
service.name: eg-gateway
team: marketing
environment: production
Benefits
Aligns logs and metrics resource configuration. Reduces the need for downstream Collector mutations. Backward compatible (optional field, no impact if unset).
Alternatives Considered
Continue using the Collector resource or attributes processors to inject resource attributes, but this increases deployment complexity and does not align logs and metrics configuration in the CRD.