Package is targeting .NET 7 and above.
AzureMonitorLogs Exporter is an open-source project that provides a simple and efficient way to export telemetry data from your application to Azure Log Analytics. The project is based on open telemetry dotnet implementation, adding a dedicated exporter targeting Log Analytics.
Signal | Status |
---|---|
Traces | Supported |
Logs | Not supported |
Metrics | Not supported |
- Azure log analytics Workspace is provisioned and known.
- Workspace immutable id.
- Workspace shared key, either primary or secondary.
- Exporter will target user specified custom log table, creating it on the fly, when required.
Important to note - It is recommended not to use an existing custom log table, in order to avoid data loss.
- Azure log analytics Workspace is provisioned and known.
- Workspace immutable id.
- Application is provisioned and known, representing the to be instrumented service.
- Dcr and Dce.
- Application was granted the appropriate permission to Dcr.
- A log analytics custom log table was provisioned in advance, targeting open telemetry trace schema.
- Dcr stream definition depicting schema must match destination custom log table schema.
Important to note - Ingestion api tutorial on how to set Application and Permissions
Column | Type |
---|---|
TimeGenerated | datetime |
Name | string |
TraceId | string |
TraceId | string |
SpanId | string |
ParentId | string |
StartTime | datetime |
EndTime | datetime |
Attributes | dynamic |
using OpenTelemetry;
using OpenTelemetry.Exporter.AzureMonitorLogs;
using OpenTelemetry.Trace;
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAzureMonitorLogsExporter(o =>
{
o.WorkspaceId = //Workspace immutable id.
o.SharedKey = //workspace shared key, can be either primary or secondary.
o.TableName = //destination custom log table.
})
.Build();
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAzureMonitorLogsExporter(o =>
{
o.WorkspaceId = //Workspace immutable id.
o.ClientId = //Application client id.
o.ClientSecret = //Application client secret.
o.TenantId = //AAD Tenant id.
o.AuthorityBaseUri = //AAD base url, for example - https://login.microsoftonline.com.
o.Audience = //Azure Resource Manager target audience, for example - https://monitor.azure.com/.default
o.DceUri = //dce uri, for example - https://yyyyyyy.{region}.ingest.monitor.azure.com
o.DcrImmutableId = //dcr immutable id, for example - dcr-yyyyxxxxaaaaazzzz00000
o.TableName = //destination custom log table.
})
.Build();