Skip to content

alerting_manage_rules get operation discards full query model, breaking round-trip updates for non-PromQL datasources #732

@hanks

Description

@hanks

Bug

The alerting_manage_rules get operation returns only a querySummary for each query (ref_id, datasource_uid, expression), discarding the full query model from the provisioning API response. This makes it impossible to round-trip get -> update without silently losing datasource-specific fields.

Affected Fields

Fields present in the provisioning API response but missing from the get output:

  • Graphite: target, datasource, textEditor
  • OpenSearch/Elasticsearch: bucketAggs, metrics, queryType, timeField, format
  • All datasources: intervalMs, maxDataPoints, relativeTimeRange (full model)
  • Classic conditions: query.params, operator, reducer (within conditions)

Steps to Reproduce

  1. Create an alert rule with a Graphite query (e.g., target: "alias(asPercent(a, b), 'rate')")
  2. Use alerting_manage_rules with operation: get to retrieve the rule
  3. The response queries array shows only:
    {"ref_id": "A", "datasource_uid": "000000004", "expression": ""}
  4. The Graphite target field is invisible — expression is empty because extractQuerySummaries only looks for expr, expression, and query keys
  5. Using this output to construct an update payload results in an empty query model, breaking the alert

Root Cause

In tools/alerting_manage_rules_handlers.go, mergeRuleDetail calls extractQuerySummaries which creates a compact querySummary struct. The full provisioned.Data (which contains complete models.AlertQuery with full model maps) is discarded.

Expected Behavior

The get response should include the full query data alongside the summary, enabling safe get -> update round-trips for all datasource types.

Environment

  • mcp-grafana v0.11.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions