Skip to content

MCP: allow filtering list_alert_rules by cluster #4288

@ebarron

Description

@ebarron

Summary

Add an optional cluster parameter to the list_alert_rules MCP tool so users can list only alert rules that target a specific cluster (or set of clusters), instead of always returning every rule defined in alert_rules.yml / ems_alert_rules.yml.

Background

list_alert_rules reads the rule files via the rule manager and returns the full inventory. Cluster scoping today is only possible if a cluster name happens to appear inside a rule's expr (e.g. volume_size_used_percent{cluster="prod-east-1"} > 90), and even then the user has to grep the response themselves.

In multi-cluster Harvest deployments operators commonly want to answer:

  • "Which alert rules apply to prod-east-1?"
  • "Show me all rules that mention lab-cluster-2."

…without paging through dozens of unrelated rules.

Proposed enhancement

Add an optional argument:

  • cluster — exact cluster name, or
  • cluster_match — regex pattern.

When provided, filter the returned AlertRules and EMSRules lists to only include rules whose:

  • expr contains a label matcher referencing the cluster (cluster="X", cluster=~"pattern", or substring match), or
  • labels.cluster matches the requested cluster(s).

When omitted, behavior is unchanged (return everything).

Use cases

  • "What alerts are configured for my prod-east-1 cluster?"
  • Per-datacenter rule audits.
  • Chatbot conversations scoped to a single cluster ("show me my volume rules for cluster X").

Notes

Filed as part of a NAbox chatbot integration review. Companion issues: #4286 (infrastructure_health), #4287 (get_active_alerts). Together these three are the only harvest-mcp tools that currently can't be scoped to a cluster — the rest already allow it via PromQL label matchers in their query arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions