> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squasher.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure Monitor

> Forward Azure Monitor diagnostic logs into Squasher with the Azure drain endpoint.

Squasher accepts Azure Monitor diagnostic log JSON, so you can forward the same records payload from your Azure delivery step into a Squasher project.

## Overview

<Note>
  Send the Azure Monitor records payload as JSON. Squasher accepts both `records` and Azure-style
  `Records` arrays.
</Note>

## Prerequisites

* A Squasher project ID
* A Squasher drain key or log connector key for that project
* Access to create or update Azure Monitor diagnostic settings
* A delivery step that can POST Azure Monitor diagnostic log JSON to Squasher

## Endpoint URL

```text theme={null}
https://ingest.squasher.ai/v1/drain/azure/{project_id}
```

## Authentication

Send your drain key in the `x-squasher-key` header on every request.

```http theme={null}
x-squasher-key: sq_pk_your_drain_key
Content-Type: application/json
```

## Payload Format

The Azure drain expects the native Azure Monitor diagnostic log shape with a `records` array.

```json theme={null}
{
  "records": [
    {
      "time": "2024-03-21T12:00:00Z",
      "category": "AppServiceConsoleLogs",
      "operationName": "WriteConsoleLogs",
      "resourceId": "/subscriptions/demo/resourceGroups/example/providers/Microsoft.Web/sites/demo",
      "properties": {
        "message": "Unhandled exception in worker",
        "severity": "Error"
      }
    }
  ]
}
```

## Setup Steps

<Steps>
  <Step title="Choose the resource and log categories">
    Pick the Azure resource you want to monitor and decide which diagnostic categories you want to export first.
  </Step>

  <Step title="Create or update the diagnostic setting">
    In **Monitor > Diagnostic settings**, create a setting for the selected categories and point it at the forwarding step you control.
  </Step>

  <Step title="POST the records payload to Squasher">
    Configure your Azure Function, collector, or other bridge to send the diagnostic log JSON body to the Azure drain endpoint with the `x-squasher-key` header.
  </Step>
</Steps>

## Working cURL Example

Use this example to confirm the endpoint accepts Azure Monitor records before you connect your Azure delivery flow.

```bash theme={null}
PROJECT_ID="your-project-id"
SQUASHER_KEY="sq_pk_your_drain_key"

curl -X POST "https://ingest.squasher.ai/v1/drain/azure/${PROJECT_ID}" \
  -H "Content-Type: application/json" \
  -H "x-squasher-key: ${SQUASHER_KEY}" \
  -d '{
    "records": [
      {
        "time": "2024-03-21T12:00:00Z",
        "category": "AppServiceConsoleLogs",
        "operationName": "WriteConsoleLogs",
        "resourceId": "/subscriptions/demo/resourceGroups/example/providers/Microsoft.Web/sites/demo",
        "properties": {
          "message": "Unhandled exception in worker",
          "severity": "Error"
        }
      }
    ]
  }'
```

A successful request returns `202 Accepted`.

## Agent handoff

```text theme={null}
Set up Azure Monitor forwarding to Squasher for project <project_id>. Use a project-specific drain or connector key, verify with one records payload, and ask before changing diagnostic settings across additional resources.
```
