1

I am use Grafana with a lot of Dashboards and Panels. Many panels have alerts. Accordingly, these alerts often change their state, for example, from OK to Altering or no_data.

I also have my application (ASP.NET Core) where I want to get the current state of alert for some panel, as well as alert history, using the Grafana HTTP API.

Using a request like:

GET api/alerts?PanelId=36 

I only get the latest notification state. How do I get notification history for this panel? Such that I can see in the Grafana interface using Panel-> Edit-> Alert-> State History. Maybe i need to do something with the query or dashboardQuery parameters of the API GET request?

Thanks!

3 Answers3

0

https://grafana.com/docs/grafana/latest/http_api/alerting/

Add state=ALL to the query string

tomgalpin
  • 1,943
  • 1
  • 4
  • 12
0

You can use the '/api/annotations?limit=100&&type=alert' API

Erick Storck
  • 91
  • 1
  • 4
0

I looked around in browser's dev-mode, and searched for "api" and discovered the results were rendered from a GET towards /api/annotations?from=1618380800000&to=1618898976586&dashboardId=565&panelId=40 setting the time accordingly.

Afterwards, I realised it's well documented in https://grafana.com/docs/grafana/latest/http_api/annotations/#find-annotations