mcpField
A
azure-resource-health-diagnose

azure-resource-health-diagnose

github.com/github云与 DevOps40.5k8.7k 次安装今天更新
代码仓库

关于 azure-resource-health-diagnose

用于评估 Azure 资源健康状况并通过监控数据排查问题的工作流技能,涵盖资源定位、根因分析,以及按优先级制定修复和验证计划。

主要功能

  1. 01Azure 资源发现
  2. 02健康状态与可用性评估
  3. 03日志和遥测分析
  4. 04问题分类与根因分析
  5. 05分级修复计划
  6. 06验证与回滚指导

适用场景

  1. 01调查 Azure 资源中断
  2. 02查找性能下降原因
  3. 03制定恢复与预防计划

MCP 相关

通过已配置并完成认证的 Azure MCP 服务工具发现资源、评估监控数据并执行 Log Analytics 查询;Azure CLI 用作备用方案。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/github/awesome-copilot --skill azure-resource-health-diagnose

安装后在 Claude Code 中输入/azure-resource-health-diagnose确认已加载。

详细介绍

Azure 资源运行状况与问题诊断

此工作流分析特定的 Azure 资源,以评估其运行状况,利用日志和遥测数据诊断潜在问题,并针对发现的任何问题制定全面的修复计划。

先决条件

  • 已配置并验证 Azure MCP 服务
  • 已确定目标 Azure 资源(名称,以及可选的资源组/订阅)
  • 资源必须已部署并正在运行,以生成日志/遥测数据
  • 在可用的情况下,优先使用 Azure MCP 工具(azmcp-*),而非直接使用 Azure CLI

工作流步骤

步骤 1:获取 Azure 最佳实践

操作:检索诊断和故障排除最佳实践 工具:Azure MCP 最佳实践工具 过程:

  1. 加载最佳实践:
    • 执行 Azure 最佳实践工具以获取诊断指南
    • 重点关注运行状况监控、日志分析和问题解决模式
    • 使用这些实践来指导诊断方法和修复建议
步骤 2:资源发现与识别

操作:定位并识别目标 Azure 资源 工具:Azure MCP 工具 + Azure CLI 回退 过程:

  1. 资源查找:

    • 如果仅提供了资源名称:使用 azmcp-subscription-list 跨订阅搜索
    • 使用 az resource list --name <resource-name> 查找匹配的资源
    • 如果找到多个匹配项,提示用户指定订阅/资源组
    • 收集详细的资源信息:
      • 资源类型和当前状态
      • 位置、标记和配置
      • 关联的服务和依赖项
  2. 资源类型检测:

    • 识别资源类型以确定适当的诊断方法:
      • Web 应用/函数应用:应用程序日志、性能指标、依赖项跟踪
      • 虚拟机:系统日志、性能计数器、启动诊断
      • Cosmos DB:请求指标、限制、分区统计信息
      • 存储帐户:访问日志、性能指标、可用性
      • SQL 数据库:查询性能、连接日志、资源利用率
      • Application Insights:应用程序遥测、异常、依赖项
      • Key Vault:访问日志、证书状态、机密使用情况
      • Service Bus:消息指标、死信队列、吞吐量
步骤 3:运行状况评估

操作:评估当前资源运行状况和可用性 工具:Azure MCP 监控工具 + Azure CLI 过程:

  1. 基本运行状况检查:

    • 检查资源配置状态和运行状态
    • 验证服务可用性和响应能力
    • 查看最近的部署或配置更改
    • 评估当前资源利用率(CPU、内存、存储等)
  2. 服务特定的运行状况指标:

    • Web 应用:HTTP 响应代码、响应时间、运行时间
    • 数据库:连接成功率、查询性能、死锁
    • 存储:可用性百分比、请求成功率、延迟
    • VM:启动诊断、来宾 OS 指标、网络连接
    • 函数:执行成功率、持续时间、错误频率
步骤 4:日志与遥测分析

操作:分析日志与遥测数据,以识别问题和模式 工具:用于 Log Analytics 查询的 Azure MCP 监控工具 流程:

  1. 查找监控源:

    • 使用 azmcp-monitor-workspace-list 识别 Log Analytics 工作区
    • 定位与该资源关联的 Application Insights 实例
    • 使用 azmcp-monitor-table-list 识别相关日志表
  2. 执行诊断查询: 根据资源类型,使用 azmcp-monitor-log-query 执行有针对性的 KQL 查询:

    常规错误分析:

    // Recent errors and exceptions
    union isfuzzy=true 
        AzureDiagnostics,
        AppServiceHTTPLogs,
        AppServiceAppLogs,
        AzureActivity
    | where TimeGenerated > ago(24h)
    | where Level == "Error" or ResultType != "Success"
    | summarize ErrorCount=count() by Resource, ResultType, bin(TimeGenerated, 1h)
    | order by TimeGenerated desc
    

    性能分析:

    // Performance degradation patterns
    Perf
    | where TimeGenerated > ago(7d)
    | where ObjectName == "Processor" and CounterName == "% Processor Time"
    | summarize avg(CounterValue) by Computer, bin(TimeGenerated, 1h)
    | where avg_CounterValue > 80
    

    应用程序特定查询:

    // Application Insights - Failed requests
    requests
    | where timestamp > ago(24h)
    | where success == false
    | summarize FailureCount=count() by resultCode, bin(timestamp, 1h)
    | order by timestamp desc
    
    // Database - Connection failures
    AzureDiagnostics
    | where ResourceProvider == "MICROSOFT.SQL"
    | where Category == "SQLSecurityAuditEvents"
    | where action_name_s == "CONNECTION_FAILED"
    | summarize ConnectionFailures=count() by bin(TimeGenerated, 1h)
    
  3. 模式识别:

    • 识别反复出现的错误模式或异常
    • 将错误与部署时间或配置变更关联起来
    • 分析性能趋势和退化模式
    • 查找依赖项故障或外部服务问题
步骤 5:问题分类与根因分析

操作:对识别出的问题进行分类并确定根因 流程:

  1. 问题分类:

    • 严重:服务不可用、数据丢失、安全泄露
    • 高:性能退化、间歇性故障、高错误率
    • 中:警告、次优配置、轻微性能问题
    • 低:信息性警报、优化机会
  2. 根因分析:

    • 配置问题:设置不正确、缺少依赖项
    • 资源限制:CPU/内存/磁盘限制、限流
    • 网络问题:连接问题、DNS 解析、防火墙规则
    • 应用程序问题:代码缺陷、内存泄漏、低效查询
    • 外部依赖项:第三方服务故障、API 限制
    • 安全问题:身份验证失败、证书过期
  3. 影响评估:

    • 确定业务影响以及受影响的用户/系统
    • 评估数据完整性和安全影响
    • 评估恢复时间目标和优先级
步骤 6:生成修复计划

操作:创建全面计划以解决识别出的问题 流程:

  1. 即时操作(严重问题):

    • 通过紧急修复恢复服务可用性
    • 通过临时变通方法减轻影响
    • 针对复杂问题的升级流程
  2. 短期修复(高/中问题):

    • 配置调整和资源扩缩容
    • 应用程序更新和补丁
    • 监控和告警改进
  3. 长期改进(所有问题):

    • 通过架构变更提升韧性
    • 预防措施和监控增强
    • 文档和流程改进
  4. 实施步骤:

    • 带有具体 Azure CLI 命令的优先行动项
    • 测试和验证流程
    • 每项变更的回滚计划
    • 通过监控验证问题解决情况
步骤 7:用户确认与报告生成

操作:展示发现结果并获取修复操作的批准 流程:

  1. 显示健康状况评估摘要:

    🏥 Azure Resource Health Assessment
    
    📊 Resource Overview:
    • Resource: [Name] ([Type])
    • Status: [Healthy/Warning/Critical]
    • Location: [Region]
    • Last Analyzed: [Timestamp]
    
    🚨 Issues Identified:
    • Critical: X issues requiring immediate attention
    • High: Y issues affecting performance/reliability  
    • Medium: Z issues for optimization
    • Low: N informational items
    
    🔍 Top Issues:
    1. [Issue Type]: [Description] - Impact: [High/Medium/Low]
    2. [Issue Type]: [Description] - Impact: [High/Medium/Low]
    3. [Issue Type]: [Description] - Impact: [High/Medium/Low]
    
    🛠️ Remediation Plan:
    • Immediate Actions: X items
    • Short-term Fixes: Y items  
    • Long-term Improvements: Z items
    • Estimated Resolution Time: [Timeline]
    
    ❓ Proceed with detailed remediation plan? (y/n)
    
  2. 生成详细报告:

    # Azure Resource Health Report: [Resource Name]
    
    **Generated**: [Timestamp]  
    **Resource**: [Full Resource ID]  
    **Overall Health**: [Status with color indicator]
    
    ## 🔍 Executive Summary
    [Brief overview of health status and key findings]
    
    ## 📊 Health Metrics
    - **Availability**: X% over last 24h
    - **Performance**: [Average response time/throughput]
    - **Error Rate**: X% over last 24h
    - **Resource Utilization**: [CPU/Memory/Storage percentages]
    
    ## 🚨 Issues Identified
    
    ### Critical Issues
    - **[Issue 1]**: [Description]
      - **Root Cause**: [Analysis]
      - **Impact**: [Business impact]
      - **Immediate Action**: [Required steps]
    
    ### High Priority Issues  
    - **[Issue 2]**: [Description]
      - **Root Cause**: [Analysis]
      - **Impact**: [Performance/reliability impact]
      - **Recommended Fix**: [Solution steps]
    
    ## 🛠️ Remediation Plan
    
    ### Phase 1: Immediate Actions (0-2 hours)
    ```bash
    # Critical fixes to restore service
    [Azure CLI commands with explanations]
    
    阶段 2:短期修复(2-24 小时)
    # Performance and reliability improvements
    [Azure CLI commands with explanations]
    
    阶段 3:长期改进(1-4 周)
    # Architectural and preventive measures
    [Azure CLI commands and configuration changes]
    

    📈 监控建议

    • 要配置的告警:[推荐告警列表]
    • 要创建的仪表板:[监控仪表板建议]
    • 定期健康检查:[推荐频率和范围]

    ✅ 验证步骤

    • 通过日志验证问题已解决
    • 确认性能改进
    • 测试应用程序功能
    • 更新监控和告警
    • 记录经验教训

    📝 预防措施

    • [防止类似问题的建议]
    • [流程改进]
    • [监控增强]

Error Handling

  • Resource Not Found: Provide guidance on resource name/location specification
  • Authentication Issues: Guide user through Azure authentication setup
  • Insufficient Permissions: List required RBAC roles for resource access
  • No Logs Available: Suggest enabling diagnostic settings and waiting for data
  • Query Timeouts: Break down analysis into smaller time windows
  • Service-Specific Issues: Provide generic health assessment with limitations noted

Success Criteria

  • ✅ Resource health status accurately assessed
  • ✅ All significant issues identified and categorized
  • ✅ Root cause analysis completed for major problems
  • ✅ Actionable remediation plan with specific steps provided
  • ✅ Monitoring and prevention recommendations included
  • ✅ Clear prioritization of issues by business impact
  • ✅ Implementation steps include validation and rollback procedures

评论

支持 Markdown