View a markdown version of this page

ListRules - Amazon Managed Service for Prometheus

ListRules

The ListRules operation retrieves information about the rules configured in the workspace.

A single response contains at most 100,000 rules. Because rule groups are never split across pages, truncation always lands on a rule group boundary. A response can therefore contain fewer than 100,000 rules if including the next rule group exceeds the cap. When truncation occurs, the response includes the groupNextToken property. To retrieve the next page, pass that value as the group_next_token query parameter, which you must send together with group_limit.

Valid HTTP verbs:

GET

Valid URIs:

/workspaces/workspaceId/api/v1/rules

URL query parameters:

type=<alert|record> Return only the alerting rules (for example, type=alert) or the recording rules (for example, type=record). When the parameter is absent or empty, no filtering is done. Optional

rule_name[]=<string> Filters rules using the provided names. When multiple filters are provided, the rule name must satisfy at least one of the given filters. Optional

rule_group[]=<string> Filters rule groups using the provided names. When multiple filters are provided, the rule group name must satisfy at least one of the given filters. Optional

file[]=<string> Filters rule group namespaces using the provided names. When multiple filters are provided, the rule group namespace name must satisfy at least one of the given filters. Optional

exclude_alerts=<true|false> Filters rules without any active alerts when set to true. Optional

match[]=<series_selector> Only return rules that have configured labels that satisfy the label selectors. If the parameter is repeated, rules that match any of the sets of label selectors are returned. Note that matching is on the labels in the definition of each rule, not on the values after template expansion (for alerting rules). Optional

group_limit=<number> Maximum number of rule groups returned in a single response. In subsequent requests to paginate, use the groupNextToken property from this response to set the group_next_token parameter. Optional

group_next_token=<string> The pagination token returned by a previous request when you set the group_limit property or when the response reaches the 100,000-rule cap. Use this token to iteratively paginate over the remaining rule groups. When you use this parameter, you must also send the group_limit parameter. Optional

Sample request

GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/rules HTTP/1.1 Content-Length: 0, Authorization: AUTHPARAMS X-Amz-Date: 20201201T193725Z User-Agent: Grafana/8.1.0

Sample response

HTTP/1.1 200 OK x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535 Content-Length: 423 Connection: keep-alive Date: Tue, 01 Dec 2020 19:37:25 GMT Content-Type: application/json Server: amazon vary: Origin { "status": "success", "data": { "groups": [ { "name": "test-1.rules", "file": "test-rules", "rules": [ { "name": "record:1", "query": "sum(rate(node_cpu_seconds_total[10m:1m]))", "labels": {}, "health": "ok", "lastError": "", "type": "recording", "lastEvaluation": "2021-10-21T21:22:34.429565909Z", "evaluationTime": 0.001005399 } ], "interval": 60, "lastEvaluation": "2021-10-21T21:22:34.429563992Z", "evaluationTime": 0.001010504 } ] }, "errorType": "", "error": "" }