holmesgpt icon indicating copy to clipboard operation
holmesgpt copied to clipboard

Add azuremonitormetrics toolset & azuremonitorlogs toolset (both toolsets for CLI only)

Open vishiy opened this issue 4 months ago • 3 comments

  • Add azure monitor metrics toolset for CLI
  • Add azuremonitor logs toolset for CLI - Note : I have disabled azuremonitorlogs toolset for now, as it requires AzureMCP (which has removed SSE based activations from last release) where as HOlmes support only SSE . Once Holmes supports stdout, i will enable azuremonitor logs toolset in CLI by default.
  • Also added azuremonitoraerts for investigate flows to investigate metric based alerts in azure monitor.
  • All the tools use defaultcreds that requires login from az cli
  • Added unit tests for azure monitor metrics & alerts (will add azuremonitorlogs tests in subsequent PRs when azuremonitorlogs get enabled)

vishiy avatar Aug 04 '25 18:08 vishiy

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 04 '25 18:08 CLAassistant

Walkthrough

This update introduces comprehensive Azure Monitor integration for AKS clusters, adding new toolsets for Azure Monitor Metrics and Logs, complete with configuration, installation, and troubleshooting documentation. It implements new plugins for fetching and investigating Azure Monitor Prometheus metric alerts, extends the CLI with alert investigation commands, and provides diagnostic runbooks for systematic alert analysis. Extensive unit tests and documentation support these additions, alongside dependency updates and configuration examples.

Changes

Cohort / File(s) Change Summary
Azure Monitor Metrics Toolset Implementation
holmes/plugins/toolsets/azuremonitor_metrics/azuremonitor_metrics_toolset.py, holmes/plugins/toolsets/azuremonitor_metrics/utils.py, holmes/plugins/toolsets/azuremonitor_metrics/azuremonitor_metrics_instructions.jinja2, holmes/plugins/toolsets/azuremonitor_metrics/install.md, holmes/plugins/toolsets/azuremonitor_metrics/__init__.py
Implements Azure Monitor Metrics toolset for querying managed Prometheus metrics on AKS clusters, including configuration, installation guide, utility functions for cluster/resource detection, LLM instructions, and module docstring.
Azure Monitor Logs Toolset Implementation
holmes/plugins/toolsets/azuremonitorlogs/azuremonitorlogs_toolset.py, holmes/plugins/toolsets/azuremonitorlogs/utils.py, holmes/plugins/toolsets/azuremonitorlogs/azuremonitorlogs_instructions.jinja2, holmes/plugins/toolsets/azuremonitorlogs/install.md, holmes/plugins/toolsets/azuremonitorlogs/__init__.py
Adds Azure Monitor Logs toolset for AKS Container Insights detection and Log Analytics workspace integration, with configuration, installation, utilities for cluster/workspace detection, and instruction documentation.
Azure Monitor Alerts Source Plugin
holmes/plugins/sources/azuremonitoralerts/__init__.py
Implements a new source plugin to fetch and process Azure Monitor Prometheus metric alerts for AKS clusters, converting them into Holmes issues with detailed query and description extraction.
Runbooks for Azure Monitor & Kubernetes Troubleshooting
holmes/plugins/runbooks/azuremonitor-alerts.yaml, holmes/plugins/runbooks/azure_monitor_logs_cost_optimization.md, holmes/plugins/runbooks/catalog.json, holmes/plugins/runbooks/networking/dns_troubleshooting_prometheus_instructions.md, holmes/plugins/runbooks/node_troubleshooting_prometheus_instructions.md, holmes/plugins/runbooks/pod_troubleshooting_prometheus_instructions.md, examples/azuremonitor_runbooks.yaml
Adds YAML and Markdown runbooks for Azure Monitor alert diagnostics, cost optimization, and Kubernetes troubleshooting (DNS, node, pod issues), and updates the runbooks catalog.
Documentation and Guides
AZURE_MONITOR_SETUP_GUIDE.md, docs/toolsets/azuremonitor-metrics.md, docs/toolsets/azuremonitor-logs.md, README.md, config.example.yaml
Introduces setup, usage, and troubleshooting guides for Azure Monitor toolsets, updates README with new integrations, and extends configuration examples.
Toolset and Core Integration
holmes/plugins/toolsets/__init__.py, holmes/core/toolset_manager.py
Integrates new toolsets with conditional imports, availability checks, and special enable/disable logic for default toolsets.
CLI and Investigation Enhancements
holmes/main.py, holmes/core/tool_calling_llm.py, holmes/core/runbooks.py
Adds CLI command for Azure Monitor Prometheus alert investigation, improves runbook display in investigations, and introduces a method to retrieve matched runbooks with metadata.
Dependency Updates
pyproject.toml
Adds azure-mgmt-resourcegraph dependency and updates azure-mgmt-resource version.
Azure Monitor Metrics Toolset Tests
tests/plugins/toolsets/azuremonitor_metrics/test_azuremonitor_metrics_tools.py, tests/plugins/toolsets/azuremonitor_metrics/README.md
Adds comprehensive unit tests and documentation for the Azure Monitor Metrics toolset, covering all tools, success/failure cases, and mocking strategies.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI (holmes/main.py)
    participant AzureMonitorAlertsSource
    participant Azure API
    participant Investigator
    participant RunbookManager

    User->>CLI (holmes/main.py): Run `azuremonitormetrics --alertid=...`
    CLI (holmes/main.py)->>AzureMonitorAlertsSource: fetch_issue(alertid)
    AzureMonitorAlertsSource->>Azure API: Query Alert Management API
    Azure API-->>AzureMonitorAlertsSource: Return alert details
    AzureMonitorAlertsSource-->>CLI (holmes/main.py): Return Issue object
    CLI (holmes/main.py)->>Investigator: investigate(issue)
    Investigator->>RunbookManager: get_matched_runbooks_for_issue(issue)
    RunbookManager-->>Investigator: Return matched runbooks
    Investigator-->>CLI (holmes/main.py): Investigation result
    CLI (holmes/main.py)-->>User: Display analysis and runbook info
sequenceDiagram
    participant HolmesGPT
    participant AzureMonitorMetricsToolset
    participant Azure API
    participant AKS Cluster

    HolmesGPT->>AzureMonitorMetricsToolset: Execute PromQL query
    AzureMonitorMetricsToolset->>Azure API: Authenticate (Azure CLI/Managed Identity)
    AzureMonitorMetricsToolset->>AKS Cluster: Detect cluster resource ID
    AzureMonitorMetricsToolset->>Azure API: Query Prometheus endpoint
    Azure API-->>AzureMonitorMetricsToolset: Return metrics/alerts
    AzureMonitorMetricsToolset-->>HolmesGPT: Return results

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~70 minutes

Suggested reviewers

  • arikalon1

[!NOTE]

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Aug 04 '25 18:08 coderabbitai[bot]

@austonli @aritraghosh @pavneeta

vishiy avatar Aug 04 '25 18:08 vishiy