Azure Monitor Ingestion SDK for Python
將自訂記錄傳送至 Azure Monitor
此技能可讓 Claude Code 使用官方的 Logs Ingestion API,將自訂應用程式記錄傳送至 Azure Monitor Log Analytics 工作區。它提供程式碼範例與最佳實務,協助您在 Python 應用程式中整合 Azure 監控。
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「Azure Monitor Ingestion SDK for Python」。 How do I upload logs to Azure Monitor?
預期結果:
To upload logs to Azure Monitor, create a LogsIngestionClient with your Data Collection Endpoint and authenticate using DefaultAzureCredential. Then call client.upload() with your rule ID, stream name, and log data array.
正在使用「Azure Monitor Ingestion SDK for Python」。 What authentication methods are supported?
預期結果:
The SDK supports Azure Identity libraries including DefaultAzureCredential, ManagedIdentityCredential, and ServicePrincipalCredential. DefaultAzureCredential automatically attempts multiple auth methods including managed identity, environment variables, and interactive login.
安全審計
安全This is a prompt-only skill containing only documentation (SKILL.md). No executable code was scanned. The skill provides reference documentation for the Microsoft Azure Monitor Ingestion SDK for Python. No security risks identified.
品質評分
你能建構什麼
應用程式效能監控
從 Python 服務將應用程式記錄、指標和追蹤資料傳送至 Azure Monitor,進行集中式記錄與分析。
安全性稽核記錄
將安全性事件、驗證記錄與合規資料匯入 Log Analytics,以進行安全性監控與威脅偵測。
商業分析整合
從 Python 應用程式將商業指標與營運資料推送至 Log Analytics,以建立自訂報表與儀��板。
試試這些提示
Show me how to use the Azure Monitor Ingestion SDK to upload custom logs to a Log Analytics workspace. Include the client setup with DefaultAzureCredential.
How do I handle partial upload failures when sending logs to Azure Monitor? Show an example with error callback and retry logic.
Write an example of using the async LogsIngestionClient to upload logs in a high-throughput Python application.
How do I configure the Azure Monitor Ingestion client for Azure Government cloud instead of public Azure?
最佳實務
- Always include the TimeGenerated field in your log entries - it is required by Azure Monitor
- Use the on_error callback to handle partial failures and implement retry logic for failed logs
- Match your log schema to the Data Collection Rule column definitions to ensure proper ingestion
避免
- Do not hardcode credentials in your application code - use Azure Identity
- Do not skip error handling - network failures and partial uploads are common in log ingestion
- Do not send logs without first validating they match your DCR schema - mismatched data will be rejected
常見問題
Azure Monitor 中的 DCE 與 DCR 有何差異?
我需要先建立 Log Analytics 資料表嗎?
SDK 如何處理大量記錄?
我可以將此 SDK 與 Azure Government 搭配使用嗎?
如果部分記錄上傳失敗會發生什麼情況?
是否支援非同步功能?
開發者詳情
作者
sickn33授權
MIT
儲存庫
https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-monitor-ingestion-py引用
main
檔案結構
📄 SKILL.md