Azure Monitor / Log Analytics
Compatible with the azure-monitor-ingestion and azure-monitor-query SDKs, the
Microsoft.OperationalInsights / Microsoft.Insights ARM management plane, and any HTTP client.
Floci AZ emulates the Logs Ingestion API (push custom logs through a Data Collection Rule) and
the Log Analytics query API (read them back with a subset of KQL), all in-process.
HTTP-only: no Docker. Workspaces, Data Collection Endpoints/Rules, ingestion, and querying are all in-process. There is no sidecar.
Features
- Log Analytics workspaces:
Microsoft.OperationalInsights/workspacesCreateOrUpdate, Get, Delete, and List in a resource group or across the subscription; acustomerId(workspace GUID) is generated when not supplied, kept across redeploys, and indexed for query resolution.sharedKeys(and thelistKeysform ARM templates call) answerprimarySharedKeyandsecondarySharedKey, stable for the workspace's life - Data Collection Endpoints (DCE):
Microsoft.Insights/dataCollectionEndpointsCreateOrUpdate, Get, Delete, List in a resource group or across the subscription; the returnedlogsIngestion.endpointpoints back at the emulator base URL - Data Collection Rules (DCR):
Microsoft.Insights/dataCollectionRulesCreateOrUpdate, Get, Delete, List in a resource group or across the subscription; animmutableIdis generated when not supplied, kept across redeploys, and used to route ingestion - Diagnostic settings:
{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}on any resource: CreateOrUpdate, Get, Delete, and List for the resource they extend - Resource ids compare case-insensitively, as in ARM: a PUT through another casing of the same id
updates the one resource, and the id keeps the casing it was created with. Workspaces, data
collection endpoints and rules and diagnostic settings persist under the
monitorstorage mode - Logs Ingestion API:
POST /dataCollectionRules/{immutableId}/streams/{stream}accepts a JSON array of log records (plain orContent-Encoding: gzip, which the ingestion SDKs always send), resolves the DCR's Log Analytics destination, and stores each record against the destination workspace (TimeGeneratedis honoured or defaulted to now) - Log query API:
POST /v1/workspaces/{workspaceId}/queryruns a KQL subset over the stored records and returns the standard{tables:[{name,columns,rows}]}shape with inferred column types
Endpoints
Management operations use ARM paths; ingestion and query use the Monitor data-plane paths.
PUT /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.OperationalInsights/workspaces/{name}
GET /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.OperationalInsights/workspaces
GET /subscriptions/{sub}/providers/Microsoft.OperationalInsights/workspaces
GET /subscriptions/{sub}[/resourceGroups/{rg}]/providers/Microsoft.OperationalInsights/deletedWorkspaces
GET /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.OperationalInsights/workspaces/{name}
DELETE /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.OperationalInsights/workspaces/{name}
POST /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.OperationalInsights/workspaces/{name}/sharedKeys
POST /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.OperationalInsights/workspaces/{name}/listKeys
PUT /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Insights/dataCollectionEndpoints/{name}
GET /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Insights/dataCollectionEndpoints
GET /subscriptions/{sub}/providers/Microsoft.Insights/dataCollectionEndpoints
GET /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Insights/dataCollectionEndpoints/{name}
DELETE /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Insights/dataCollectionEndpoints/{name}
PUT /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Insights/dataCollectionRules/{name}
GET /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Insights/dataCollectionRules
GET /subscriptions/{sub}/providers/Microsoft.Insights/dataCollectionRules
GET /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Insights/dataCollectionRules/{name}
DELETE /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Insights/dataCollectionRules/{name}
POST /dataCollectionRules/{immutableId}/streams/{stream} # data-plane ingestion
POST /v1/workspaces/{workspaceId}/query # data-plane query
Quickstart
1: Create a workspace, DCE, and DCR
BASE="http://localhost:4577/subscriptions/my-sub/resourceGroups/my-rg/providers"
API="?api-version=2023-09-01"
# Workspace: capture the returned properties.customerId for queries
curl -s -X PUT "$BASE/Microsoft.OperationalInsights/workspaces/my-ws$API" \
-H "Content-Type: application/json" \
-d '{"location":"eastus","properties":{}}'
# Data Collection Endpoint
curl -s -X PUT "$BASE/Microsoft.Insights/dataCollectionEndpoints/my-dce$API" \
-H "Content-Type: application/json" \
-d '{"location":"eastus","properties":{}}'
# Data Collection Rule: destination is the workspace; capture properties.immutableId
curl -s -X PUT "$BASE/Microsoft.Insights/dataCollectionRules/my-dcr$API" \
-H "Content-Type: application/json" \
-d '{
"location": "eastus",
"properties": {
"destinations": {
"logAnalytics": [{
"name": "ws",
"workspaceResourceId": "/subscriptions/my-sub/resourceGroups/my-rg/providers/Microsoft.OperationalInsights/workspaces/my-ws"
}]
}
}
}'
2: Ingest logs
Post a JSON array of records to the DCR's immutableId and stream name:
curl -s -X POST \
"http://localhost:4577/dataCollectionRules/<immutableId>/streams/Custom-MyTable_CL?api-version=2023-01-01" \
-H "Content-Type: application/json" \
-d '[
{"TimeGenerated":"2026-06-25T10:00:00Z","Level":"INFO","Message":"hello"},
{"TimeGenerated":"2026-06-25T10:01:00Z","Level":"ERROR","Message":"boom"}
]'
# → 204 No Content
3: Query logs
from azure.identity import DefaultAzureCredential
from azure.monitor.query import LogsQueryClient
client = LogsQueryClient(DefaultAzureCredential(), endpoint="http://localhost:4577")
response = client.query_workspace(
workspace_id="<customerId>",
query="MyTable_CL | where Level == 'ERROR' | project TimeGenerated, Message | take 10",
timespan=None,
)
for table in response.tables:
print(table.columns, table.rows)
The workspace can be addressed by its customerId GUID or by its workspace name; the stream/table
name is matched with or without the Custom- prefix and the _CL suffix used by custom logs.
Activity Log
GET /subscriptions/{sub}/providers/Microsoft.Insights/eventtypes/management/values serves the
subscription Activity Log the way the Activity Logs list operation does. Every management-plane PUT,
PATCH, DELETE and POST action on an existing subscription is recorded as an Administrative
entry: a BeginRequest entry with status Started when the request enters, and an EndRequest
entry with Succeeded or Failed, the HTTP status word as subStatus and properties.statusCode,
when the request is answered. A write the ARM request gate refuses before its handler runs (an
invalid or taken name, a missing resource group, a policy deny) is logged as Failed at Error
level with the refusal's error, as Azure shows validation and policy refusals in the Activity Log; a
request refused because its subscription is unknown or read-only is not. Reads and listings are not
logged, as in Azure. Entries carry the caller and
claims of the request's bearer token, the x-ms-correlation-request-id and x-ms-client-request-id
headers, the authorization action and scope, the httpRequest method, uri and client address, and
the resource's id, type, provider, group and subscription. Operation names follow ARM:
Microsoft.Storage/storageAccounts/write, .../delete, .../listKeys/action,
Microsoft.Resources/subscriptions/resourceGroups/write.
curl -s "http://localhost:4577/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.Insights/eventtypes/management/values?api-version=2015-04-01&\$filter=eventTimestamp%20ge%20'2026-01-01T00:00:00Z'%20and%20resourceGroupName%20eq%20'rg1'" | jq .
$filter(required) takeseventTimestamp ge '...'pluseventTimestamp le,resourceGroupName eq,resourceUri eq/resourceId eq,resourceProvider eq,correlationId eq,eventChannels eq,levels eq,operations eq,status eq,subStatus eq,caller eq,category eqandsearchText eq, joined withand; the list-valued fields take comma-separated values. Values are quoted or bare tokens, and a date-time without an offset is read as UTC, which is howaz monitor activity-log listsends the window it computes. Anything else answers400 BadRequest, as does a filter without a start time; errors use this API's flat{"code": ..., "message": ...}shape rather than ARM'serrorwrapper.$selectnarrows each entry to the named properties.- Paging:
activity-log.page-sizeentries per page (default 1000), the rest behindnextLinkwith an opaque$skiptoken. Entries are newest first. Policyentries: services that evaluate policy can recordMicrosoft.Authorization/policies/{effect}/actionentries throughActivityLog.recordPolicyEffect, with theproperties.policiesJSON the Policy category carries.- Any
api-versionis accepted, the stable2015-04-01and the2017-03-01-previewalike.
Supported KQL subset
The query engine implements a pragmatic subset of KQL: enough for the assertions test suites and local dashboards typically make:
| Operator | Notes |
|---|---|
where <expr> |
comparisons ==, !=, >, <, >=, <= against string/number/datetime columns |
project <cols> |
comma-separated column projection |
take N / limit N |
row cap |
timespan |
request-level timespan (ISO-8601 duration such as PT1H, or a start/end range) filters by TimeGenerated before the query runs |
Column types in the response are inferred from the data (datetime for TimeGenerated, bool,
long, real, otherwise string).
Configuration
floci-az:
services:
monitor:
enabled: true
activity-log:
enabled: true
capacity: 10000
page-size: 1000
| Env var | Default | Description |
|---|---|---|
FLOCI_AZ_SERVICES_MONITOR_ENABLED |
true |
Enable/disable the service |
FLOCI_AZ_SERVICES_MONITOR_ACTIVITY_LOG_ENABLED |
true |
Records Administrative Activity Log entries for every ARM write, delete and action and serves the list operation |
FLOCI_AZ_SERVICES_MONITOR_ACTIVITY_LOG_CAPACITY |
10000 |
Activity Log entries kept in memory; the oldest are dropped beyond it |
FLOCI_AZ_SERVICES_MONITOR_ACTIVITY_LOG_PAGE_SIZE |
1000 |
Entries per page of the Activity Log list operation |
Stored log records use the global StorageBackend (FLOCI_AZ_STORAGE_MODE), so logs can survive
restarts in persistent/hybrid/wal modes.
Notes & limitations
- Workspaces are not soft-deleted. A delete removes the workspace outright, so it cannot be recovered and
deletedWorkspacesalways lists nothing. Real Azure keeps a deleted workspace recoverable for a period. - KQL is a subset.
summarize,extend,join,order by,parse, scalar functions, and aggregations are not implemented: onlywhere/project/take/limitplustimespanfiltering. - The Activity Log is in memory (
activity-log.capacityentries, default 10000,0keeps none) and covers the management plane only: noServiceHealth,Alert,Autoscale,SecurityorRecommendationcategories, no tenant-level log (/providers/Microsoft.Insights/eventtypes/management/valueswithout a subscription), andauthorization.roleis not reported. - Metrics are out of scope. Only the logs surface (ingestion + Log Analytics query) is emulated;
Microsoft.Insights/metrics, alerts, action groups, and autoscale are not. - Auth is permissive. Bearer tokens are accepted but not validated (dev mode), matching the rest of the emulator.
- Transformations are ignored. A DCR's
dataFlows/transformKqlare stored but not applied; records are written to the workspace as posted.