grafana/pkg/services
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
..
accesscontrol RBAC: Feature to override default assignments (#66561) 2023-04-14 17:17:59 +02:00
alerting Search v1: Add support for inherited folder permissions if nested folders are enabled (#63275) 2023-04-06 11:16:15 +03:00
annotations Search v1: Add support for inherited folder permissions if nested folders are enabled (#63275) 2023-04-06 11:16:15 +03:00
anonymous AnonymousService: Test tagging service (#64708) 2023-03-14 10:47:34 +01:00
apikey Chore: Remove result field from API keys commands and queries (#65055) 2023-03-21 13:26:33 +01:00
auth Auth: Add feature flag to move token rotation to client (#65060) 2023-03-23 14:39:04 +01:00
authn AuthN: Tune logs in client (#65714) 2023-03-31 16:43:24 +02:00
caching Caching: Refactor enterprise query caching middleware to a wire service (#65616) 2023-04-12 12:30:33 -04:00
cleanup Chore: Fix goimports grouping in pkg/services (#62420) 2023-01-30 08:21:27 +00:00
contexthandler Auth: Remove the session cookie only if it's invalid or revoked (#65984) 2023-04-13 09:23:39 +02:00
correlations Correlations: Add usage stats about correlations (#66021) 2023-04-11 08:53:34 +02:00
dashboardimport Dashboards: Avoid adding unused revision property (#64362) 2023-03-08 08:26:38 -08:00
dashboards NestedFolders: Add folder service registry with dashboard service implementation (#65033) 2023-04-14 11:17:23 +02:00
dashboardsnapshots Snapshots: Add snapshot enable config (#61587) 2023-01-26 10:28:11 -03:00
dashboardversion API: Fix "Updated by" Column in dashboard versions table (#65351) 2023-03-30 17:31:53 +03:00
datasourceproxy Caching: Refactor enterprise query caching middleware to a wire service (#65616) 2023-04-12 12:30:33 -04:00
datasources Chore: Remove result field from remaining datasources queries (#65054) 2023-03-20 19:18:21 +01:00
encryption Chore: Fix goimports grouping in pkg/services (#62420) 2023-01-30 08:21:27 +00:00
featuremgmt NestedFolders: Don't require dev mode for feature toggle (#66501) 2023-04-17 15:54:32 +03:00
folder NestedFolders: Add folder service registry with dashboard service implementation (#65033) 2023-04-14 11:17:23 +02:00
grpcserver ApiKeyGenPrefix: rename package (#65623) 2023-03-30 17:04:10 +02:00
guardian Cfg: Move ViewersCanEdit into cfg (#64876) 2023-03-16 10:54:01 +01:00
hooks chore: move user_auth models to (mostly) login service (#62269) 2023-01-27 13:36:54 -05:00
kmsproviders Encryption: Refactor secrets.Service initialization (#51091) 2022-07-07 09:48:25 +02:00
ldap LDAP: Always synchronize Server Admin role through role sync if role sync is enabled (#58820) 2023-03-31 15:39:23 +01:00
libraryelements NestedFolders: Add folder service registry with dashboard service implementation (#65033) 2023-04-14 11:17:23 +02:00
librarypanels NestedFolders: Add folder service registry with dashboard service implementation (#65033) 2023-04-14 11:17:23 +02:00
licensing Chore: Clean up old navigation (#66287) 2023-04-14 09:43:11 +01:00
live Build: Fix Redis/Memcached integration tests (#64298) 2023-04-05 11:55:55 +03:00
login Chore: Remove result fields from login (#65136) 2023-03-28 20:32:21 +02:00
loginattempt Chore: Remove result field from loginattempt (#65117) 2023-03-22 21:25:29 +01:00
navtree Chore: Clean up NavModel interface (#66548) 2023-04-17 16:01:32 +01:00
ngalert Alerting: Add limits and filters to Prometheus Rules API (#66627) 2023-04-17 17:45:06 +01:00
notifications Chore: Remove result field from notifications (#65170) 2023-03-28 13:44:15 +02:00
oauthtoken Chore: Remove result fields from login (#65136) 2023-03-28 20:32:21 +02:00
org Auth: Fix orgrole picker disabled if isSynced user (#64033) 2023-03-22 17:41:59 +00:00
playlist Chore: Update oapi-codegen library (#62962) 2023-02-21 12:34:24 +01:00
plugindashboards Plugins: Add file store abstraction for handling plugin files (#65432) 2023-03-29 12:55:55 +02:00
pluginsintegration Caching: Refactor enterprise query caching middleware to a wire service (#65616) 2023-04-12 12:30:33 -04:00
preference SQLStore: Fix wrong usage of xorm's insert functions in tests (#63850) 2023-03-02 13:01:36 +02:00
provisioning Alerting: Remove dependency on alerting package in definitions (#65390) 2023-03-29 13:34:59 -04:00
publicdashboards PublicDashboards: Code formatted (#66462) 2023-04-13 16:29:09 +03:00
query Caching: Refactor enterprise query caching middleware to a wire service (#65616) 2023-04-12 12:30:33 -04:00
queryhistory Chore: Use time mocks in queryhistory to speed up tests (#66644) 2023-04-17 12:02:47 +02:00
quota Chore: Remove xorcare/pointer dependency (#63900) 2023-03-06 05:23:15 -05:00
rendering Rendering: Experimental support to use JWTs as auth method (#60841) 2023-04-03 18:53:38 +02:00
screenshot Alerting: Fix a bug taking screenshots with Dashboard UID (#63220) 2023-02-09 15:23:01 -05:00
search Chore: Remove result field from search (#65583) 2023-03-30 11:28:12 +02:00
searchusers Chore: Move ReqContext to contexthandler service (#62102) 2023-01-27 08:50:36 +01:00
searchV2 Chore: remove querylibrary feature toggle (#65021) 2023-03-20 20:00:14 +04:00
secrets Chore: Remove result field from remaining datasources queries (#65054) 2023-03-20 19:18:21 +01:00
serviceaccounts ApiKeyGenPrefix: rename package (#65623) 2023-03-30 17:04:10 +02:00
shorturls Chore: Replace short UID generation with more standard UUIDs (#62731) 2023-02-06 20:44:37 -05:00
signingkeys Auth: Add SigningKeys Service (#64343) 2023-04-17 11:42:37 +02:00
sqlstore Previews: remove dashboard previews backend (#66176) 2023-04-13 21:42:24 +04:00
star Search: Improvements for starred dashboard search (#64758) 2023-03-16 09:20:07 +00:00
stats Analytics: Add total dashboard byte size to reporting (#66425) 2023-04-13 21:37:03 +03:00
store ApiKeyGenPrefix: rename package (#65623) 2023-03-30 17:04:10 +02:00
supportbundles Support bundles: fix user collector permissions and format collector output (#64531) 2023-03-09 11:43:18 -05:00
tag Chore: Fix goimports grouping in pkg/services (#62420) 2023-01-30 08:21:27 +00:00
team Chore: Remove CreateUserForTests() (#64125) 2023-03-03 11:01:23 -05:00
teamguardian Chore: Fix goimports grouping (#62426) 2023-01-30 09:34:18 +01:00
temp_user fix: create temp user no longer sets ID to 0 for all users (#64149) 2023-03-03 10:50:54 -05:00
updatechecker Plugins: Improve instrumentation by adding metrics and tracing (#61035) 2023-03-28 11:01:06 +02:00
user Support bundles: fix user collector permissions and format collector output (#64531) 2023-03-09 11:43:18 -05:00
validations chore: move validations model into the validations service (#61953) 2023-01-23 15:10:14 -05:00