Azure logs through Event Hubs

Send the resource logs of App Service, Azure Functions, Container Apps and AKS to Flowhawk with a diagnostic setting and an Event Hub.

Azure Monitor can't post logs to an outside address by itself. A diagnostic setting streams them to an Event Hub, and a small Azure Function with an Event Hub trigger posts each batch to Flowhawk, which reads Azure's record format directly.

What you get

  • Azure resource logs in Logs, next to your traces and metrics, searchable with the same query language (severity>=WARN service=checkout "timeout"), grouped into patterns or followed live.
  • A log line that names a request path joins the business flow of that route, so a failing checkout shows these logs on the checkout flow's page.
  • A line that carries a trace id opens its trace.
  • Alert on any search with Alert on this, and let the agent read these logs when it investigates an incident.

Set it up

First create an ingest key: in the app, open Settings > API keys and pick Services. In the examples below, KEY stands for that key. Keep it out of your repository, like any other secret.

1. Create an Event Hub

az eventhubs namespace create -g my-group -n my-logs-ns -l westeurope
az eventhubs eventhub create -g my-group --namespace-name my-logs-ns -n logs

2. Stream a resource's logs to it

Add a diagnostic setting to each resource whose logs you want (an App Service app, a Function App, a Container Apps environment, an AKS cluster). In the portal it is Diagnostic settings > Add diagnostic setting > Stream to an event hub. With the CLI:

az monitor diagnostic-settings create --name flowhawk \
  --resource RESOURCE_ID \
  --event-hub logs \
  --event-hub-rule /subscriptions/SUB/resourceGroups/my-group/providers/Microsoft.EventHub/namespaces/my-logs-ns/authorizationRules/RootManageSharedAccessKey \
  --logs '[{"categoryGroup":"allLogs","enabled":true}]'

3. Forward the batches with a function

Create a Function App on Node.js 18 or later (the v4 programming model) with this function. Give it two app settings: EventHubConnection, the namespace's connection string, and FLOWHAWK_KEY, your ingest key.

// src/functions/flowhawk.js
const { app } = require("@azure/functions");
app.eventHub("flowhawk", {
  connection: "EventHubConnection", eventHubName: "logs", cardinality: "many",
  handler: async (messages) => {
    const res = await fetch("https://api.flowhawk.dev/v1/logs/azure", {
      method: "POST", body: JSON.stringify(messages),
      headers: { "content-type": "application/json", authorization: `Bearer ${process.env.FLOWHAWK_KEY}` },
    });
    if (!res.ok) throw new Error(`Flowhawk answered ${res.status}`); // retried by the trigger
  },
});

The same code, with your workspace's address filled in, is in the app under Settings > Integrations > Log drains.

What arrives

Azure recordIn Flowhawk
App Service, Function App, Container App or container nameThe service. Add ?service= to the address to name it yourself
A message that is itself JSONIts fields: level, message, trace_id and the rest
propertiesAttributes, with cloud.resource_id and azure.category
A request path in the recordThe business flow and step of that route

Common questions

Does this include application traces?

No, these are logs. For traces, add OpenTelemetry to the app (.NET, other languages) and send it straight to Flowhawk. Logs that carry a trace id then open their trace.

What does it cost on the Azure side?

An Event Hubs namespace and a Function App on the consumption plan. Flowhawk charges for the logs you keep, like any other data (Billing).