grafana / oncall

Developer-friendly incident response with brilliant Slack integration
GNU Affero General Public License v3.0
3.55k stars 294 forks source link

Ability to create an Alert Groups via the public API #2762

Closed njohnstone2 closed 1 month ago

njohnstone2 commented 1 year ago

What would you like to see!

According to the docs only get and delete are supported for alert groups. It would be really useful to be able to create an ad hoc alert group via the API. This functionality is currently supported in the UI and slack slash commands.

My use case is that I have application code that runs in response to events in my cloud account. I'd like the ability to trigger oncall alerts when these events occur.

example payload being used by the UI (internal API)

{
  "team": "<TEAM_ID>",
  "title": "my test alert",
  "message": "testing manually created alerts",
  "users": [],
  "schedules": [
    {
      "important": false,
      "id": "<SCHEDULE_ID>"
    }
  ]
}

Product Area

Alert Flow & Configuration

Anything else to add?

Workaround

My current work around is to publish these events as a metric which can be used in an alerting rule. This works for triggering the alert but due to the nature of events (firing then shortly after returning to 0) the alert will quickly return to a healthy state without necessarily being acknowledged by the person oncall.

github-actions[bot] commented 1 year ago

The current version of Grafana OnCall, at the time this issue was opened, is v1.3.22. If your issue pertains to an older version of Grafana OnCall, please be sure to list it in the PR description. Thank you :smile:!

njohnstone2 commented 1 year ago

This turned out to be user error. In this case, alerts should be created using the inbound webhook/formatted webhook integrations.

Is it worth mentioning this integration on the HTTP API docs? As i was clearly looking in the wrong place.

mjs commented 9 months ago

It might still be nice to be able to create alert groups via the API. As noted in #3912, submitting via an inbound webhook has some limitations.