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
27 changes: 27 additions & 0 deletions .chloggen/azuremonitorexporter-add-authenticator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: exporter/azuremonitor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add authenticator extension support to the Azure Monitor exporter."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [41004]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
12 changes: 12 additions & 0 deletions exporter/azuremonitorexporter/AUTHENTICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ exporters:
connection_string: ${env:APPLICATIONINSIGHTS_CONNECTION_STRING}
```
## Authenticator Extension
You can use any standard OTEL authenticator extension to add authentication to outgoing requests.
This is an example using [azureauthextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/azureauthextension):
```yaml
exporters:
azuremonitor:
auth:
authenticator: azureauth
```
## AAD/Entra Authentication
Local Authentication can be disabled in [Application Insights](https://learn.microsoft.com/en-us/azure/azure-monitor/app/azure-ad-authentication) and an AAD based identity can be used in conjunction with the instrumentation key.
Expand Down
9 changes: 7 additions & 2 deletions exporter/azuremonitorexporter/azuremonitor_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,24 @@ import (
type azureMonitorExporter struct {
config *Config
transportChannel appinsights.TelemetryChannel
settings component.TelemetrySettings
logger *zap.Logger
packer *metricPacker
}

func (exporter *azureMonitorExporter) Start(_ context.Context, _ component.Host) (err error) {
func (exporter *azureMonitorExporter) Start(ctx context.Context, host component.Host) (err error) {
connectionVars, err := parseConnectionString(exporter.config)
if err != nil {
return err
}

exporter.config.InstrumentationKey = configopaque.String(connectionVars.InstrumentationKey)
exporter.config.Endpoint = connectionVars.IngestionURL
exporter.config.ClientConfig.Endpoint = connectionVars.IngestionURL
telemetryConfiguration := appinsights.NewTelemetryConfiguration(connectionVars.InstrumentationKey)
telemetryConfiguration.Client, err = exporter.config.ClientConfig.ToClient(ctx, host, exporter.settings)
if err != nil {
return err
}
telemetryConfiguration.EndpointUrl = connectionVars.IngestionURL
telemetryConfiguration.MaxBatchSize = exporter.config.MaxBatchSize
telemetryConfiguration.MaxBatchInterval = exporter.config.MaxBatchInterval
Expand Down
3 changes: 2 additions & 1 deletion exporter/azuremonitorexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ package azuremonitorexporter // import "github.com/open-telemetry/opentelemetry-
import (
"time"

"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

// Config defines configuration for Azure Monitor
type Config struct {
QueueSettings exporterhelper.QueueBatchConfig `mapstructure:"sending_queue"`
Endpoint string `mapstructure:"endpoint"`
ConnectionString configopaque.String `mapstructure:"connection_string"`
InstrumentationKey configopaque.String `mapstructure:"instrumentation_key"`
MaxBatchSize int `mapstructure:"maxbatchsize"`
Expand All @@ -22,4 +22,5 @@ type Config struct {
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout"`
CustomEventsEnabled bool `mapstructure:"custom_events_enabled"`
ExceptionEventsEnabled bool `mapstructure:"exception_events_enabled"`
ClientConfig confighttp.ClientConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
}
5 changes: 4 additions & 1 deletion exporter/azuremonitorexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/confmap/xconfmap"
"go.opentelemetry.io/collector/exporter/exporterhelper"
Expand All @@ -37,12 +38,14 @@ func TestLoadConfig(t *testing.T) {
{
id: component.NewIDWithName(metadata.Type, "2"),
expected: &Config{
Endpoint: "https://dc.services.visualstudio.com/v2/track",
ConnectionString: "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://ingestion.azuremonitor.com/",
InstrumentationKey: "00000000-0000-0000-0000-000000000000",
MaxBatchSize: 100,
MaxBatchInterval: 10 * time.Second,
SpanEventsEnabled: false,
ClientConfig: confighttp.ClientConfig{
Endpoint: "https://dc.services.visualstudio.com/v2/track",
},
QueueSettings: func() exporterhelper.QueueBatchConfig {
queue := exporterhelper.NewDefaultQueueConfig()
queue.QueueSize = 1000
Expand Down
4 changes: 2 additions & 2 deletions exporter/azuremonitorexporter/connection_string_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ func parseConnectionString(exporterConfig *Config) (*connectionVars, error) {
}
if connectionString == "" {
connectionVars.InstrumentationKey = instrumentationKey
if exporterConfig.Endpoint == "" {
if exporterConfig.ClientConfig.Endpoint == "" {
connectionVars.IngestionURL = getIngestionURL(DefaultIngestionEndpoint)
} else {
connectionVars.IngestionURL = getIngestionURL(exporterConfig.Endpoint)
connectionVars.IngestionURL = getIngestionURL(exporterConfig.ClientConfig.Endpoint)
}
return connectionVars, nil
}
Expand Down
7 changes: 4 additions & 3 deletions exporter/azuremonitorexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ func getOrCreateAzureMonitorExporter(cfg component.Config, set exporter.Settings
conf := cfg.(*Config)
ame := exporters.GetOrAdd(set.ID, func() component.Component {
return &azureMonitorExporter{
config: conf,
logger: set.Logger,
packer: newMetricPacker(set.Logger),
config: conf,
logger: set.Logger,
packer: newMetricPacker(set.Logger),
settings: set.TelemetrySettings,
}
})

Expand Down
17 changes: 17 additions & 0 deletions exporter/azuremonitorexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/stretchr/testify v1.11.1
go.opentelemetry.io/collector/component v1.44.0
go.opentelemetry.io/collector/component/componenttest v0.138.0
go.opentelemetry.io/collector/config/confighttp v0.138.0
go.opentelemetry.io/collector/config/configopaque v1.44.0
go.opentelemetry.io/collector/confmap v1.44.0
go.opentelemetry.io/collector/confmap/xconfmap v0.138.0
Expand All @@ -25,33 +26,47 @@ require (
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/foxboron/go-tpm-keyfiles v0.0.0-20250903184740-5d135037bd4d // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/google/go-tpm v0.9.6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/knadh/koanf/maps v0.1.2 // indirect
github.com/knadh/koanf/providers/confmap v1.0.0 // indirect
github.com/knadh/koanf/v2 v2.3.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/collector/client v1.44.0 // indirect
go.opentelemetry.io/collector/config/configauth v1.44.0 // indirect
go.opentelemetry.io/collector/config/configcompression v1.44.0 // indirect
go.opentelemetry.io/collector/config/configmiddleware v1.44.0 // indirect
go.opentelemetry.io/collector/config/configoptional v1.44.0 // indirect
go.opentelemetry.io/collector/config/configretry v1.44.0 // indirect
go.opentelemetry.io/collector/config/configtls v1.44.0 // indirect
go.opentelemetry.io/collector/consumer v1.44.0 // indirect
go.opentelemetry.io/collector/consumer/consumertest v0.138.0 // indirect
go.opentelemetry.io/collector/consumer/xconsumer v0.138.0 // indirect
go.opentelemetry.io/collector/exporter/xexporter v0.138.0 // indirect
go.opentelemetry.io/collector/extension v1.44.0 // indirect
go.opentelemetry.io/collector/extension/extensionauth v1.44.0 // indirect
go.opentelemetry.io/collector/extension/extensionmiddleware v0.138.0 // indirect
go.opentelemetry.io/collector/extension/xextension v0.138.0 // indirect
go.opentelemetry.io/collector/featuregate v1.44.0 // indirect
go.opentelemetry.io/collector/internal/telemetry v0.138.0 // indirect
Expand All @@ -62,13 +77,15 @@ require (
go.opentelemetry.io/collector/receiver/receivertest v0.138.0 // indirect
go.opentelemetry.io/collector/receiver/xreceiver v0.138.0 // indirect
go.opentelemetry.io/contrib/bridges/otelzap v0.13.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
go.opentelemetry.io/otel/log v0.14.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
Expand Down
Loading