grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
67.02k stars 12.46k forks source link

[alerting] time intervals #99810

Open nlamirault opened 1 month ago

nlamirault commented 1 month ago

Why is this needed:

Alertmanager has both mute_time_intervals and active_time_intervals. Do you think it is in the roadmap of Grafana to support both?

What would you like to be added:

when I want a only business hour alert, I wrote the PromQL query, do another query for only business hour and after that a Math request.

I could be useful to replace something like:

(vector(1) and on() hour() >= vector(6) <= vector(17) and on() day_of_week() >= vector(1) <= vector(5)) or vector(0)

to something like:

active_time_intervals: business_hours

Who is this feature for?

[Add information on what kind of user the feature is for.]

Alertmanager documentation

# Times when the route should be muted. These must match the name of a
# time interval defined in the time_intervals section.
# Additionally, the root node cannot have any mute times.
# When a route is muted it will not send any notifications, but
# otherwise acts normally (including ending the route-matching process
# if the `continue` option is not set.)
mute_time_intervals:
  [ - <string> ...]

# Times when the route should be active. These must match the name of a
# time interval defined in the time_intervals section. An empty value
# means that the route is always active.
# Additionally, the root node cannot have any active times.
# The route will send notifications only when active, but otherwise
# acts normally (including ending the route-matching process
# if the `continue` option is not set).
active_time_intervals:
  [ - <string> ...]
yuri-tceretian commented 1 month ago

This needs some frontend and backend work but the latter is more important now. The good thing is that we have almost done it. The only missing piece is API. There are a couple of APIs that need to be updated but it's just matter of copying a field whereas mute_time_interval is mentioned.

We would appreciate a community contribution, and I can promise a prompt review for the pull request.

KyriosGN0 commented 1 month ago

@yuri-tceretian i will take a look into this tomorrow, will ping you when i have a PR 🙏