azure-observability
Azure 可觀測性:Monitor、App Insights 與 KQL
此技能為 Claude 提供 Azure 監控服務、Application Insights、Log Analytics、KQL 查詢及 SDK 參考資料,以用於在 Azure 應用程式中實現全端可觀測性。
تنزيل ZIP المهارة
رفع في Claude
اذهب إلى Settings → Capabilities → Skills → Upload skill
فعّل وابدأ الاستخدام
اختبرها
استخدام "azure-observability". 從 Application Insights 查詢近期的例外狀況
النتيجة المتوقعة:
使用此 KQL 查詢:
```kql
AppExceptions
| where TimeGenerated > ago(1h)
| project TimeGenerated, Message, StackTrace
| order by TimeGenerated desc
```
或使用 Azure CLI:
```bash
az monitor log-analytics query \
--workspace WORKSPACE_ID \
--analytics-query "AppExceptions | where TimeGenerated > ago(1h)"
```
استخدام "azure-observability". 如何為 Python 設定 OpenTelemetry
النتيجة المتوقعة:
安裝套件:
```bash
pip install azure-monitor-opentelemetry
```
然後在 Python 程式碼中設定:
```python
from azure.monitor.opentelemetry import configure_azure_monitor
configure_azure_monitor()
```
最佳做法:
- 在匯入檢測的程式庫之前盡早呼叫 configure_azure_monitor()
- 在生產環境中使用環境變數設定連線字串
- 設定雲端角色名稱以支援多服務 Application Map
التدقيق الأمني
آمنThis is an official Microsoft documentation skill containing only markdown reference files. All 57 static findings are false positives: backtick commands are CLI examples in documentation, URLs point to Microsoft Learn documentation, and environment variable patterns are standard configuration. No malicious behavior detected.
درجة الجودة
ماذا يمكنك بناءه
使用 App Insights 偵錯應用程式錯誤
查詢 Application Insights 以找出近期的例外狀況、失敗要求及生產環境應用程式的效能問題。
分析基礎架構指標
使用 Azure Monitor 和 Log Analytics 查詢 Azure 資源的 CPU、記憶體和磁碟指標。
建置自訂監控儀表板
為自訂報告建立 KQL 查詢,並與 Azure Workbooks 整合以進行互動式視覺化。
جرّب هذه الموجهات
顯示如何使用 KQL 從 Application Insights 查詢近期的錯誤,以找出過去一小時內的例外狀況。
撰寫 KQL 查詢以從 App Insights 取得平均回應時間和要求計數,並依作業名稱分組。
顯示如何為 Python FastAPI 應用程式設定 Azure Monitor OpenTelemetry,並加入自訂範圍屬性。
提供 CLI 命令以列出 Log Analytics 工作區並查詢虛擬機器的 CPU 指標。
أفضل الممارسات
- 使用带有時間篩選條件(ago())的 KQL 查詢來限制結果集並提升效能
- 在應用程式啟動時、匯入其他受檢測的程式庫之前設定 OpenTelemetry
- 在生產工作負載中使用 AAD 驗證而非檢測金鑰
تجنب
- 避免查詢大範圍時間而不使用篩選條件 - 這會導致查詢緩慢且成本高昂
- 不要在原始程式碼中硬編碼連線字串 - 應使用環境變數
- 避免在 Application Insights 中記錄敏感的使用者資料 - 這會造成合規問題
الأسئلة المتكررة
Azure Monitor 和 Application Insights 有什麼差別?
使用此技能是否需要 Azure 訂用帳戶?
此技能是否可以建立 Application Insights 資源?
什麼是 KQL?
如何啟用 Azure MCP 伺服器?
所有 Azure 服務都支援 OpenTelemetry 嗎?
تفاصيل المطور
المؤلف
microsoftالترخيص
MIT
المستودع
https://github.com/microsoft/github-copilot-for-azure/tree/main/plugin/skills/azure-observability/مرجع
main