Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: API spec for paginated version of getAlertGroups and getAlerts #3361

Open
qinxx108 opened this issue May 11, 2023 · 3 comments
Open

Comments

@qinxx108
Copy link
Contributor

qinxx108 commented May 11, 2023

Background

Without pagination of the APIs, the getAlertGroups and getAlerts can cause a significant performance impact on the server
After discussed in proposal, we get an agreement on create a brand new API to return only alert group information.
This proposal will discuss the API spec of the paginated version of getAlertGroups and getAlerts

getAlertGroupsInfo

  • URL query parameters:
    • maxResults Integer. The maximum number of alert groups to return in one getAlertGroupsInfo operation. The range is 1–1000. Optional
    • nextToken String. The token for the next set of items to return. (You received this token from a previous call.). Optional
    • filter An array of strings. A list of matchers to filter alert group by. Optional
    • receiver String. A regular expression matching receivers to filter alerts by. Optional
  • Sample response
      groups: [
      {
          "labels": {
              "group": "hello1"
          },
          "receiver": {
              "name": "example-sns"
          },
          "route": "{ROUTE_UUID}"
      },
      {
          "labels": {
              "group": "hello2"
          },
          "receiver": {
              "name": "example-sns"
          }, 
          "fingerprint": "{group_UUID}"
      }
      ],
        nextToken:"123"

getAlerts

  • URL query parameters:
    • maxResults Integer. The maximum number of alerts to return in one getAlerts operation. The range is 1–1000. Optional
    • nextToken String. The token for the next set of items to return. (You received this token from a previous call.). Optional
    • active Boolean. If true, the returned list includes active alerts. The default is true. Optional
    • silenced Boolean. If true, the returned list includes silenced alerts. The default is true. Optional
    • inhibited Boolean. If true, the returned list includes inhibited alerts. The default is true. Optional
    • unprocessed Boolean. If true, the returned list includes unprocessed alerts. The default is true. Optional
    • filter An array of strings. A list of matchers to filter alerts by. Optional
    • receiver String. A regular expression matching receivers to filter alerts by. Optional
    • groupId String. The group id to filter alerts by. Optional
  • Sample response
{
  "alerts": [
    {
      "annotations": {
        "summary": "this is a test alert used for demo purposes"
      },
      "endsAt": "2021-10-21T22:07:31.501Z",
      "fingerprint": "375eab7b59892505",
      "receivers": [
        {
          "name": "sns-0"
        }
      ],
      "startsAt": "2021-10-21T22:02:31.501Z",
      "status": {
        "inhibitedBy": [],
        "silencedBy": [],
        "state": "active"
      },
      "updatedAt": "2021-10-21T22:02:31.501Z",
      "labels": {
        "alertname": "test-alert"
      }
    }
  ],
  "nextToken": "123"
}

other consideration

Add UUID for each route

For current data structure, one route can not be unique identified by receiver name.
However in order to search the alerts by alert group we need a fingerprint to identify the referenced alert group. The finger print to unique identify the alerting group should be group labels + route info.
We proposed to generate a unique identifier to each route as it is created

Add group information for each alert in the response of getAlerts API

It will be a better user experience if we can link the alerts back to the alert groups.
We proposed to add the groups info for each alert to the response of getAlerts API

@alvinlin123
Copy link
Contributor

I would also love a spec for paginated version get silences.

@Petrichia
Copy link

Hi, I was wondering if there's an update on when pagination will be implemented for the getAlerts endpoint? Thanks!

@qinxx108
Copy link
Contributor Author

qinxx108 commented Apr 9, 2024

Hi, I was wondering if there's an update on when pagination will be implemented for the getAlerts endpoint? Thanks!

This is implemented here: #3521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants