Skip to content

fix(monitors): drop notify_by=["*"] when query has no by-group clause#625

Merged
riyazsh merged 1 commit into
mainfrom
riyaz/HAMR-392-monitor-notify-by
Jul 14, 2026
Merged

fix(monitors): drop notify_by=["*"] when query has no by-group clause#625
riyazsh merged 1 commit into
mainfrom
riyaz/HAMR-392-monitor-notify-by

Conversation

@riyazsh

@riyazsh riyazsh commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

options.notify_by = ["*"] is a documented "simple monitor" sentinel that is effectively a no-op on an ungrouped monitor. Some destinations enable a validator that rejects any non-empty notify_by when the query has no grouping clause. Drop the sentinel only when it is exactly ["*"] AND the query has no grouping. Any concrete list (e.g. ["host"]) on an ungrouped query is a real misconfiguration and stays in place so the 400 still surfaces.

Grouping detection covers:

  • by {host, service} (query / metric / service check alerts)
  • .by(...) / .BY(...) (log / event-v2 / process alerts, case-insensitive)
  • options.variables[*].group_by (formula/function monitors, invisible to a query-string regex)

Runs in pre_resource_action_hook alongside existing custom_schedule / warning_recovery migrations. Null-safe on options, query, and variables.

Test plan

14 new unit tests in TestMonitorsSchemaMigrations — drop on ungrouped queries across query alert / event-v2 alert / log alert; preserve on grouped queries in every syntax form (braces, .by(...), formula variables, uppercase BY); preserve named group keys and multi-entry lists; no-op when notify_by absent or empty; null-safety on missing query. Full tests/unit/ suite passes (0 regressions).

@riyazsh
riyazsh requested a review from a team as a code owner July 13, 2026 20:23
@riyazsh
riyazsh force-pushed the riyaz/HAMR-392-monitor-notify-by branch from 1de8187 to 51159c4 Compare July 13, 2026 20:30
Some environments enable a validator that rejects a non-empty notify_by
when the monitor query lacks a `by {...}` group clause. The ["*"] value
is a documented "simple monitor" sentinel that is effectively a no-op
on an ungrouped monitor.

Drop options.notify_by only when it is exactly ["*"] and the query has
no `by {...}` clause. Any concrete group-key list (e.g. ["host"]) on an
ungrouped query is a real misconfiguration and is left in place so the
400 still surfaces it.

Runs in pre_resource_action_hook alongside the existing custom_schedule
and warning_recovery migrations. Null-safe on options and query.

7 new unit tests.
@riyazsh
riyazsh force-pushed the riyaz/HAMR-392-monitor-notify-by branch from 51159c4 to 5b5aa18 Compare July 13, 2026 20:35
@riyazsh
riyazsh merged commit 734fcde into main Jul 14, 2026
11 checks passed
@riyazsh
riyazsh deleted the riyaz/HAMR-392-monitor-notify-by branch July 14, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants