Skip to content

Commit 10825e5

Browse files
Azure Docs: Azure Log Analytics (#582)
Co-authored-by: Brian Rinaldi <brian.rinaldi@gmail.com>
1 parent 6110e25 commit 10825e5

1 file changed

Lines changed: 206 additions & 0 deletions

File tree

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
title: "Log Analytics"
3+
description: Get started with Azure Log Analytics on LocalStack
4+
template: doc
5+
---
6+
7+
import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage";
8+
9+
## Introduction
10+
11+
Azure Log Analytics Workspaces are the primary data store for Azure Monitor log data.
12+
They collect, index, and query log data from Azure resources, virtual machines, and custom sources. For more information, see [Log Analytics workspace overview](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/log-analytics-workspace-overview).
13+
They are commonly used as the central destination for diagnostic settings, Azure Monitor agents, and security audit logs in enterprise monitoring architectures.
14+
15+
LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Log Analytics Workspaces.
16+
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Log Analytics' integration with LocalStack.
17+
18+
## Getting started
19+
20+
This guide walks you through creating a Log Analytics Workspace, retrieving its shared keys, and deleting the workspace.
21+
22+
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:
23+
24+
```bash
25+
azlocal start-interception
26+
```
27+
28+
This command points the `az` CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API.
29+
To revert this configuration, run:
30+
31+
```bash
32+
azlocal stop-interception
33+
```
34+
35+
This reconfigures the `az` CLI to send commands to the official Azure management REST API.
36+
37+
### Create a resource group
38+
39+
Create a resource group to hold all resources created in this guide:
40+
41+
```bash
42+
az group create --name rg-laws-demo --location westeurope
43+
```
44+
45+
```bash title="Output"
46+
{
47+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-laws-demo",
48+
"location": "westeurope",
49+
"name": "rg-laws-demo",
50+
"properties": { "provisioningState": "Succeeded" },
51+
"type": "Microsoft.Resources/resourceGroups"
52+
}
53+
```
54+
55+
### Create a Log Analytics Workspace
56+
57+
Create a Log Analytics workspace with a 30-day data retention period (matching the default for `--retention-time` in the [Azure CLI workspace create](https://learn.microsoft.com/en-us/cli/azure/monitor/log-analytics/workspace?view=azure-cli-latest#az-monitor-log-analytics-workspace-create) reference):
58+
59+
```bash
60+
az monitor log-analytics workspace create \
61+
--name my-workspace \
62+
--resource-group rg-laws-demo \
63+
--location westeurope \
64+
--retention-time 30
65+
```
66+
67+
```bash title="Output"
68+
{
69+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-laws-demo/providers/Microsoft.OperationalInsights/workspaces/my-workspace",
70+
"location": "westeurope",
71+
"name": "my-workspace",
72+
"resourceGroup": "rg-laws-demo",
73+
"type": "Microsoft.OperationalInsights/workspaces",
74+
"properties": {
75+
"customerId": "a1b2c3d4-e5f6-4789-a012-3456789abcd0",
76+
"provisioningState": "Succeeded",
77+
"publicNetworkAccessForIngestion": "Enabled",
78+
"publicNetworkAccessForQuery": "Enabled",
79+
"retentionInDays": 30,
80+
"sku": { "name": "PerGB2018" }
81+
}
82+
}
83+
```
84+
85+
### Retrieve workspace shared keys
86+
87+
Retrieve the primary and secondary shared keys used to send logs directly to the workspace:
88+
89+
```bash
90+
az monitor log-analytics workspace get-shared-keys \
91+
--workspace-name my-workspace \
92+
--resource-group rg-laws-demo
93+
```
94+
95+
```bash title="Output"
96+
{
97+
"primarySharedKey": "ZW5jb2RlZFNoYXJlZEtleUV4YW1wbGUxMjM0NTY3OA==",
98+
"secondarySharedKey": "c2Vjb25kYXJ5U2hhcmVkS2V5RXhhbXBsZTk4NzY1NDMyMQ=="
99+
}
100+
```
101+
102+
### List workspaces
103+
104+
List all Log Analytics workspaces in the resource group:
105+
106+
```bash
107+
az monitor log-analytics workspace list \
108+
--resource-group rg-laws-demo
109+
```
110+
111+
```bash title="Output"
112+
[
113+
{
114+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-laws-demo/providers/Microsoft.OperationalInsights/workspaces/my-workspace",
115+
"location": "westeurope",
116+
"name": "my-workspace",
117+
"resourceGroup": "rg-laws-demo",
118+
"type": "Microsoft.OperationalInsights/workspaces",
119+
"properties": {
120+
"customerId": "a1b2c3d4-e5f6-4789-a012-3456789abcd0",
121+
"provisioningState": "Succeeded",
122+
"retentionInDays": 30,
123+
"sku": { "name": "PerGB2018" }
124+
}
125+
}
126+
]
127+
```
128+
129+
### Show a workspace
130+
131+
Retrieve the full details of the workspace, including its unique customer ID:
132+
133+
```bash
134+
az monitor log-analytics workspace show \
135+
--workspace-name my-workspace \
136+
--resource-group rg-laws-demo
137+
```
138+
139+
```bash title="Output"
140+
{
141+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-laws-demo/providers/Microsoft.OperationalInsights/workspaces/my-workspace",
142+
"location": "westeurope",
143+
"name": "my-workspace",
144+
"resourceGroup": "rg-laws-demo",
145+
"type": "Microsoft.OperationalInsights/workspaces",
146+
"properties": {
147+
"customerId": "a1b2c3d4-e5f6-4789-a012-3456789abcd0",
148+
"provisioningState": "Succeeded",
149+
"publicNetworkAccessForIngestion": "Enabled",
150+
"publicNetworkAccessForQuery": "Enabled",
151+
"retentionInDays": 30,
152+
"sku": { "name": "PerGB2018" }
153+
}
154+
}
155+
```
156+
157+
### Delete and verify
158+
159+
Delete the resource and confirm it no longer appears in the list:
160+
161+
```bash
162+
az monitor log-analytics workspace delete \
163+
--workspace-name my-workspace \
164+
--resource-group rg-laws-demo \
165+
--yes
166+
```
167+
168+
169+
Then list all workspaces to confirm the resource group is now empty:
170+
171+
```bash
172+
az monitor log-analytics workspace list \
173+
--resource-group rg-laws-demo
174+
```
175+
176+
```bash title="Output"
177+
[]
178+
```
179+
180+
## Features
181+
182+
- **Workspace lifecycle:** Create, read, list, update, and delete Log Analytics Workspaces.
183+
- **Shared key retrieval:** Retrieve primary and secondary shared keys via `get-shared-keys`.
184+
- **SKU configuration:** Accept `PerGB2018`, `Free`, `Standard`, `Premium`, `PerNode`, and `Standalone` SKUs (Azure's REST API also defines `CapacityReservation` and `LACluster`; see [WorkspaceSkuNameEnum](https://learn.microsoft.com/en-us/rest/api/loganalytics/workspaces/create-or-update#workspaceskunameenum) in the Azure REST reference).
185+
- **Retention configuration:** Configure log retention period in days.
186+
- **Activity Logs:** Activity log events generated by LocalStack operations are fully emulated and queryable via the Activity Log API.
187+
188+
## Limitations
189+
190+
- **No log ingestion:** Data sent to the legacy [HTTP Data Collector API](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/data-collector-api) or other ingestion endpoints is not stored.
191+
- **No KQL query execution:** Running `az monitor log-analytics query` is not supported.
192+
- **No table or schema management:** Custom tables, table schemas, and retention policies per table are not managed.
193+
- **No saved searches:** Saved queries and search functions are not supported.
194+
- **No linked services:** Linking Automation accounts or [Microsoft Defender for Cloud](https://learn.microsoft.com/en-us/azure/defender-for-cloud/defender-for-cloud-introduction) to a workspace is not emulated.
195+
- **No Microsoft Sentinel:** Sentinel and related SIEM workspace features are not emulated.
196+
197+
## Samples
198+
199+
The following sample demonstrates how to use Azure Log Analytics with LocalStack for Azure:
200+
201+
- [Function App and Service Bus](https://github.com/localstack/localstack-azure-samples/samples/function-app-service-bus/dotnet/README.md)
202+
- [Web App and Cosmos DB for MongoDB API](https://github.com/localstack/localstack-azure-samples/samples/web-app-cosmosdb-mongodb-api/python/README.md)
203+
204+
## API Coverage
205+
206+
<AzureFeatureCoverage service="Microsoft.OperationalInsights" client:load />

0 commit comments

Comments
 (0)