# Send Custom Logs to Azure Monitor with Python

Sending structured logs to Azure Monitor requires correct endpoints, credentials, rules, and schemas. This skill provides Python patterns for synchronous, asynchronous, and resilient ingestion.

## Install

```bash
npx skillstore add sickn33/azure-monitor-ingestion-py
```

## Metadata

- Status: approved
- Slug: sickn33-azure-monitor-ingestion-py
- Skillstore revision: r2
- Version status: missing
- Tree hash: 2f2e715ef4283ac480bd876b919784a938ad65ea79d0a207d9860b4eeb45dfc2
- Author: sickn33
- GitHub username: sickn33
- License: MIT
- Repository: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-monitor-ingestion-py
- Ref: f9e2c34b4f19c7f3e6b0a1e93227b5f77cc12526
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, network, filesystem, env\_access
- Quality score: 78
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/sickn33-azure-monitor-ingestion-py
- Manifest: https://skillstore.pages.dev/api/skills/sickn33-azure-monitor-ingestion-py/manifest

## Capabilities

- Configure Azure Monitor ingestion with Data Collection Endpoint, rule, and stream environment variables.
- Authenticate LogsIngestionClient with DefaultAzureCredential.
- Upload structured custom logs to a Log Analytics workspace.
- Load log records from a local JSON file before ingestion.
- Handle partial upload failures and retry failed records.
- Use asynchronous clients and Azure Government endpoints.

## Use Cases

- Centralize Service Logs: Send structured application events from Python services into a shared Log Analytics workspace.
- Add Custom Telemetry: Implement reliable Azure Monitor uploads with retries and partial-failure handling.
- Support Sovereign Cloud: Configure ingestion endpoints, authority hosts, and scopes for Azure Government deployments.

## Prompt Templates

### Create a Basic Uploader

```
Create a minimal Python example that sends sample logs to Azure Monitor using environment variables and DefaultAzureCredential.
```

### Ingest Existing Events

```
Adapt my Python event records for a custom Log Analytics table and identify required Data Collection Rule fields.
```

### Handle Partial Failures

```
Design upload error handling that records failed entries, limits retries, preserves diagnostics, and avoids duplicate ingestion.
```

### Scale Government Ingestion

```
Plan asynchronous Azure Government ingestion with credential scope, client cleanup, bounded concurrency, retries, and schema validation.
```

## Limitations

- Requires an existing Log Analytics workspace, Data Collection Endpoint, Data Collection Rule, and compatible table.
- Does not provision Azure resources or assign permissions.
- Examples require environment-specific schema, endpoint, and identity validation.
- Does not inspect log records for secrets or regulated data.

## Best Practices

- Match every log field and type to the Data Collection Rule schema.
- Use managed identity or another DefaultAzureCredential source instead of embedded secrets.
- Record partial failures and apply bounded retries with duplicate protection.

## Anti Patterns

- Do not hardcode client secrets, tenant secrets, or production credentials.
- Do not silently ignore upload failures in production workflows.
- Do not upload local files before reviewing their contents and destination.

## Security Audit

- Audited at: 2026-07-23T21:48:59.452\+00:00
- Summary: All 33 static findings are false positives caused by Markdown formatting, standard Azure endpoint examples, or explicit configuration reads. No prompt injection, malicious command execution, credential exfiltration, or reconnaissance intent was found.

## Stats

- Views: 162
- Downloads: 8
- Favorites: 0
- Popularity score: 0
