Your applications run on virtual machines, App Service and Azure databases, and every incident starts with a detour through Azure Monitor before anyone opens Dynatrace. A Dynatrace Azure integration brings Azure Monitor metrics and resource logs into the same platform as your traces and SLOs.

For on-call engineers the benefit is counted in minutes: when the Azure SQL database hits its DTU ceiling, that fact must appear next to the slow service, not in a separate portal. Fewer switches, less toil, shorter MTTR.

The goal of this tutorial: create a read-only service principal, connect a subscription, forward Azure logs through Event Hub, and check everything in DQL. The content applies to Dynatrace SaaS and Dynatrace Managed; differences are flagged.

The two flows of the Dynatrace Azure integration

As with other clouds, two independent mechanisms live side by side:

  • Metrics and metadata (pull): Dynatrace queries the Azure Monitor API with the identity of a service principal holding the built-in Monitoring Reader role.
  • Logs (push): resource diagnostic settings send their logs to an Event Hub; a log forwarder reads that Event Hub and pushes to the Dynatrace log ingest API.

An RBAC role problem does not stop logs from arriving, and a misconfigured Event Hub does not affect metrics. Always troubleshoot the two separately.

Prerequisites

  • Azure CLI (az) signed in with an account allowed to create an app registration and assign roles on the subscription.
  • Permission to change Dynatrace environment settings.
  • A Dynatrace API token with the log ingest scope (logs.ingest) for the forwarder.
  • An Event Hub namespace in the region of the resources you want to monitor.
  • On Managed: an ActiveGate that reaches both the Azure APIs and your cluster; it is the component that polls Azure Monitor.

Step 1: create the service principal

Create an app registration and its service principal with a client secret:

az ad sp create-for-rbac \ --name "dynatrace-monitoring" \ --query "{CLIENT_ID:appId, TENANT_ID:tenant, CLIENT_SECRET:password}" \ --output table 

Record the three values straight away: the secret is never shown again. Store it in your secret vault, not in a ticket.

Step 2: assign the Monitoring Reader role

Fetch the principal’s object ID, then assign the role at subscription scope:

OBJECT_ID=$(az ad sp list --display-name "dynatrace-monitoring" --query "[0].id" -o tsv) az role assignment create \ --assignee-object-id "$OBJECT_ID" \ --role "Monitoring Reader" \ --scope "/subscriptions/<subscription-id>" \ --assignee-principal-type ServicePrincipal \ --description "Dynatrace Monitoring" 

Monitoring Reader grants read access to metrics and metadata, with no write rights. To cover many subscriptions, assign the same role at management group level with --scope "/providers/Microsoft.Management/managementGroups/<id>": every new subscription is then covered with no extra step.

Check the assignment, inheritance included:

az role assignment list \ --assignee-object-id "$OBJECT_ID" \ --role "Monitoring Reader" \ --scope "/subscriptions/<subscription-id>" \ --include-inherited 

An empty array means the role is missing: there is no point going further on the Dynatrace side.

Step 3: connect the subscription in Dynatrace

In the Dynatrace settings, create the Azure connection with the client ID, tenant ID and secret. Then choose the services to monitor and filter by location or tag. On recent SaaS environments, the Azure connection relies on a managed extension that also supports subscription filtering and enrichment from Azure tags; on Managed, use the Azure integration screen of your cluster version. Exact labels vary by version: the documentation for your deployment is authoritative.

Tag filtering (for example environment=production) is the best starting setting: it limits calls to the Azure Monitor API and the volume of ingested metrics.

Step 4: forward logs through Event Hub

Dynatrace publishes an open source log forwarder as a deployment script. It creates a Function App that reads the Event Hub and sends to your environment:

DEPLOYMENT_NAME=dtlogs TARGET_URL=https://<environment-id>.live.dynatrace.com TARGET_API_TOKEN=<logs-ingest-token> RESOURCE_GROUP=rg-observability EVENT_HUB_CONNECTION_STRING="<event-hub-connection-string>" REQUIRE_VALID_CERTIFICATE=true wget -q https://github.com/dynatrace-oss/dynatrace-azure-log-forwarder/releases/latest/download/dynatrace-azure-logs.sh \ -O dynatrace-azure-logs.sh && chmod +x ./dynatrace-azure-logs.sh ./dynatrace-azure-logs.sh \ --deployment-name $DEPLOYMENT_NAME \ --target-url $TARGET_URL \ --target-api-token $TARGET_API_TOKEN \ --resource-group $RESOURCE_GROUP \ --event-hub-connection-string "$EVENT_HUB_CONNECTION_STRING" \ --require-valid-certificate $REQUIRE_VALID_CERTIFICATE 

On Managed, TARGET_URL points to your ActiveGate (https://<activegate>/e/<environment-id>); the script also offers an option to reuse an existing ActiveGate. It accepts a managed identity instead of the connection string too, which saves one more secret.

Finally, wire resources to the Event Hub with a diagnostic setting:

az monitor diagnostic-settings create \ --name to-dynatrace \ --resource "<resource-id>" \ --event-hub-rule "<authorization-rule-id>" \ --event-hub "<event-hub-name>" \ --logs '[{"categoryGroup":"allLogs","enabled":true}]' 

Only choose allLogs for critical resources. For the rest, target specific categories: volume drops and the signal stays readable.

How to check it works

On the Azure side, open the Event Hub: the Incoming Messages chart should rise after a few minutes, and Outgoing Messages should follow. If only incoming messages grow, the forwarder is not consuming: read the Function App logs.

On the Dynatrace side, open a notebook and run:

fetch logs, from: now() - 1h | filter matchesValue(cloud.provider, "Azure") | summarize count(), by: {azure.resource.type} | sort `count()` desc 

If the azure.resource.type field does not exist in your records, drop the grouping and inspect a raw record to see which attributes are available. For metrics, search « azure » in the metrics explorer and chart CPU usage for a known virtual machine. More checks are in our DQL query examples for operations.

Good practices

  • One service principal per scope (production, non-production), so you can revoke without cutting everything.
  • Rotate the client secret with az ad app credential reset --append: the old secret stays valid until you update Dynatrace.
  • Carry Azure tags into Dynatrace and build on them with management zones and automatic tagging.
  • Give the forwarder its own consumer group: shared with another tool, it causes lost messages.
  • Watch for silence from a critical source: see detecting gaps in log ingestion.

Frequently asked questions

Is Monitoring Reader enough, or do I need Reader?

For metric and metadata collection, the documentation asks for Monitoring Reader. Some advanced features may need extra read permissions; the documentation provides a custom role template with read-only actions per resource provider. Avoid Contributor: nothing justifies it.

What is the difference between SaaS and Managed?

On SaaS, Dynatrace polls Azure from its own infrastructure. On Managed, the ActiveGate of your environment makes those calls and must reach the Azure APIs; logs go through it as well. See Environment ActiveGate or Cluster ActiveGate to place it.

Logs arrive but metrics do not: what should I check?

The two flows are independent. Check the role assignment with --include-inherited, the client secret expiry, then the connection filters: an overly strict tag filter excludes everything without raising an error.

Conclusion

A read-only service principal, the Monitoring Reader role and an Event Hub are enough to bring Azure Monitor into Dynatrace. The point is not to duplicate the Azure portal but to correlate: the saturated managed resource shows up in the same problem as the affected service. Start with one production subscription, check in DQL, then extend through management groups. The reference procedure lives on docs.dynatrace.com.

span.observer is an independent community blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of its owner. Screen names and procedures change: always check the official documentation before a production change.

Originally published on span.observer. French version: https://span.observer/fr/dynatrace-azure-monitor-logs/.