技能 Azure Monitor Ingestion SDK for Python
📦

Azure Monitor Ingestion SDK for Python

安全

將自訂記錄傳送至 Azure Monitor

此技能可讓 Claude Code 使用官方的 Logs Ingestion API,將自訂應用程式記錄傳送至 Azure Monitor Log Analytics 工作區。它提供程式碼範例與最佳實務,協助您在 Python 應用程式中整合 Azure 監控。

支援: Claude Codex Code(CC)
🥉 73 青銅
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「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.

安全審計

安全
v1 • 2/25/2026

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.

0
已掃描檔案
0
分析行數
0
發現項
1
審計總數
未發現安全問題
審計者: claude

品質評分

38
架構
100
可維護性
87
內容
50
社群
100
安全
83
規範符合性

你能建構什麼

應用程式效能監控

從 Python 服務將應用程式記錄、指標和追蹤資料傳送至 Azure Monitor,進行集中式記錄與分析。

安全性稽核記錄

將安全性事件、驗證記錄與合規資料匯入 Log Analytics,以進行安全性監控與威脅偵測。

商業分析整合

從 Python 應用程式將商業指標與營運資料推送至 Log Analytics,以建立自訂報表與儀��板。

試試這些提示

Basic Log Upload
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.
Error Handling
How do I handle partial upload failures when sending logs to Azure Monitor? Show an example with error callback and retry logic.
Async Ingestion
Write an example of using the async LogsIngestionClient to upload logs in a high-throughput Python application.
Sovereign Cloud Configuration
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 有何差異?
Data Collection Endpoint (DCE) 是傳送記錄的擷取 URL。Data Collection Rule (DCR) 則定義記錄的結構描述、轉換與目的地資料表。
我需要先建立 Log Analytics 資料表嗎?
對於自訂資料表,當 DCR 首次處理擷取時會自動建立資料表。內建資料表則必須在傳送資料前先存在。
SDK 如何處理大量記錄?
SDK 會自動將記錄分批為 1MB 的區塊,使用 gzip 壓縮,並平行上傳。您不需要手動實作分批處理。
我可以將此 SDK 與 Azure Government 搭配使用嗎?
可以,使用 AzureAuthorityHosts 為 Azure Government 或其他主權雲端設定 authority 與 credential_scopes。
如果部分記錄上傳失敗會發生什麼情況?
SDK 提供一個 on_error 回呼函式,可接收失敗的記錄項目。您可以實作重試邏輯來重新傳送這些記錄。
是否支援非同步功能?
可以,在高效能場景中,使用來自 azure.monitor.ingestion.aio 的 LogsIngestionClient 搭配 async/await 模式。

開發者詳情

檔案結構

📄 SKILL.md