grafana/pkg
George Robinson 19ebb079ba
Alerting: Add limits and filters to Prometheus Rules API (#66627)
This commit adds support for limits and filters to the Prometheus Rules
API.

Limits:

It adds a number of limits to the Grafana flavour of the Prometheus Rules
API:

- `limit` limits the maximum number of Rule Groups returned
- `limit_rules` limits the maximum number of rules per Rule Group
- `limit_alerts` limits the maximum number of alerts per rule

It sorts Rule Groups and rules within Rule Groups such that data in the
response is stable across requests. It also returns summaries (totals)
for all Rule Groups, individual Rule Groups and rules.

Filters:

Alerts can be filtered by state with the `state` query string. An example
of an HTTP request asking for just firing alerts might be
`/api/prometheus/grafana/api/v1/rules?state=alerting`.

A request can filter by two or more states by adding additional `state`
query strings to the URL. For example `?state=alerting&state=normal`.

Like the alert list panel, the `firing`, `pending` and `normal` state are
first compared against the state of each alert rule. All other states are
ignored. If the alert rule matches then its alert instances are filtered
against states once more.

Alerts can also be filtered by labels using the `matcher` query string.
Like `state`, multiple matchers can be provided by adding additional
`matcher` query strings to the URL.

The match expression should be parsed using existing regular expression
and sent to the API as URL-encoded JSON in the format:

{
    "name": "test",
    "value": "value1",
    "isRegex": false,
    "isEqual": true
}

The `isRegex` and `isEqual` options work as follows:

| IsEqual | IsRegex  | Operator |
| ------- | -------- | -------- |
| true    | false    |    =     |
| true    | true     |    =~    |
| false   | true     |    !~    |
| false   | false    |    !=    |
2023-04-17 17:45:06 +01:00
..
api Chore: Remove deprecated dashboardId from panel query runner (#64786) 2023-04-14 16:50:10 -07:00
build CI: Split /bin/build artifacts * subcommand (#66005) 2023-04-12 11:47:40 +03:00
bus Chore: Fix goimports grouping in other backend platform packages (#62422) 2023-01-30 08:26:42 +00:00
cmd Chore: Unite wire graphs for cli and server (#61143) 2023-03-17 16:36:39 +01:00
codegen Docs: Add Default column to generated schema docs (#64550) 2023-03-22 18:42:28 +01:00
components ApiKeyGenPrefix: rename package (#65623) 2023-03-30 17:04:10 +02:00
cuectx extract kindsys to external library (#64562) 2023-03-15 12:04:28 -04:00
events Alerting: Update rules version when folder title is updated (#53013) 2022-08-01 19:28:38 -04:00
expr SSE: Dataplane Compliance (#65927) 2023-04-12 12:24:34 -04:00
extensions Deps: Replace go-jose v2 with go-jose v3 (#64228) 2023-03-06 15:12:51 +01:00
ifaces/gcsifaces Chore: Upgrade Go to 1.19.1 (#54902) 2022-09-12 12:03:49 +02:00
infra Analytics: Add total dashboard byte size to reporting (#66425) 2023-04-13 21:37:03 +03:00
kinds Chore: Update times in dashboards (#65179) 2023-03-22 15:57:44 +01:00
kindsysreport Chore: Fix times in schemas (#64906) 2023-03-21 10:42:19 +01:00
login GenericOAuth: Set sub as auth id (#65902) 2023-04-05 17:24:06 +02:00
middleware Caching: Refactor enterprise query caching middleware to a wire service (#65616) 2023-04-12 12:30:33 -04:00
mocks/mock_gcsifaces Chore: Fix goimports grouping in other backend platform packages (#62422) 2023-01-30 08:26:42 +00:00
models Auth: Add feature flag to move token rotation to client (#65060) 2023-03-23 14:39:04 +01:00
modules Chore: Add initial support for deployment modes (#63992) 2023-03-06 14:06:52 -05:00
plugins Plugins: Fix module.js file not being closed when loading plugins (#66288) 2023-04-13 10:48:15 +02:00
registry extract kindsys to external library (#64562) 2023-03-15 12:04:28 -04:00
server Auth: Add SigningKeys Service (#64343) 2023-04-17 11:42:37 +02:00
services Alerting: Add limits and filters to Prometheus Rules API (#66627) 2023-04-17 17:45:06 +01:00
setting SQL Datasources: Update Max Connection and Max Idle Connection Defaults to 100 and add auto mode (#65834) 2023-04-17 11:44:05 +03:00
tests Alerting: Add limits and filters to Prometheus Rules API (#66627) 2023-04-17 17:45:06 +01:00
tsdb SQL Datasources: Update Max Connection and Max Idle Connection Defaults to 100 and add auto mode (#65834) 2023-04-17 11:44:05 +03:00
util Prometheus: Enable converter tests (#66378) 2023-04-13 09:10:04 +02:00
web Alerting: Add limits and filters to Prometheus Rules API (#66627) 2023-04-17 17:45:06 +01:00
README.md Chore: Move all backend contribution documents to a single directory (#61140) 2023-01-11 11:16:52 +01:00
ruleguard.rules.go

This directory contains the code for the Grafana backend.

The contributor documentation for Grafana's backend is in /contribute/backend/README.md.