How to obtain historical alerts information

Dear devepopers and friends:
I have created several alerts. Now I want to obtain the alarm information for a certain period of time. What api should I use to obtain the alert information

welcome to the :grafana: community @zhangmingyuu

try this API:


it will return what was the alert state at certain period of time in a similar way as what you see in the state history in the UI

API response reflecting last status change:

        "newState": "Alerting",
        "prevState": "Pending",

You could filter by alertId

If you don’t know the alertId, you can retrieve it via this other endpoint:

GET /api/v1/provisioning/alert-rules/{UID}

Note: the UID of the alert shows in the browser’s URL when viewing/editing the alert in the UI

Hi, @antonio Thank you for your reply!
I have used this API:“/api/annotations”, but how do I obtain alarm information within a certain time range, like 7:00-8:00

try adding the from and to parameters to your request.

the bellow range is Friday, March 31, 2023 from 7:00 to 8:00 (in epoch timestamp):


note: you can convert time to epoch timestamp using an online calculator such as this one

1 Like

Hi, @antonio.merello ! Is there a way to get paginated response from this endpoint?

I tried offset and keyset pagination but it didn’t work :man_shrugging:

You could suggest the implementation of pagination here (note there will be a new feature request issue template soon. In the meantime you can open it as an “issue”. You could add “feature request” as part of the issue title).