Description
Component(s)
receiver/azuremonitor
Is your feature request related to a problem? Please describe.
This is related to the issue #38908.
The azureauthextension
implements the interface azcore.TokenCredential
. So it can be used instead of creating a new azure identity using auth
and any related fields.
Using the azureauthextension
, the token credential can be shared among multiple receivers, instead of creating identities for each receiver used.
Describe the solution you'd like
The proposed feature would require either auth
and its related fields to be filled, or token_provider
(I have used token_provider
name, since auth
is taken). Once the receiver starts, it looks for that extension and then uses it to get credentials. The configuration using azureauthextension
with the receiver would be a bit like this (very simple set up):
receivers:
azuremonitor:
discover_subscriptions: true
token_provider: azureauth
extensions:
azureauth:
# See options in https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/azureauthextension#azure-authenticator-extension
managed_identity:
client_id: ${CLIENT_ID}
exporters:
debug:
verbosity: detailed
service:
extensions:
- azureauth
telemetry:
logs:
level: debug
pipelines:
metrics:
receivers: [azuremonitor]
exporters: [debug]
Describe alternatives you've considered
N/A
Additional context
You can find in my branch main...constanca-m:opentelemetry-collector-contrib:azuremonitorreceiver-add-support-azureauth the needed changes to support this feature. It's a rough draft, but everything should work well. Using the set up I shared before, you should be able to have the collector working well:
$ ./collector --config config.yaml
2025-03-30T20:01:33.247+0200 info [email protected]/service.go:193 Setting up own telemetry...
2025-03-30T20:01:33.248+0200 info builders/builders.go:26 Development component. May change in the future. {"otelcol.component.id": "debug", "otelcol.component.kind": "Exporter", "otelcol.signal": "metrics"}
2025-03-30T20:01:33.248+0200 info builders/extension.go:50 Development component. May change in the future. {"otelcol.component.id": "azureauth", "otelcol.component.kind": "Extension"}
2025-03-30T20:01:33.249+0200 info [email protected]/service.go:260 Starting ... {"Version": "v0.0.0", "NumCPU": 16}
2025-03-30T20:01:33.249+0200 info extensions/extensions.go:40 Starting extensions...
2025-03-30T20:01:33.249+0200 info extensions/extensions.go:44 Extension is starting... {"otelcol.component.id": "azureauth", "otelcol.component.kind": "Extension"}
2025-03-30T20:01:33.249+0200 info extensions/extensions.go:61 Extension started. {"otelcol.component.id": "azureauth", "otelcol.component.kind": "Extension"}
2025-03-30T20:01:33.249+0200 info azuremonitorreceiver/scraper.go:186 'token_provider' will be used to get the token credential {"otelcol.component.id": "azuremonitor", "otelcol.component.kind": "Receiver", "otelcol.signal": "metrics"} <-------- The new token_provider configuration
2025-03-30T20:01:33.249+0200 info [email protected]/service.go:283 Everything is ready. Begin running and processing data.
2025-03-30T20:01:34.249+0200 info Metrics {"otelcol.component.id": "debug", "otelcol.component.kind": "Exporter", "otelcol.signal": "metrics", "resource metrics": 0, "metrics": 0, "data points": 0}
2025-03-30T20:01:34.250+0200 info {"otelcol.component.id": "debug", "otelcol.component.kind": "Exporter", "otelcol.signal": "metric