Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/content/docs/azure/services/insights.mdx

This file was deleted.

220 changes: 220 additions & 0 deletions src/content/docs/azure/services/monitor.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
---
title: "Monitor"
description: Get started with Azure Monitor on LocalStack
template: doc
---

import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage";

## Introduction

Azure Monitor is a platform service for collecting, analyzing, and acting on telemetry from Azure resources and applications.
It helps you inspect activity logs and configure diagnostic settings for operational visibility.
These capabilities are useful for troubleshooting, auditing, and observability workflows.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These capabilities are useful for troubleshooting, auditing, and observability workflows.
These capabilities are useful for troubleshooting, auditing, and observability workflows. For more information, see [Azure Monitor overview](https://learn.microsoft.com/azure/azure-monitor/fundamentals/overview).


LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Monitor.
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Monitor's integration with LocalStack.

## Getting started

This guide is designed for users new to Azure Monitor and assumes basic knowledge of the Azure CLI and our `azlocal` wrapper script.

Start your LocalStack container using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Start your LocalStack container using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/).
Launch LocalStack using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/). Once the container is running, enable Azure CLI interception by running:
```bash
azlocal start-interception
```


:::note
As an alternative to using the `azlocal` CLI, users can run:

`azlocal start-interception`

This command points the `az` CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API.
To revert this configuration, run:

`azlocal stop-interception`

This reconfigures the `az` CLI to send commands to the official Azure management REST API. At this time, there is no full parity between `azlocal` and `az` commands after running `az start-interception`. Therefore, this technique is not fully interchangeable.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This reconfigures the `az` CLI to send commands to the official Azure management REST API. At this time, there is no full parity between `azlocal` and `az` commands after running `az start-interception`. Therefore, this technique is not fully interchangeable.
This reconfigures the `az` CLI to send commands to the official Azure management REST API.

:::

### Create a resource group

Create a resource group to contain your Monitor demo resources:

```bash
azlocal group create \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the recent refactoring, az has achieved full feature parity with azlocal. Consequently, az can now be used as a direct replacement.

Suggested change
azlocal group create \
az group create \

--name rg-monitor-demo \
--location westeurope
```

```bash title="Output"
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-monitor-demo",
"location": "westeurope",
"managedBy": null,
"name": "rg-monitor-demo",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
```

### Create a storage account

Create a storage account to use as a diagnostic settings destination:

```bash
azlocal storage account create \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the recent refactoring, az has achieved full feature parity with azlocal. Consequently, az can now be used as a direct replacement.

Suggested change
azlocal storage account create \
az storage account create \

--name stmonitordoc79 \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing wrong with stmonitordoc79, but it's better to use a simple name like mystore

Suggested change
--name stmonitordoc79 \
--name mystore \

--resource-group rg-monitor-demo \
--location westeurope \
--sku Standard_LRS
```

```bash title="Output"
{
...
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-monitor-demo/providers/Microsoft.Storage/storageAccounts/stmonitordoc79",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-monitor-demo/providers/Microsoft.Storage/storageAccounts/stmonitordoc79",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-monitor-demo/providers/Microsoft.Storage/storageAccounts/mystore",

...
"name": "stmonitordoc79",
...
"primaryEndpoints": {
"blob": "https://stmonitordoc79blob.localhost.localstack.cloud:4566",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the recent refactoring, the fully qualified domain names (FQDN) for storage account endpoints have been updated.

Suggested change
"blob": "https://stmonitordoc79blob.localhost.localstack.cloud:4566",
"blob": "https://mystore.blob.core.azure.localhost.localstack.cloud:4566",

...
"table": "https://stmonitordoc79table.localhost.localstack.cloud:4566",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"table": "https://stmonitordoc79table.localhost.localstack.cloud:4566",
"table": "https://mystore.table.core.azure.localhost.localstack.cloud:4566",

...
},
...
}
```

### List activity logs

List recent activity logs from the subscription:

```bash
azlocal monitor activity-log list --max-events 5
```

```bash title="Output"
[
{
"caller": "00000000-0000-0000-0000-000000000000",
"category": {
"value": "Administrative",
...
},
"eventName": {
"value": "EndRequest",
...
},
"eventTimestamp": "2026-03-17T07:34:43.230050",
"resourceGroupName": "rg-monitor-demo",
"resourceProviderName": {
"value": "Microsoft.Resources",
...
},
...
},
...
]
```

### Create and inspect diagnostic settings

Get the resource group resource ID:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Get the resource group resource ID:
Get the resource ID of the storage account:


```bash
RESOURCE_ID=$(azlocal group show \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RESOURCE_ID=$(azlocal group show \
RESOURCE_ID=$(az storage account show \

--name rg-monitor-demo \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--name rg-monitor-demo \
--name mystore \
--resource-group rg-monitor-demo \

--query id \
--output tsv)
```

Create diagnostic settings for the resource group:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Azure, you can create diagnostic settings for resources, but not for resource groups. A resource group is not a resource that emits diagnostic logs or metrics, so you can't attach a diagnostic setting directly to it the way you would to, say, a Key Vault or a SQL Database.

Suggested change
Create diagnostic settings for the resource group:
Create a diagnostic setting for the bob service of the storage account. For more information, see [Diagnostic settings in Azure Monitor](https://learn.microsoft.com/en-us/azure/azure-monitor/platform/diagnostic-settings):


```bash
azlocal monitor diagnostic-settings create \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
azlocal monitor diagnostic-settings create \
az monitor diagnostic-settings create \

--name rg-monitor-demo \
--resource "$RESOURCE_ID" \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--resource "$RESOURCE_ID" \
--resource "${RESOURCE_ID}/blobServices/default" \

--storage-account stmonitordoc79 \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--storage-account stmonitordoc79 \
--storage-account mystore \

--logs '[{"category":"Administrative","enabled":true}]'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--logs '[{"category":"Administrative","enabled":true}]'
--logs '[{"category":"StorageRead","enabled":true},{"category":"StorageWrite","enabled":true}]' \
--metrics '[{"category":"Transaction","enabled":true},{"category":"Capacity","enabled":true}]'

```

```bash title="Output"
{
"id": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-monitor-demo/providers/microsoft.insights/diagnosticSettings/rg-monitor-demo",
"name": "rg-monitor-demo",
"logs": [
{
"category": "Administrative",
"enabled": true
}
],
"metrics": [],
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-monitor-demo/providers/microsoft.Storage/storageAccounts/stmonitordoc79",
"type": "microsoft.insights/diagnosticSettings"
}
```

Get the diagnostic setting:

```bash
azlocal monitor diagnostic-settings show \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
azlocal monitor diagnostic-settings show \
az monitor diagnostic-settings show \

--name rg-monitor-demo \
--resource "$RESOURCE_ID"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--resource "$RESOURCE_ID"
--resource "${RESOURCE_ID}/blobServices/default"

```

```bash title="Output"
{
"id": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-monitor-demo/providers/microsoft.insights/diagnosticSettings/rg-monitor-demo",
"name": "rg-monitor-demo",
"logs": [
{
"category": "Administrative",
"enabled": true
}
],
"metrics": [],
Comment on lines +171 to +177
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"logs": [
{
"category": "Administrative",
"enabled": true
}
],
"metrics": [],
"logs": [
{
"category": "StorageRead",
"enabled": true
},
{
"category": "StorageWrite",
"enabled": true
}
],
"metrics": [
{
"category": "Transaction",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "Capacity",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],

...
}
```

### Update and delete diagnostic settings

Update diagnostic settings to include an additional category:

```bash
azlocal monitor diagnostic-settings update \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
azlocal monitor diagnostic-settings update \
az monitor diagnostic-settings update \

--name rg-monitor-demo \
--resource "$RESOURCE_ID" \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--resource "$RESOURCE_ID" \
--resource"${RESOURCE_ID}/blobServices/default" \

--logs '[{"category":"Administrative","enabled":true},{"category":"Security","enabled":false}]'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--logs '[{"category":"Administrative","enabled":true},{"category":"Security","enabled":false}]'
--logs '[{"category":"StorageRead","enabled":true},{"category":"StorageWrite","enabled":true},,{"category":"StorageDelete","enabled":true}]' \
--metrics '[{"category":"Transaction","enabled":true},{"category":"Capacity","enabled":true}]'

```

```bash title="Output"
{
"name": "rg-monitor-demo",
"logs": [
{
"category": "Administrative",
"enabled": true
},
{
"category": "Security",
"enabled": false
}
],
Comment on lines +196 to +205
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"logs": [
{
"category": "Administrative",
"enabled": true
},
{
"category": "Security",
"enabled": false
}
],
"logs": [
{
"category": "StorageRead",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "StorageWrite",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "StorageDelete",
"enabled": false,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],
"metrics": [
{
"category": "Transaction",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "Capacity",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],

...
}
```

Delete the diagnostic setting:

```bash
azlocal monitor diagnostic-settings delete \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
azlocal monitor diagnostic-settings delete \
az monitor diagnostic-settings delete \

--name rg-monitor-demo \
--resource "$RESOURCE_ID"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--resource "$RESOURCE_ID"
--resource "${RESOURCE_ID}/blobServices/default"

```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Features
The Azure Monitor emulator supports the following features:
- **Activity logs**: List activity log entries for a subscription, with optional filtering by resource ID and time range.
- **Diagnostic settings**: Create, get, update, and delete diagnostic settings on any ARM resource.
- **Application Insights components**: Create, get, update tags, list, delete, and purge Application Insights components. Billing features (get and update) are also supported.
- **Action groups**: Create, get, update, list (by resource group or subscription), and delete action groups.
- **Metric alerts**: Create, get, update, list (by resource group or subscription), and delete metric alert rules.
- **Activity log alerts**: Create, get, update, list (by resource group or subscription), and delete activity log alert rules.
- **Autoscale settings**: Create, get, update, list (by resource group or subscription), and delete autoscale settings.
- **Scheduled query rules**: Create, get, update, list (by resource group or subscription), and delete scheduled query rules.
- **Data collection rules and endpoints**: Create, get, update, list (by resource group or subscription), and delete data collection rules and data collection endpoints. Create, get, list (by resource, by rule, or by endpoint), and delete data collection rule associations.
- **Web tests**: Create, get, update tags, list (by resource group, subscription, or component), and delete availability web tests.
- **Workbooks and workbook templates**: Create, get, update, list (by resource group or subscription), and delete workbooks. Create, get, update, list (by resource group), and delete workbook templates. Workbook revisions (get and list) are also supported.
- **Telemetry ingestion (data plane)**: Accept Application Insights SDK telemetry payloads (`track`), custom metrics publish, and live metrics subscription checks.
- **Query API (data plane)**: Execute and get log analytics queries, retrieve metrics, and list events.
## Limitations
- **No data persistence across restarts**: Activity logs, diagnostic settings, and all resource state are held in memory and lost when the emulator is stopped or restarted.
- **Activity log recording**: Only non-read (non-GET) control plane operations are recorded. Data plane operations and read requests do not produce activity log entries.
- **Diagnostic settings are not enforced**: Diagnostic settings are stored but do not route logs or metrics to the specified destination (storage account, Log Analytics workspace, or event hub).
- **Telemetry ingestion is a no-op**: The data plane telemetry endpoints (`track`, `publish`, `isSubscribed`) accept payloads and return success responses, but telemetry data is not stored or queryable.
- **Query API returns empty results**: Log analytics queries, metrics, and event queries return structurally valid but empty responses.
- **Autoscale rules are not evaluated**: Autoscale settings are stored but scaling actions are never triggered.
- **Alert rule evaluation**: Metric alerts, activity log alerts, and scheduled query rules are stored as resources but are never evaluated or fired.
- **Workbook revision history**: Revisions always return the current version of a workbook; historical revision tracking is not implemented.
- **Components purge**: The purge endpoint accepts requests and returns an operation ID, but no data is actually purged.
## Samples
Explore the following samples to get started with Service Bus on LocalStack:
- [Azure Functions App with Service Bus Messaging](https://github.com/localstack/localstack-azure-samples/blob/main/samples/function-app-service-bus/dotnet/)
- [Azure Web App with Azure Cosmos DB for MongoDB](https://github.com/localstack/localstack-azure-samples/blob/main/samples/web-app-cosmosdb-mongodb-api/python/)

## API Coverage

<AzureFeatureCoverage service="Microsoft.Insights" client:load />