Azure

Azure Diagnostic Metrics Integration

Stream Azure Monitor metrics to Qorrelate

Overview

The Azure Diagnostic Metrics integration allows you to collect platform metrics from Azure Monitor and forward them to Qorrelate. Monitor CPU, memory, network, and custom metrics from your Azure resources in a unified observability platform.

Prerequisites

  • An Azure subscription with Azure Monitor enabled
  • Service Principal with Monitoring Reader role
  • Your Qorrelate API endpoint and organization ID

Configuration Steps

1. Create a Service Principal

Create a Service Principal with monitoring read permissions:

# Create service principal
az ad sp create-for-rbac --name "qorrelate-metrics-reader" \
  --role "Monitoring Reader" \
  --scopes /subscriptions/YOUR_SUBSCRIPTION_ID

# Save the output - you'll need:
# - appId (client ID)
# - password (client secret)
# - tenant

2. Deploy the Metrics Forwarder

Deploy an Azure Function or container that queries Azure Monitor and forwards metrics:

import os
from azure.identity import ClientSecretCredential
from azure.monitor.query import MetricsQueryClient
from datetime import datetime, timedelta
import requests

# Azure credentials
credential = ClientSecretCredential(
    tenant_id=os.environ["AZURE_TENANT_ID"],
    client_id=os.environ["AZURE_CLIENT_ID"],
    client_secret=os.environ["AZURE_CLIENT_SECRET"]
)

client = MetricsQueryClient(credential)

def query_and_forward_metrics():
    # Query metrics from Azure Monitor
    resource_id = "/subscriptions/{sub}/resourceGroups/{rg}/providers/..."
    
    response = client.query_resource(
        resource_id,
        metric_names=["Percentage CPU", "Network In Total", "Network Out Total"],
        timespan=timedelta(minutes=5)
    )
    
    # Convert to Prometheus format for Qorrelate
    metrics = []
    for metric in response.metrics:
        for ts in metric.timeseries:
            for data in ts.data:
                metrics.append({
                    "name": metric.name.replace(" ", "_").lower(),
                    "value": data.average or data.total or 0,
                    "timestamp": data.timestamp.isoformat(),
                    "labels": {
                        "resource_id": resource_id,
                        "source": "azure-monitor"
                    }
                })
    
    # Forward to Qorrelate
    headers = {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['QORRELATE_API_KEY']}",
        "X-Organization-Id": os.environ["QORRELATE_ORG_ID"]
    }
    
    requests.post(
        f"{os.environ['QORRELATE_ENDPOINT']}/v1/metrics",
        headers=headers,
        json={"metrics": metrics}
    )

3. Configure Diagnostic Settings

Enable diagnostic settings on your Azure resources to export metrics:

# Enable diagnostic settings for a VM
az monitor diagnostic-settings create \
  --name "qorrelate-export" \
  --resource "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachines/{vm}" \
  --metrics '[{"category": "AllMetrics", "enabled": true}]' \
  --event-hub "{event-hub-name}" \
  --event-hub-rule "{event-hub-auth-rule-id}"

Available Metrics

Common Azure metrics you can collect:

Resource Type Metrics
Virtual Machines CPU %, Memory %, Disk IOPS, Network I/O
App Service Requests, Response Time, HTTP errors
SQL Database DTU %, CPU %, Storage %, Deadlocks
Storage Accounts Transactions, Latency, Availability

Verifying the Integration

  1. Deploy your metrics forwarder function
  2. Wait 5-10 minutes for initial metrics to appear
  3. Navigate to the Metrics Explorer in Qorrelate
  4. Search for metrics with source:azure-monitor label