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 community @zhangmingyuu
try this API:
/api/annotations?alertId=XX
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):
/api/annotations?alertId=XX&from=1680246000&to=1680249600
note: you can convert time to epoch timestamp using an online calculator such as this one
I tried offset and keyset pagination but it didn’t work
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).