From 4ef5c33af90967f3801e8bdc3b7cc32631db884e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kre=C5=A1imir=20Ba=C4=8Di=C4=87?=
<96543666+kureshimiru@users.noreply.github.com>
Date: Tue, 25 Jul 2023 18:27:44 +0200
Subject: [PATCH 01/64] Heatmap: Add datalink support (#71016)
---
.../plugins/panel/heatmap/HeatmapHoverView.tsx | 16 ++++++++++++++--
.../app/plugins/panel/heatmap/HeatmapPanel.tsx | 12 ++++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx b/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx
index 40fe2fe4897..5794e8bd88d 100644
--- a/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx
+++ b/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx
@@ -8,6 +8,9 @@ import {
getFieldDisplayName,
LinkModel,
TimeRange,
+ getLinksSupplier,
+ InterpolateFunction,
+ ScopedVars,
} from '@grafana/data';
import { HeatmapCellLayout } from '@grafana/schema';
import { LinkButton, VerticalGroup } from '@grafana/ui';
@@ -23,6 +26,8 @@ type Props = {
hover: HeatmapHoverEvent;
showHistogram?: boolean;
timeRange: TimeRange;
+ replaceVars: InterpolateFunction;
+ scopedVars: ScopedVars[];
};
export const HeatmapHoverView = (props: Props) => {
@@ -32,7 +37,7 @@ export const HeatmapHoverView = (props: Props) => {
return ;
};
-const HeatmapHoverCell = ({ data, hover, showHistogram }: Props) => {
+const HeatmapHoverCell = ({ data, hover, showHistogram, scopedVars, replaceVars }: Props) => {
const index = hover.dataIdx;
const xField = data.heatmap?.fields[0];
const yField = data.heatmap?.fields[1];
@@ -119,7 +124,14 @@ const HeatmapHoverCell = ({ data, hover, showHistogram }: Props) => {
const linkLookup = new Set();
for (const field of visibleFields ?? []) {
- // TODO: Currently always undefined? (getLinks)
+ const hasLinks = field.config.links && field.config.links.length > 0;
+ if (hasLinks && data.heatmap) {
+ let appropriateScopedVars = scopedVars.filter(
+ (sv) => sv && sv.__dataContext && sv.__dataContext.value.field.name === nonNumericOrdinalDisplay
+ )[0];
+ field.getLinks = getLinksSupplier(data.heatmap, field, appropriateScopedVars ?? {}, replaceVars);
+ }
+
if (field.getLinks) {
const v = field.values[index];
const disp = field.display ? field.display(v) : { text: `${v}`, numeric: +v };
diff --git a/public/app/plugins/panel/heatmap/HeatmapPanel.tsx b/public/app/plugins/panel/heatmap/HeatmapPanel.tsx
index a84729f0d83..b21560fdd4a 100644
--- a/public/app/plugins/panel/heatmap/HeatmapPanel.tsx
+++ b/public/app/plugins/panel/heatmap/HeatmapPanel.tsx
@@ -43,6 +43,16 @@ export const HeatmapPanel = ({
const styles = useStyles2(getStyles);
const { sync } = usePanelContext();
+ // necessary for enabling datalinks in hover view
+ let scopedVarsFromRawData = [];
+ for (const series of data.series) {
+ for (const field of series.fields) {
+ if (field.state?.scopedVars) {
+ scopedVarsFromRawData.push(field.state?.scopedVars);
+ }
+ }
+ }
+
// ugh
let timeRangeRef = useRef(timeRange);
timeRangeRef.current = timeRange;
@@ -210,6 +220,8 @@ export const HeatmapPanel = ({
data={info}
hover={hover}
showHistogram={options.tooltip.yHistogram}
+ replaceVars={replaceVariables}
+ scopedVars={scopedVarsFromRawData}
/>
)}
From 9ff193f6928956bd8f1d0586792e3760fceffe58 Mon Sep 17 00:00:00 2001
From: Ieva
Date: Tue, 25 Jul 2023 17:46:46 +0100
Subject: [PATCH 02/64] Docs: update GitLab OAuth2 documentation (#71834)
* gitlab doc update and update the default scopes
* small fixes
* fix a reference
* update another reference
* PR feedback: fix numbering of bulletpoints, reorder config options
* linting
---
conf/defaults.ini | 4 +-
conf/sample.ini | 2 +-
.../introduction/grafana-enterprise.md | 2 +-
.../configure-authentication/github/index.md | 2 +-
.../configure-authentication/gitlab/index.md | 320 +++++++-----------
.../configure-security/configure-team-sync.md | 2 +-
6 files changed, 128 insertions(+), 204 deletions(-)
diff --git a/conf/defaults.ini b/conf/defaults.ini
index 76542724d10..b3cc15b3586 100644
--- a/conf/defaults.ini
+++ b/conf/defaults.ini
@@ -612,7 +612,7 @@ allow_sign_up = true
auto_login = false
client_id = some_id
client_secret =
-scopes = api
+scopes = openid email profile
auth_url = https://gitlab.com/oauth/authorize
token_url = https://gitlab.com/oauth/token
api_url = https://gitlab.com/api/v4
@@ -1278,7 +1278,7 @@ news_feed_enabled = true
#################################### Query #############################
[query]
# Set the number of data source queries that can be executed concurrently in mixed queries. Default is the number of CPUs.
-concurrent_query_limit =
+concurrent_query_limit =
#################################### Query History #############################
[query_history]
diff --git a/conf/sample.ini b/conf/sample.ini
index 960f917dc71..265cb8a9b9a 100644
--- a/conf/sample.ini
+++ b/conf/sample.ini
@@ -595,7 +595,7 @@
;auto_login = false
;client_id = some_id
;client_secret = some_secret
-;scopes = api
+;scopes = openid email profile
;auth_url = https://gitlab.com/oauth/authorize
;token_url = https://gitlab.com/oauth/token
;api_url = https://gitlab.com/api/v4
diff --git a/docs/sources/introduction/grafana-enterprise.md b/docs/sources/introduction/grafana-enterprise.md
index 4c60908b02d..e7ea3c27e3b 100644
--- a/docs/sources/introduction/grafana-enterprise.md
+++ b/docs/sources/introduction/grafana-enterprise.md
@@ -34,7 +34,7 @@ Supported auth providers:
- [Auth Proxy]({{< relref "../setup-grafana/configure-security/configure-authentication/auth-proxy#team-sync-enterprise-only" >}})
- [Azure AD OAuth]({{< relref "../setup-grafana/configure-security/configure-authentication/azuread#team-sync-enterprise-only" >}})
- [GitHub OAuth]({{< relref "../setup-grafana/configure-security/configure-authentication/github#configure-team-synchronization" >}})
-- [GitLab OAuth]({{< relref "../setup-grafana/configure-security/configure-authentication/gitlab#team-sync-enterprise-only" >}})
+- [GitLab OAuth]({{< relref "../setup-grafana/configure-security/configure-authentication/gitlab#configure-team-synchronization" >}})
- [LDAP]({{< relref "../setup-grafana/configure-security/configure-authentication/enhanced-ldap#ldap-group-synchronization-for-teams" >}})
- [Okta]({{< relref "../setup-grafana/configure-security/configure-authentication/okta#configure-team-synchronization-enterprise-only" >}})
- [SAML]({{< relref "../setup-grafana/configure-security/configure-authentication/saml#configure-team-sync" >}})
diff --git a/docs/sources/setup-grafana/configure-security/configure-authentication/github/index.md b/docs/sources/setup-grafana/configure-security/configure-authentication/github/index.md
index 940d545a311..2ad0dcd173e 100644
--- a/docs/sources/setup-grafana/configure-security/configure-authentication/github/index.md
+++ b/docs/sources/setup-grafana/configure-security/configure-authentication/github/index.md
@@ -146,7 +146,7 @@ For example, `https://github.com/orgs/grafana/teams/developers` or `@grafana/dev
To learn more about Team Sync, refer to [Configure team sync]({{< relref "../../configure-team-sync" >}}).
-## Examples of GitHub configuration in Grafana
+## Example of GitHub configuration in Grafana
This section includes an example of GitHub configuration in the Grafana configuration file.
diff --git a/docs/sources/setup-grafana/configure-security/configure-authentication/gitlab/index.md b/docs/sources/setup-grafana/configure-security/configure-authentication/gitlab/index.md
index 2eddacc5c22..9759567471f 100644
--- a/docs/sources/setup-grafana/configure-security/configure-authentication/gitlab/index.md
+++ b/docs/sources/setup-grafana/configure-security/configure-authentication/gitlab/index.md
@@ -19,85 +19,83 @@ weight: 1000
# Configure GitLab OAuth2 authentication
-To enable GitLab OAuth2 you must register the application in GitLab. GitLab will generate a client ID and secret key for you to use.
+{{< docs/shared "auth/intro.md" >}}
-## Create GitLab OAuth keys
+This topic describes how to configure GitLab OAuth2 authentication.
-You need to [create a GitLab OAuth application](https://docs.gitlab.com/ce/integration/oauth_provider.html).
-Choose a descriptive _Name_, and use the following _Redirect URI_:
+## Before you begin
-```
-https://grafana.example.com/login/gitlab
-```
+To follow this guide:
-where `https://grafana.example.com` is the URL you use to connect to Grafana.
-Adjust it as needed if you don't use HTTPS or if you use a different port; for
-instance, if you access Grafana at `http://203.0.113.31:3000`, you should use
+- Ensure that you have access to the [Grafana configuration file]({{< relref "../../../configure-grafana#configuration-file-location" >}}).
+- Ensure you know how to create a GitLab OAuth application. Consult GitLab's documentation on [creating a GitLab OAuth application](https://docs.gitlab.com/ee/integration/oauth_provider.html) for more information.
-```
-http://203.0.113.31:3000/login/gitlab
-```
+## Steps
-Finally, select `openid`, `email` and `profile` as the scopes and submit the form.
+To configure GitLab authentication with Grafana, follow these steps:
-You'll get an _Application Id_ and a _Secret_ in return; we'll call them
-`GITLAB_APPLICATION_ID` and `GITLAB_SECRET` respectively for the rest of this
-section.
+1. Create an OAuth application in GitLab.
-## Enable GitLab in Grafana
+ 1. Set the redirect URI to `http://:/login/gitlab`.
-In this example, we'll assume you use the public `gitlab.com` instance, but you
-can use your own instance of GitLab instead by replacing `auth_url`, `token_url` with the URL of your instance.
+ Ensure that the Redirect URI is the complete HTTP address that you use to access Grafana via your browser, but with the appended path of `/login/gitlab`.
-You can find these URLs in the `well known` configuration file of your GitLab instance, for example `https://gitlab.com/.well-known/openid-configuration`.
+ For the Redirect URI to be correct, it might be necessary to set the `root_url` option in the `[server]`section of the Grafana configuration file. For example, if you are serving Grafana behind a proxy.
-Add the following to your Grafana configuration file to enable GitLab
-authentication:
+ 1. Set the OAuth2 scopes to `openid`, `email` and `profile`.
-```bash
-[auth.gitlab]
-enabled = true
-allow_sign_up = true
-auto_login = false
-client_id = GITLAB_APPLICATION_ID
-client_secret = GITLAB_SECRET
-scopes = openid email profile
-auth_url = https://gitlab.com/oauth/authorize
-token_url = https://gitlab.com/oauth/token
-allowed_groups =
-role_attribute_path =
-role_attribute_strict = false
-allow_assign_grafana_admin = false
-tls_skip_verify_insecure = false
-tls_client_cert =
-tls_client_key =
-tls_client_ca =
-use_pkce = true
-```
+1. Refer to the following table to update field values located in the `[auth.gitlab]` section of the Grafana configuration file:
-You may have to set the `root_url` option of `[server]` for the callback URL to be
-correct. For example in case you are serving Grafana behind a proxy.
+ | Field | Description |
+ | ---------------------------- | -------------------------------------------------------------------------------------------- |
+ | `client_id`, `client_secret` | These values must match the client ID and client secret from your GitLab OAuth2 application. |
+ | `enabled` | Enables GitLab authentication. Set this value to `true`. |
-Restart the Grafana backend for your changes to take effect.
+ Review the list of other GitLab [configuration options]({{< relref "#configuration-options" >}}) and complete them, as necessary.
-With `allow_sign_up` set to `false`, only existing users will be able to login
-using their GitLab account, but with `allow_sign_up` set to `true`, _any_ user
-who can authenticate on GitLab will be able to login on your Grafana instance;
-if you use the public `gitlab.com`, it means anyone in the world would be able
-to login on your Grafana instance.
+1. Optional: [Configure a refresh token]({{< relref "#configure-a-refresh-token" >}}):
-You can limit access to only members of a given group or list of
-groups by setting the `allowed_groups` option.
+ a. Enable `accessTokenExpirationCheck` feature toggle.
-You can also specify the SSL/TLS configuration used by the client.
+ b. Set `use_refresh_token` to `true` in `[auth.gitlab]` section in Grafana configuration file.
-- Set `tls_client_cert` to the path of the certificate.
-- Set `tls_client_key` to the path containing the key.
-- Set `tls_client_ca` to the path containing a trusted certificate authority list.
+1. [Configure role mapping]({{< relref "#configure-role-mapping" >}}).
+1. Optional: [Configure team synchronization]({{< relref "#configure-team-synchronization" >}}).
+1. Restart Grafana.
-`tls_skip_verify_insecure` controls whether a client verifies the server's certificate chain and host name. If it is true, then SSL/TLS accepts any certificate presented by the server and any host name in that certificate. _You should only use this for testing_, because this mode leaves SSL/TLS susceptible to man-in-the-middle attacks.
+ You should now see a GitLab login button on the login page and be able to log in or sign up with your GitLab accounts.
-### Configure refresh token
+## Configuration options
+
+The table below describes all GitLab OAuth configuration options. Like any other Grafana configuration, you can apply these options as environment variables.
+
+| Setting | Required | Description | Default |
+| ---------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
+| `enabled` | Yes | Whether GitLab OAuth authentication is allowed. | `false` |
+| `client_id` | Yes | Client ID provided by your GitLab OAuth app. | |
+| `client_secret` | Yes | Client secret provided by your GitLab OAuth app. | |
+| `auth_url` | Yes | Authorization endpoint of your GitLab OAuth provider. If you use your own instance of GitLab instead of gitlab.com, adjust `auth_url` by replacing the `gitlab.com` hostname with your own. | `https://gitlab.com/oauth/authorize` |
+| `token_url` | Yes | Endpoint used to obtain GitLab OAuth access token. If you use your own instance of GitLab instead of gitlab.com, adjust `token_url` by replacing the `gitlab.com` hostname with your own. | `https://gitlab.com/oauth/token` |
+| `api_url` | No | Grafana uses `/user` endpoint to obtain GitLab user information compatible with [OpenID UserInfo](https://connect2id.com/products/server/docs/api/userinfo). | `https://gitlab.com/api/v4` |
+| `name` | No | Name used to refer to the GitLab authentication in the Grafana user interface. | `GitLab` |
+| `icon` | No | Icon used for GitLab authentication in the Grafana user interface. | `gitlab` |
+| `scopes` | No | List of comma- or space-separated GitLab OAuth scopes. | `openid email profile` |
+| `allow_sign_up` | No | Whether to allow new Grafana user creation through GitLab login. If set to `false`, then only existing Grafana users can log in with GitLab OAuth. | `true` |
+| `auto_login` | No | Set to `true` to enable users to bypass the login screen and automatically log in. This setting is ignored if you configure multiple auth providers to use auto-login. | `false` |
+| `role_attribute_path` | No | [JMESPath](http://jmespath.org/examples.html) expression to use for Grafana role lookup. Grafana will first evaluate the expression using the GitLab OAuth token. If no role is found, Grafana creates a JSON data with `groups` key that maps to groups obtained from GitLab's `/oauth/userinfo` endpoint, and evaluates the expression using this data. Finally, if a valid role is still not found, the expression is evaluated against the user information retrieved from `api_url/users` endpoint and groups retrieved from `api_url/groups` endpoint. The result of the evaluation should be a valid Grafana role (`Viewer`, `Editor`, `Admin` or `GrafanaAdmin`). For more information on user role mapping, refer to [Configure role mapping]({{< relref "#configure-role-mapping" >}}). | |
+| `role_attribute_strict` | No | Set to `true` to deny user login if the Grafana role cannot be extracted using `role_attribute_path`. For more information on user role mapping, refer to [Configure role mapping]({{< relref "#configure-role-mapping" >}}). | `false` |
+| `allow_assign_grafana_admin` | No | Set to `true` to enable automatic sync of the Grafana server administrator role. If this option is set to `true` and the result of evaluating `role_attribute_path` for a user is `GrafanaAdmin`, Grafana grants the user the server administrator privileges and organization administrator role. If this option is set to `false` and the result of evaluating `role_attribute_path` for a user is `GrafanaAdmin`, Grafana grants the user only organization administrator role. For more information on user role mapping, refer to [Configure role mapping]({{< relref "#configure-role-mapping" >}}). | `false` |
+| `skip_org_role_sync` | No | Set to `true` to stop automatically syncing user roles. | `false` |
+| `allowed_domains` | No | List of comma- or space-separated domains. User must belong to at least one domain to log in. | |
+| `allowed_groups` | No | List of comma- or space-separated groups. The user should be a member of at least one group to log in. If you configure `allowed_groups`, you must also configure `groups_attribute_path`. | |
+| `tls_skip_verify_insecure` | No | If set to `true`, the client accepts any certificate presented by the server and any host name in that certificate. _You should only use this for testing_, because this mode leaves SSL/TLS susceptible to man-in-the-middle attacks. | `false` |
+| `tls_client_cert` | No | The path to the certificate. | |
+| `tls_client_key` | No | The path to the key. | |
+| `tls_client_ca` | No | The path to the trusted certificate authority list. | |
+| `use_pkce` | No | Set to `true` to use [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636). Grafana uses the SHA256 based `S256` challenge method and a 128 bytes (base64url encoded) code verifier. | `true` |
+| `use_refresh_token` | No | Set to `true` to use refresh token and check access token expiration. The `accessTokenExpirationCheck` feature toggle should also be enabled to use refresh token. | `true` |
+
+### Configure a refresh token
> Available in Grafana v9.3 and later versions.
@@ -113,169 +111,95 @@ Refresh token fetching and access token expiration check is enabled by default f
> **Note:** The `accessTokenExpirationCheck` feature toggle will be removed in Grafana v10.2.0 and the `use_refresh_token` configuration value will be used instead for configuring refresh token fetching and access token expiration check.
-### allowed_groups
+### Configure allowed groups
To limit access to authenticated users that are members of one or more [GitLab
groups](https://docs.gitlab.com/ce/user/group/index.html), set `allowed_groups`
-to a comma- or space-separated list of groups. For instance, if you want to
-only give access to members of the `example` group, set
+to a comma- or space-separated list of groups.
+
+GitLab's groups are referenced by the group name. For example, `developers`. To reference a subgroup `frontend`, use `developers/frontend`.
+Note that in GitLab, the group or subgroup name does not always match its display name, especially if the display name contains spaces or special characters.
+Make sure you always use the group or subgroup name as it appears in the URL of the group or subgroup.
+
+## Configure role mapping
+
+Unless `skip_org_role_sync` option is enabled, the user's role will be set to the role retrieved from GitLab upon user login.
+
+The user's role is retrieved using a [JMESPath](http://jmespath.org/examples.html) expression from the `role_attribute_path` configuration option.
+To map the server administrator role, use the `allow_assign_grafana_admin` configuration option.
+Refer to [configuration options]({{< relref "#configuration-options" >}}) for more information.
+
+If no valid role is found, the user is assigned the role specified by [the `auto_assign_org_role` option]({{< relref "../../../configure-grafana#auto_assign_org_role" >}}).
+You can disable this default role assignment by setting `role_attribute_strict = true`.
+This setting denies user access if no role or an invalid role is returned.
+
+To ease configuration of a proper JMESPath expression, go to [JMESPath](http://jmespath.org/) to test and evaluate expressions with custom payloads.
+
+### Role mapping examples
+
+This section includes examples of JMESPath expressions used for role mapping.
+
+#### Map roles using user information from OAuth token
+
+In this example, the user with email `admin@company.com` has been granted the `Admin` role.
+All other users are granted the `Viewer` role.
```ini
-allowed_groups = example
+role_attribute_path = email=='admin@company.com' && 'Admin' || 'Viewer'
```
-If you want to also give access to members of the subgroup `bar`, which is in
-the group `foo`, set
-
-```ini
-allowed_groups = example, foo/bar
-```
-
-To put values containing spaces in the list, use the following JSON syntax:
-
-```ini
-allowed_groups = ["Admins", "Software Engineers"]
-```
-
-Note that in GitLab, the group or subgroup name doesn't always match its
-display name, especially if the display name contains spaces or special
-characters. Make sure you always use the group or subgroup name as it appears
-in the URL of the group or subgroup.
-
-Here's a complete example with `allow_sign_up` enabled, with access limited to
-the `example` and `foo/bar` groups. The example also promotes all GitLab Admins to Grafana organization admins:
-
-```ini
-[auth.gitlab]
-enabled = true
-allow_sign_up = true
-auto_login = false
-client_id = GITLAB_APPLICATION_ID
-client_secret = GITLAB_SECRET
-scopes = openid email profile
-auth_url = https://gitlab.com/oauth/authorize
-token_url = https://gitlab.com/oauth/token
-allowed_groups = example, foo/bar
-role_attribute_path = is_admin && 'Admin' || 'Viewer'
-role_attribute_strict = true
-allow_assign_grafana_admin = false
-tls_skip_verify_insecure = false
-tls_client_cert =
-tls_client_key =
-tls_client_ca =
-use_pkce = true
-```
-
-### PKCE
-
-IETF's [RFC 7636](https://datatracker.ietf.org/doc/html/rfc7636)
-introduces "proof key for code exchange" (PKCE) which provides
-additional protection against some forms of authorization code
-interception attacks. PKCE will be required in [OAuth 2.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-03).
-
-> You can disable PKCE in Grafana by setting `use_pkce` to `false` in the`[auth.gitlab]` section.
-
-```
-use_pkce = true
-```
-
-Grafana always uses the SHA256 based `S256` challenge method and a 128 bytes (base64url encoded) code verifier.
-
-### Configure automatic login
-
-Set `auto_login` option to true to attempt login automatically, skipping the login screen.
-This setting is ignored if multiple auth providers are configured to use auto login.
-
-```
-auto_login = true
-```
-
-### Map roles
-
-You can use GitLab OAuth to map roles. During mapping, Grafana checks for the presence of a role using the [JMESPath](http://jmespath.org/examples.html) specified via the `role_attribute_path` configuration option.
-
-For the path lookup, Grafana uses JSON obtained from querying GitLab's API [`/api/v4/user`](https://docs.gitlab.com/ee/api/users.html#list-current-user-for-normal-users) endpoint and a `groups` key containing all of the user's teams. The result of evaluating the `role_attribute_path` JMESPath expression must be a valid Grafana role, for example, `Viewer`, `Editor` or `Admin`. For more information about roles and permissions in Grafana, refer to [Roles and permissions]({{< relref "../../../../administration/roles-and-permissions" >}}).
-
-{{% admonition type="warning" %}}
-Currently if no organization role mapping is found for a user, Grafana doesn't
-update the user's organization role. This is going to change in Grafana 10. To avoid overriding manually set roles,
-enable the `skip_org_role_sync` option.
-See [Configure Grafana]({{< relref "../../../configure-grafana#authgitlab" >}}) for more information.
-{{% /admonition %}}
-
-On first login, if the`role_attribute_path` property does not return a role, then the user is assigned the role
-specified by [the `auto_assign_org_role` option]({{< relref "../../../configure-grafana#auto_assign_org_role" >}}).
-You can disable this default role assignment by setting `role_attribute_strict = true`.
-It denies user access if no role or an invalid role is returned.
-
-{{% admonition type="warning" %}}
-With Grafana 10, **on every login**, if the`role_attribute_path` property does not return a role,
-then the user is assigned the role specified by
-[the `auto_assign_org_role` option]({{< relref "../../../configure-grafana#auto_assign_org_role" >}}).
-{{% /admonition %}}
-
-An example Query could look like the following:
-
-```ini
-role_attribute_path = is_admin && 'Admin' || 'Viewer'
-```
-
-This allows every GitLab Admin to be an Admin in Grafana.
-
#### Map roles using groups
-Groups can also be used to map roles. Group name (lowercased and unique) is used instead of display name for identifying groups
-
-For instance, if you have a group with display name 'Example-Group' you can use the following snippet to
-ensure those members inherit the role 'Editor'.
+In this example, the user from GitLab group 'example-group' have been granted the `Editor` role.
+All other users are granted the `Viewer` role.
```ini
role_attribute_path = contains(groups[*], 'example-group') && 'Editor' || 'Viewer'
```
-Note: If a match is found in other fields, groups will be ignored.
+#### Map server administrator role
-#### Map server administrator privileges
+In this example, the user with email `admin@company.com` has been granted the `Admin` organization role as well as the Grafana server admin role.
+All other users are granted the `Viewer` role.
-> Available in Grafana v9.2 and later versions.
-
-If the application role received by Grafana is `GrafanaAdmin`, Grafana grants the user server administrator privileges.
-This is useful if you want to grant server administrator privileges to a subset of users.
-Grafana also assigns the user the `Admin` role of the default organization.
-
-The setting `allow_assign_grafana_admin` under `[auth.gitlab]` must be set to `true` for this to work.
-If the setting is set to `false`, the user is assigned the role of `Admin` of the default organization, but not server administrator privileges.
-
-```ini
-allow_assign_grafana_admin = true
+```bash
+role_attribute_path = email=='admin@company.com' && 'GrafanaAdmin' || 'Viewer'
```
-Example:
+## Configure team synchronization
-```ini
-role_attribute_path = is_admin && 'GrafanaAdmin' || 'Viewer'
-```
+> **Note:** Available in [Grafana Enterprise]({{< relref "../../../../introduction/grafana-enterprise" >}}) and [Grafana Cloud](/docs/grafana-cloud/).
-### Team Sync (Enterprise only)
+By using Team Sync, you can map GitLab groups to teams within Grafana. This will automatically assign users to the appropriate teams.
+Teams for each user are synchronized when the user logs in.
-> Only available in Grafana Enterprise v6.4+
+GitLab groups are referenced by the group name. For example, `developers`. To reference a subgroup `frontend`, use `developers/frontend`.
+Note that in GitLab, the group or subgroup name does not always match its display name, especially if the display name contains spaces or special characters.
+Make sure you always use the group or subgroup name as it appears in the URL of the group or subgroup.
-With Team Sync you can map your GitLab groups to teams in Grafana so that your users will automatically be added to
-the correct teams.
+To learn more about Team Sync, refer to [Configure team sync]({{< relref "../../configure-team-sync" >}}).
-Your GitLab groups can be referenced in the same way as `allowed_groups`, like `example` or `foo/bar`.
+## Example of GitLab configuration in Grafana
-[Learn more about Team Sync]({{< relref "../../configure-team-sync" >}})
+This section includes an example of GitLab configuration in the Grafana configuration file.
-## Skip organization role sync
-
-To prevent the sync of organization roles from GitLab, set `skip_org_role_sync` to `true`. This is useful if you want to manage the organization roles for your users from within Grafana.
-This also impacts the `allow_assign_grafana_admin` setting by not syncing the Grafana admin role from GitLab.
-
-```ini
+```bash
[auth.gitlab]
-# ..
-# prevents the sync of org roles from Github
-skip_org_role_sync = true
-``
+enabled = true
+allow_sign_up = true
+auto_login = false
+client_id = YOUR_GITLAB_APPLICATION_ID
+client_secret = YOUR_GITLAB_APPLICATION_SECRET
+scopes = openid email profile
+auth_url = https://gitlab.com/oauth/authorize
+token_url = https://gitlab.com/oauth/token
+api_url = https://gitlab.com/api/v4
+role_attribute_path = contains(groups[*], 'example-group') && 'Editor' || 'Viewer'
+role_attribute_strict = false
+allow_assign_grafana_admin = false
+allowed_groups = ["admins", "software engineers", "developers/frontend"]
+allowed_domains = mycompany.com mycompany.org
+tls_skip_verify_insecure = false
+use_pkce = true
+use_refresh_token = true
```
diff --git a/docs/sources/setup-grafana/configure-security/configure-team-sync.md b/docs/sources/setup-grafana/configure-security/configure-team-sync.md
index 09267daa8a1..a557e48d34c 100644
--- a/docs/sources/setup-grafana/configure-security/configure-team-sync.md
+++ b/docs/sources/setup-grafana/configure-security/configure-team-sync.md
@@ -30,7 +30,7 @@ This mechanism allows Grafana to remove an existing synchronized user from a tea
- [Auth Proxy]({{< relref "./configure-authentication/auth-proxy#team-sync-enterprise-only" >}})
- [Azure AD]({{< relref "./configure-authentication/azuread#team-sync-enterprise-only" >}})
- [GitHub OAuth]({{< relref "./configure-authentication/github#configure-team-synchronization" >}})
-- [GitLab OAuth]({{< relref "./configure-authentication/gitlab#team-sync-enterprise-only" >}})
+- [GitLab OAuth]({{< relref "./configure-authentication/gitlab#configure-team-synchronization" >}})
- [LDAP]({{< relref "./configure-authentication/enhanced-ldap#ldap-group-synchronization-for-teams" >}})
- [Okta]({{< relref "./configure-authentication/okta#configure-team-synchronization-enterprise-only" >}})
- [SAML]({{< relref "./configure-authentication/saml#configure-team-sync" >}})
From 1755f8c7b764f65449df837effd5197206ab3672 Mon Sep 17 00:00:00 2001
From: Marcus Andersson
Date: Tue, 25 Jul 2023 20:18:49 +0200
Subject: [PATCH 03/64] PluginExtensions: Allow to specify unkown properties in
override but they will be ignored (#72273)
* fixed bug.
* Update public/app/features/plugins/extensions/getPluginExtensions.ts
Co-authored-by: Ben Sully
* Update public/app/features/plugins/extensions/getPluginExtensions.test.ts
Co-authored-by: Ben Sully
* Update public/app/features/plugins/extensions/getPluginExtensions.ts
Co-authored-by: Jack Westbrook
* Update public/app/features/plugins/extensions/getPluginExtensions.test.ts
Co-authored-by: Jack Westbrook
---------
Co-authored-by: Ben Sully
Co-authored-by: Jack Westbrook
---
.../extensions/getPluginExtensions.test.ts | 16 ++++++++++++++--
.../plugins/extensions/getPluginExtensions.ts | 6 +++---
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/public/app/features/plugins/extensions/getPluginExtensions.test.ts b/public/app/features/plugins/extensions/getPluginExtensions.test.ts
index 0ad86c5f080..ce106bce5a5 100644
--- a/public/app/features/plugins/extensions/getPluginExtensions.test.ts
+++ b/public/app/features/plugins/extensions/getPluginExtensions.test.ts
@@ -134,18 +134,30 @@ describe('getPluginExtensions()', () => {
expect(extension.category).toBe('Machine Learning');
});
- test('should hide the extension if it tries to override not-allowed properties with the configure() function', () => {
+ test('should ignore restricted properties passed via the configure() function', () => {
link2.configure = jest.fn().mockImplementation(() => ({
// The following props are not allowed to override
type: 'unknown-type',
pluginId: 'another-plugin',
+
+ // Unknown properties
+ testing: false,
+
+ // The following props are allowed to override
+ title: 'test',
}));
const registry = createPluginExtensionRegistry([{ pluginId, extensionConfigs: [link2] }]);
const { extensions } = getPluginExtensions({ registry, extensionPointId: extensionPoint2 });
+ const [extension] = extensions;
expect(link2.configure).toHaveBeenCalledTimes(1);
- expect(extensions).toHaveLength(0);
+ expect(extensions).toHaveLength(1);
+ expect(extension.title).toBe('test');
+ expect(extension.type).toBe('link');
+ expect(extension.pluginId).toBe('grafana-basic-app');
+ //@ts-ignore
+ expect(extension.testing).toBeUndefined();
});
test('should pass a read only context to the configure() function', () => {
const context = { title: 'New title from the context!' };
diff --git a/public/app/features/plugins/extensions/getPluginExtensions.ts b/public/app/features/plugins/extensions/getPluginExtensions.ts
index e878989ebf1..71acd6a365b 100644
--- a/public/app/features/plugins/extensions/getPluginExtensions.ts
+++ b/public/app/features/plugins/extensions/getPluginExtensions.ts
@@ -139,10 +139,10 @@ function getLinkExtensionOverrides(pluginId: string, config: PluginExtensionLink
assertStringProps({ title, description }, ['title', 'description']);
if (Object.keys(rest).length > 0) {
- throw new Error(
- `Invalid extension "${config.title}". Trying to override not-allowed properties: ${Object.keys(rest).join(
+ logWarning(
+ `Extension "${config.title}", is trying to override restricted properties: ${Object.keys(rest).join(
', '
- )}`
+ )} which will be ignored.`
);
}
From c6ab1ddb704f882043c38d8013e7cce43afdada6 Mon Sep 17 00:00:00 2001
From: brendamuir <100768211+brendamuir@users.noreply.github.com>
Date: Tue, 25 Jul 2023 22:01:22 +0200
Subject: [PATCH 04/64] Docs: adds new alert rule creation flow (#72257)
* Docs: adds new alert rule creation flow
* updates configure alerting topic
* Adds grafana-managed process
* adds data source-managed and recording rule
* takes out anchor
---
.../sources/alerting/alerting-rules/_index.md | 16 +-
.../create-grafana-managed-rule.md | 155 +++++++++++++-----
...reate-mimir-loki-managed-recording-rule.md | 8 +-
.../create-mimir-loki-managed-rule.md | 120 ++++++++++----
4 files changed, 215 insertions(+), 84 deletions(-)
diff --git a/docs/sources/alerting/alerting-rules/_index.md b/docs/sources/alerting/alerting-rules/_index.md
index 36377ae8894..da1bda8d87d 100644
--- a/docs/sources/alerting/alerting-rules/_index.md
+++ b/docs/sources/alerting/alerting-rules/_index.md
@@ -22,21 +22,15 @@ Configure the features and integrations that you need to create and manage your
**Configure alert rules**
-An alert rule is a set of evaluation criteria that determines whether an alert will fire. The alert rule consists of one or more queries and expressions, a condition, the frequency of evaluation, and optionally, the duration over which the condition is met.
+[Configure Grafana-managed alert rules][create-grafana-managed-rule].
-While queries and expressions select the data set to evaluate, a condition sets the threshold that an alert must meet or exceed to create an alert. An interval specifies how frequently an alert rule is evaluated. Duration, when configured, indicates how long a condition must be met. Alert rules can also define alerting behavior in the absence of data.
+[Configure data source-managed alert rules][create-mimir-loki-managed-rule]
-You can:
+**Configure recording rules**
-- [Create Grafana Mimir or Loki managed alert rules][create-mimir-loki-managed-rule].
-- [Create Grafana Mimir or Loki managed recording rules][create-mimir-loki-managed-recording-rule].
-- [Edit Grafana Mimir or Loki rule groups and namespaces][edit-mimir-loki-namespace-group].
-- [Create Grafana managed alert rules][create-grafana-managed-rule].
+_Recording rules are only available for compatible Prometheus or Loki data sources._
-**Note:**
-Grafana managed alert rules can only be edited or deleted by users with Edit permissions for the folder storing the rules.
-
-Alert rules for an external Grafana Mimir or Loki instance can be edited or deleted by users with Editor or Admin roles.
+For more information, see [Configure recording rules][create-mimir-loki-managed-recording-rule].
**Configure contact points**
diff --git a/docs/sources/alerting/alerting-rules/create-grafana-managed-rule.md b/docs/sources/alerting/alerting-rules/create-grafana-managed-rule.md
index 1259d24e016..3ad30c6a4bc 100644
--- a/docs/sources/alerting/alerting-rules/create-grafana-managed-rule.md
+++ b/docs/sources/alerting/alerting-rules/create-grafana-managed-rule.md
@@ -2,76 +2,153 @@
aliases:
- ../unified-alerting/alerting-rules/create-grafana-managed-rule/
canonical: https://grafana.com/docs/grafana/latest/alerting/alerting-rules/create-grafana-managed-rule/
-description: Create Grafana managed alert rule
+description: Configure Grafana-managed alert rules
keywords:
- grafana
- alerting
- guide
- rules
- create
+ - grafana-managed
+ - data source-managed
labels:
products:
- cloud
- enterprise
- oss
-title: Create Grafana-managed alert rules
+title: Configure Grafana-managed alert rules
weight: 400
---
-# Create Grafana-managed alert rules
+# Configure Grafana-managed alert rules
Grafana-managed rules are the most flexible alert rule type. They allow you to create alerts that can act on data from any of our supported data sources. In addition to supporting multiple data sources, you can also add expressions to transform your data and set alert conditions. Using images in alert notifications is also supported. This is the only type of rule that allows alerting from multiple data sources in a single rule definition.
Multiple alert instances can be created as a result of one alert rule (also known as a multi-dimensional alerting).
-For information on Grafana Alerting, see [Introduction to Grafana Alerting][fundamentals], which explains the key concepts and features of Grafana Alerting.
+**Note:**
-Watch this video to learn more about creating alerts: {{< vimeo 720001934 >}}
+Grafana managed alert rules can only be edited or deleted by users with Edit permissions for the folder storing the rules.
-To create a Grafana-managed alert rule, complete the following steps.
+Watch this video to learn more about creating alert rules: {{< vimeo 720001934 >}}
-1. In the left-side menu, click **Alerts & IRM** and then **Alerting**.
-2. Click **Alert rules**.
-3. Click **+ Create alert rule**. The new alert rule page opens where the **Grafana managed alerts** option is selected by default.
-4. In Step 1, add the rule name.
- - In **Rule name**, add a descriptive name. This name is displayed in the alert rule list. It is also the `alertname` label for every alert instance that is created from this rule.
-5. In Step 2, add queries and expressions to evaluate, and then select the alert condition.
+In the following sections, we’ll guide you through the process of creating your Grafana-managed alert rules.
- - For queries, select a data source from the dropdown.
- - Specify a [time range][time-units-and-relative-ranges].
+To create a Grafana-managed alert rule, use the in-product alert creation flow and follow these steps to help you.
- **Note:**
- Grafana Alerting only supports fixed relative time ranges, for example, `now-24hr: now`.
+1. Enter an alert rule name
+1. Define query and alert condition
+1. Set evaluation behavior
+1. Add annotations
+1. Configure notifications
- It does not support absolute time ranges: `2021-12-02 00:00:00 to 2021-12-05 23:59:592` or semi-relative time ranges: `now/d to: now`.
+## Set alert rule name
- - Add one or more [queries][add-a-query] or [expressions][expression-queries].
- - For each expression, select either **Classic condition** to create a single alert rule, or choose from the **Math**, **Reduce**, and **Resample** options to generate separate alert for each series. For details on these options, see [Single and multi dimensional rule](#single-and-multi-dimensional-rule).
- - Click **Run queries** to verify that the query is successful.
- - Next, select the query or expression for your alert condition.
+1. Click **Alerts & IRM** -> **Alert rules** -> **+ New alert rule**.
+1. Enter a name to identify your alert rule.
-6. In Step 3, specify the alert evaluation interval.
+ This name is displayed in the alert rule list. It is also the `alertname` label for every alert instance that is created from this rule.
- - From the **Condition** dropdown, select the query or expression to trigger the alert rule.
- - For **Evaluate every**, specify the frequency of evaluation. Must be a multiple of 10 seconds. For examples, `1m`, `30s`.
- - For **Evaluate for**, specify the duration for which the condition must be true before an alert fires.
- > **Note:** Once a condition is breached, the alert goes into the Pending state. If the condition remains breached for the duration specified, the alert transitions to the `Firing` state, otherwise it reverts back to the `Normal` state.
- - In **Configure no data and error handling**, configure alerting behavior in the absence of data. Use the guidelines in [No data and error handling](#configure-no-data-and-error-handling).
- - Click **Preview** to check the result of running the query at this moment. Preview excludes no data and error handling.
+## Define query and condition
- **Note:**
+Define a query to get the data you want to measure and a condition that needs to be met before an alert rule fires.
- You can pause alert rule evaluation to prevent noisy alerting while tuning your alerts. Pausing stops alert rule evaluation and does not create any alert instances. This is different to mute timings, which stop notifications from being delivered, but still allow for alert rule evaluation and the creation of alert instances.
+1. Select a data source.
+1. From the **Options** dropdown, specify a [time range][time-units-and-relative-ranges].
-7. In Step 4, add the storage location, rule group, as well as additional metadata associated with the rule.
- - From the **Folder** dropdown, select the folder where you want to store the rule.
- - For **Group**, specify a pre-defined group. Newly created rules are appended to the end of the group. Rules within a group are run sequentially at a regular interval, with the same evaluation time.
- - Add a description and summary to customize alert messages. Use the guidelines in [Annotations and labels for alerting][annotation-label].
- - Add Runbook URL, panel, dashboard, and alert IDs.
-8. In Step 5, add custom labels.
- - Add custom labels selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value .
-9. Click **Save** to save the rule or **Save and exit** to save the rule and go back to the Alerting page.
-10. Next, create a for the rule.
+ **Note:**
+
+ Grafana Alerting only supports fixed relative time ranges, for example, `now-24hr: now`.
+
+ It does not support absolute time ranges: `2021-12-02 00:00:00 to 2021-12-05 23:59:592` or semi-relative time ranges: `now/d to: now`.
+
+1. Add a query.
+
+ To add multiple [queries][add-a-query], click **Add query**.
+
+ All alert rules are managed by Grafana by default. If you want to switch to a data source-managed alert rule, click **Switch to data source-managed alert rule**.
+
+1. Add one or more [expressions][expression-queries].
+ a. For each expression, select either **Classic condition** to create a single alert rule, or choose from the **Math**, **Reduce**, and **Resample** options to generate separate alert for each series.
+
+ For details on these options, see [Single and multi dimensional rule]
+ b. Click **Preview** to verify that the expression is successful.
+
+1. Click **Set as alert condition** on the query or expression you want to set as your alert condition.
+
+## Set alert evaluation behavior
+
+Use alert rule evaluation to determine how frequently an alert rule should be evaluated and how quickly it should change its state.
+
+To do this, you need to make sure that your alert rule is in the right evaluation group and set a pending period time that works best for your use case.
+
+1. Select a folder or click **+ New folder**.
+1. Select an evaluation group or click **+ New evaluation group**.
+
+ If you are creating a new evaluation group, specify the interval for the group.
+
+ All rules within the same group are evaluated sequentially over the same time interval.
+
+1. Enter a pending period.
+
+ The pending period is the period in which an alert rule can be in breach of the condition until it fires.
+
+ Once a condition is met, the alert goes into the **Pending** state. If the condition remains active for the duration specified, the alert transitions to the **Firing** state, else it reverts to the **Normal** state.
+
+1. Turn on pause alert notifications, if required.
+
+ **Note**:
+
+ Pause alert rule evaluation to prevent noisy alerting while tuning your alerts. Pausing stops alert rule evaluation and does not create any alert instances. This is different to mute timings, which stop notifications from being delivered, but still allow for alert rule evaluation and the creation of alert instances.
+
+ You can pause alert rule evaluation to prevent noisy alerting while tuning your alerts. Pausing stops alert rule evaluation and does not create any alert instances. This is different to mute timings, which stop notifications from being delivered, but still allow for alert rule evaluation and the creation of alert instances.
+
+1. In **Configure no data and error handling**, configure alerting behavior in the absence of data.
+
+ Use the guidelines in [No data and error handling](#configure-no-data-and-error-handling).
+
+## Add annotations
+
+Add [annotations][annotation-label]. to provide more context on the alert in your alert notifications.
+
+Annotations add metadata to provide more information on the alert in your alert notifications. For example, add a **Summary** annotation to tell you which value caused the alert to fire or which server it happened on.
+
+1. [Optional] Add a summary.
+
+ Short summary of what happened and why.
+
+2. [Optional] Add a description.
+
+ Description of what the alert rule does.
+
+3. [Optional] Add a Runbook URL.
+
+ Webpage where you keep your runbook for the alert
+
+4. [Optional] Add a custom annotation
+5. [Optional] Add a dashboard and panel link.
+
+ Links alerts to panels in a dashboard.
+
+## Configure notifications
+
+Add labels to your alert rules to set which notification policy should handle your firing alert instances.
+
+All alert rules and instances, irrespective of their labels, match the default notification policy. If there are no nested policies, or no nested policies match the labels in the alert rule or alert instance, then the default notification policy is the matching policy.
+
+1. Add labels if you want to change the way your notifications are routed.
+
+ Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.
+
+2. Preview your alert instance routing set up.
+
+ Based on the labels added, alert instances are routed to the following notification policies displayed.
+
+ Expand each notification policy below to view more details.
+
+3. Click **See details** to view alert routing details and an email preview.
+
+4. Click **Save rule**.
### Single and multi-dimensional rule
diff --git a/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-recording-rule.md b/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-recording-rule.md
index 45ba9ea2fcb..dc3151bc699 100644
--- a/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-recording-rule.md
+++ b/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-recording-rule.md
@@ -50,17 +50,17 @@ To create recording rules, follow these steps.
1. Click **Alert rules**.
1. Click the **More** dropdown and then **New recording rule**.
-1. Add the rule name.
+1. Set rule name.
The recording rule name must be a Prometheus metric name and contain no whitespace.
-1. Select a data source.
+1. Define query.
- Select your Loki or Prometheus data source.
- Enter a query.
-1. Add a namespace and a group.
+1. Add namespace and group.
- From the **Namespace** dropdown, select an existing rule namespace or add a new one. Namespaces can contain one or more rule groups and only have an organizational purpose. For more information, see [Grafana Mimir or Loki rule groups and namespaces][edit-mimir-loki-namespace-group].
- From the **Group** dropdown, select an existing group within the selected namespace or add a new one. Newly created rules are appended to the end of the group. Rules within a group are run sequentially at a regular interval, with the same evaluation time.
-1. Add custom labels.
+1. Add labels.
- Add custom labels selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value .
1. Click **Save rule** to save the rule or **Save rule and exit** to save the rule and go back to the Alerting page.
diff --git a/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-rule.md b/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-rule.md
index 5035b8271c0..9090458fe61 100644
--- a/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-rule.md
+++ b/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-rule.md
@@ -4,7 +4,7 @@ aliases:
- ../unified-alerting/alerting-rules/create-mimir-loki-managed-recording-rule/
- ../unified-alerting/alerting-rules/create-mimir-loki-managed-rule/
canonical: https://grafana.com/docs/grafana/latest/alerting/alerting-rules/create-mimir-loki-managed-rule/
-description: Create Grafana Mimir or Loki managed alerting rule
+description: Configure data source-managed alert rules
keywords:
- grafana
- alerting
@@ -16,19 +16,23 @@ labels:
- cloud
- enterprise
- oss
-title: Create Grafana Mimir or Loki managed alert rules
+title: Configure data source-managed alert rules
weight: 400
---
-# Create Grafana Mimir or Loki managed alert rules
+# Configure data source-managed alert rules
-Grafana allows you to create alerting rules for an external Grafana Mimir or Loki instance that has ruler API enabled. For information on Grafana Alerting, see [About Grafana Alerting][alerting] which explains the various components of Grafana Alerting. We also recommend that you familiarize yourself with some of the [fundamental concepts][fundamentals] of Grafana Alerting.
+Create alert rules for an external Grafana Mimir or Loki instance that has ruler API enabled; these are called data source-managed alert rules.
+
+**Note**:
+
+Alert rules for an external Grafana Mimir or Loki instance can be edited or deleted by users with Editor or Admin roles.
## Before you begin
-- Verify that you have write permission to the Prometheus or Loki data source. Otherwise, you will not be able to create or update Grafana Mimir managed alerting rules.
+- Verify that you have write permission to the Prometheus or Loki data source. Otherwise, you will not be able to create or update Grafana Mimir managed alert rules.
-- For Grafana Mimir and Loki data sources, enable the ruler API by configuring their respective services.
+- For Grafana Mimir and Loki data sources, enable the Ruler API by configuring their respective services.
- **Loki** - The `local` rule storage type, default for the Loki data source, supports only viewing of rules. To edit rules, configure one of the other rule storage types.
@@ -36,34 +40,90 @@ Grafana allows you to create alerting rules for an external Grafana Mimir or Lok
Watch this video to learn more about how to create a Mimir managed alert rule: {{< vimeo 720001865 >}}
-_Refer to [Add a Grafana Mimir or Loki managed alerting rule]({{< relref "#add-a-grafana-mimir-or-loki-managed-alerting-rule" >}}) (following) for current instructions._
-
{{% admonition type="note" %}}
-If you do not want to manage alerting rules for a particular Loki or Prometheus data source, go to its settings and clear the **Manage alerts via Alerting UI** checkbox.
+If you do not want to manage alert rules for a particular Loki or Prometheus data source, go to its settings and clear the **Manage alerts via Alerting UI** checkbox.
{{% /admonition %}}
-## Add a Grafana Mimir or Loki managed alerting rule
+In the following sections, we’ll guide you through the process of creating your data source-managed alert rules.
-1. In the left-side menu, click **Alerts & IRM** and then **Alerting**.
-1. Click **Alert rules**.
-1. Click **+ Create alert rule**. The new alerting rule page opens where the **Grafana managed alerts** option is selected by default.
-1. In Step 1, add the rule name.
- - In **Rule name**, add a descriptive name. This name is displayed in the alert rule list. It is also the `alertname` label for every alert instance that is created from this rule.
-1. In Step 2, select **Mimir or Loki alert** option.
- - Next, select your Loki or Prometheus data source and add the query to evaluate.
- - Enter a PromQL or LogQL expression to query. The rule fires if the evaluation result has at least one series with a value that is greater than 0. An alert is created for each series.
-1. In Step 3, specify the alert evaluation interval.
- - In the **For** text box, specify the duration for which the condition must be true before an alert fires. If you specify `5m`, the condition must be true for 5 minutes before the alert fires.
- > **Note:** Once a condition is met, the alert goes into the `Pending` state. If the condition remains active for the duration specified, the alert transitions to the `Firing` state, else it reverts to the `Normal` state.
-1. In Step 4, add the namespace, rule group, as well as additional metadata associated with the rule.
- - From the **Namespace** dropdown, select an existing rule namespace. Otherwise, click **Add new** and enter a name to create a new one. Namespaces can contain one or more rule groups and only have an organizational purpose. For more information, see [Grafana Mimir or Loki rule groups and namespaces][edit-mimir-loki-namespace-group].
- - From the **Group** dropdown, select an existing group within the selected namespace. Otherwise, click **Add new** and enter a name to create a new one. Newly created rules are appended to the end of the group. Rules within a group are run sequentially at a regular interval, with the same evaluation time.
- - Add a description and summary to customize alert messages. Use the guidelines in [Annotations and labels for alerting][annotation-label].
- - Add Runbook URL, panel, dashboard, and alert IDs.
-1. In Step 5, add custom labels.
- - Add custom labels selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value .
-1. Click **Save** to save the rule or **Save and exit** to save the rule and go back to the Alerting page.
-1. Next, create a notification for the rule.
+To create a data source-managed alert rule, use the in-product alert creation flow and follow these steps to help you.
+
+1. Enter an alert rule name
+2. Define query and alert condition
+3. Set evaluation behavior
+4. Add annotations
+5. Configure notifications
+
+## Set alert rule name
+
+1. Click **Alerts & IRM** -> **Alert rules** -> **+ New alert rule**.
+1. Enter a name to identify your alert rule.
+
+ This name is displayed in the alert rule list. It is also the `alertname` label for every alert instance that is created from this rule.
+
+## Define query and condition
+
+Define a query to get the data you want to measure and a condition that needs to be met before an alert rule fires.
+
+**Note**:
+
+All alert rules are managed by Grafana by default. To switch to a data source-managed alert rule, click **Switch to data source-managed alert rule**.
+
+1. Select a data source.
+1. Enter a PromQL or LogQL query.
+1. Click **Preview alerts**.
+
+## Set alert evaluation behavior
+
+Use alert rule evaluation to determine how frequently an alert rule should be evaluated and how quickly it should change its state.
+
+1. Select a namespace or click **+ New namespace**.
+1. Select an evaluation group or click **+ New evaluation group**.
+
+ If you are creating a new evaluation group, specify the interval for the group.
+
+ All rules within the same group are evaluated sequentially over the same time interval.
+
+1. Enter a pending period.
+
+ The pending period is the period in which an alert rule can be in breach of the condition until it fires.
+
+ Once a condition is met, the alert goes into the **Pending** state. If the condition remains active for the duration specified, the alert transitions to the **Firing** state, else it reverts to the **Normal** state.
+
+## Add annotations
+
+Add [annotations][annotation-label]. to provide more context on the alert in your alert notifications.
+
+Annotations add metadata to provide more information on the alert in your alert notifications. For example, add a **Summary** annotation to tell you which value caused the alert to fire or which server it happened on.
+
+1. [Optional] Add a summary.
+
+ Short summary of what happened and why.
+
+2. [Optional] Add a description.
+
+ Description of what the alert rule does.
+
+3. [Optional] Add a Runbook URL.
+
+ Webpage where you keep your runbook for the alert
+
+4. [Optional] Add a custom annotation
+5. [Optional] Add a dashboard and panel link.
+
+ Links alerts to panels in a dashboard.
+
+## Configure notifications
+
+Add labels to your alert rules to set which notification policy should handle your firing alert instances.
+
+All alert rules and instances, irrespective of their labels, match the default notification policy. If there are no nested policies, or no nested policies match the labels in the alert rule or alert instance, then the default notification policy is the matching policy.
+
+1. Add labels if you want to change the way your notifications are routed.
+
+ Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.
+
+1. Click **Save rule**.
{{% docs/reference %}}
[alerting]: "/docs/grafana/ -> /docs/grafana//alerting"
From 19b239fba099d852fd1fbc5f9680f9f224ad0c4f Mon Sep 17 00:00:00 2001
From: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com>
Date: Tue, 25 Jul 2023 22:34:14 +0200
Subject: [PATCH 05/64] Alerting: Fix inconsistencies in alert rule form
depending on alert type (#72287)
* Fix inconsistencies in alert rule form depending on alert type
* Fix default annotations when comming from dashboard panel
* Update texts following pr review comments
* Fix texts
---------
Co-authored-by: Virginia Cepeda
---
.../components/rule-editor/AlertRuleForm.tsx | 11 +++++++++--
.../rule-editor/CloudEvaluationBehavior.tsx | 13 +++++++++++--
.../unified/components/rule-editor/DetailsStep.tsx | 7 ++++---
.../components/rule-editor/FolderAndGroup.tsx | 2 +-
.../rule-editor/GrafanaEvaluationBehavior.tsx | 2 +-
.../components/rule-editor/NotificationsStep.tsx | 2 +-
.../QueryAndExpressionsStep.tsx | 9 ++++++---
.../features/alerting/unified/utils/constants.ts | 6 +++---
.../features/alerting/unified/utils/rule-form.ts | 5 +++--
9 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/public/app/features/alerting/unified/components/rule-editor/AlertRuleForm.tsx b/public/app/features/alerting/unified/components/rule-editor/AlertRuleForm.tsx
index e8715f33eb0..038a776fb35 100644
--- a/public/app/features/alerting/unified/components/rule-editor/AlertRuleForm.tsx
+++ b/public/app/features/alerting/unified/components/rule-editor/AlertRuleForm.tsx
@@ -21,7 +21,13 @@ import { useUnifiedAlertingSelector } from '../../hooks/useUnifiedAlertingSelect
import { deleteRuleAction, saveRuleFormAction } from '../../state/actions';
import { RuleFormType, RuleFormValues } from '../../types/rule-form';
import { initialAsyncRequestState } from '../../utils/redux';
-import { getDefaultFormValues, getDefaultQueries, MINUTE, rulerRuleToFormValues } from '../../utils/rule-form';
+import {
+ getDefaultFormValues,
+ getDefaultQueries,
+ MINUTE,
+ normalizeDefaultAnnotations,
+ rulerRuleToFormValues,
+} from '../../utils/rule-form';
import * as ruleId from '../../utils/rule-id';
import { CloudEvaluationBehavior } from './CloudEvaluationBehavior';
@@ -50,7 +56,7 @@ const AlertRuleNameInput = () => {
const ruleFormType = watch('type');
return (
-
+ {
} = useFormContext();
const type = watch('type');
+ const dataSourceName = watch('dataSourceName');
// cloud recording rules do not have alert conditions
if (type === RuleFormType.cloudRecording) {
@@ -28,8 +30,11 @@ export const CloudEvaluationBehavior = () => {
}
return (
-
-
+
+
Manipulate data returned from queries with math and other operations
+
Manipulate data returned from queries with math and other operations.
= {
};
export const annotationDescriptions: Record = {
- [Annotation.description]: 'Description of what the alert rule does',
- [Annotation.summary]: 'Short summary of what happened and why',
- [Annotation.runbookURL]: 'Webpage where you keep your runbook for the alert',
+ [Annotation.description]: 'Description of what the alert rule does.',
+ [Annotation.summary]: 'Short summary of what happened and why.',
+ [Annotation.runbookURL]: 'Webpage where you keep your runbook for the alert.',
[Annotation.dashboardUID]: '',
[Annotation.panelID]: '',
[Annotation.alertId]: '',
diff --git a/public/app/features/alerting/unified/utils/rule-form.ts b/public/app/features/alerting/unified/utils/rule-form.ts
index bb5f3af1ad6..63eb52d6a68 100644
--- a/public/app/features/alerting/unified/utils/rule-form.ts
+++ b/public/app/features/alerting/unified/utils/rule-form.ts
@@ -94,7 +94,7 @@ export function formValuesToRulerRuleDTO(values: RuleFormValues): RulerRuleDTO {
throw new Error(`unexpected rule type: ${type}`);
}
-function listifyLabelsOrAnnotations(
+export function listifyLabelsOrAnnotations(
item: Labels | Annotations | undefined,
addEmpty: boolean
): Array<{ key: string; value: string }> {
@@ -106,7 +106,7 @@ function listifyLabelsOrAnnotations(
}
//make sure default annotations are always shown in order even if empty
-function normalizeDefaultAnnotations(annotations: Array<{ key: string; value: string }>) {
+export function normalizeDefaultAnnotations(annotations: Array<{ key: string; value: string }>) {
const orderedAnnotations = [...annotations];
const defaultAnnotationKeys = defaultAnnotations.map((annotation) => annotation.key);
@@ -179,6 +179,7 @@ export function rulerRuleToFormValues(ruleWithLocation: RuleWithLocation): RuleF
return {
...defaultFormValues,
...alertingRuleValues,
+ annotations: normalizeDefaultAnnotations(listifyLabelsOrAnnotations(rule.annotations, false)),
type: RuleFormType.cloudAlerting,
dataSourceName: ruleSourceName,
namespace,
From 67a6a99e047d9978545a389d3f41f62e4fd4e89d Mon Sep 17 00:00:00 2001
From: Nathan Marrs
Date: Tue, 25 Jul 2023 23:13:59 +0200
Subject: [PATCH 06/64] Heatmap: Clean up datalink code (#72296)
---
.../plugins/panel/heatmap/HeatmapHoverView.tsx | 17 ++++++++++-------
.../app/plugins/panel/heatmap/HeatmapPanel.tsx | 2 +-
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx b/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx
index 5794e8bd88d..5a05b0ba09e 100644
--- a/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx
+++ b/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx
@@ -125,18 +125,21 @@ const HeatmapHoverCell = ({ data, hover, showHistogram, scopedVars, replaceVars
for (const field of visibleFields ?? []) {
const hasLinks = field.config.links && field.config.links.length > 0;
+
if (hasLinks && data.heatmap) {
- let appropriateScopedVars = scopedVars.filter(
- (sv) => sv && sv.__dataContext && sv.__dataContext.value.field.name === nonNumericOrdinalDisplay
- )[0];
- field.getLinks = getLinksSupplier(data.heatmap, field, appropriateScopedVars ?? {}, replaceVars);
+ const appropriateScopedVars = scopedVars.find(
+ (scopedVar) =>
+ scopedVar && scopedVar.__dataContext && scopedVar.__dataContext.value.field.name === nonNumericOrdinalDisplay
+ );
+
+ field.getLinks = getLinksSupplier(data.heatmap, field, appropriateScopedVars || {}, replaceVars);
}
if (field.getLinks) {
- const v = field.values[index];
- const disp = field.display ? field.display(v) : { text: `${v}`, numeric: +v };
+ const value = field.values[index];
+ const display = field.display ? field.display(value) : { text: `${value}`, numeric: +value };
- field.getLinks({ calculatedValue: disp, valueRowIndex: index }).forEach((link) => {
+ field.getLinks({ calculatedValue: display, valueRowIndex: index }).forEach((link) => {
const key = `${link.title}/${link.href}`;
if (!linkLookup.has(key)) {
links.push(link);
diff --git a/public/app/plugins/panel/heatmap/HeatmapPanel.tsx b/public/app/plugins/panel/heatmap/HeatmapPanel.tsx
index b21560fdd4a..dac87caa2f8 100644
--- a/public/app/plugins/panel/heatmap/HeatmapPanel.tsx
+++ b/public/app/plugins/panel/heatmap/HeatmapPanel.tsx
@@ -48,7 +48,7 @@ export const HeatmapPanel = ({
for (const series of data.series) {
for (const field of series.fields) {
if (field.state?.scopedVars) {
- scopedVarsFromRawData.push(field.state?.scopedVars);
+ scopedVarsFromRawData.push(field.state.scopedVars);
}
}
}
From 88988e43374b660d4b452e78b93c0bcddc48a84c Mon Sep 17 00:00:00 2001
From: Coen van Leeuwen
Date: Tue, 25 Jul 2023 23:20:00 +0200
Subject: [PATCH 07/64] XYChart: Prevent crash on point hover (#70225)
---
public/app/plugins/panel/xychart/TooltipView.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/public/app/plugins/panel/xychart/TooltipView.tsx b/public/app/plugins/panel/xychart/TooltipView.tsx
index bf8256bf309..5bfe57ff54c 100644
--- a/public/app/plugins/panel/xychart/TooltipView.tsx
+++ b/public/app/plugins/panel/xychart/TooltipView.tsx
@@ -72,8 +72,8 @@ export const TooltipView = ({
let yValue: YValue | null = null;
let extraFacets: ExtraFacets | null = null;
if (seriesMapping === SeriesMapping.Manual && manualSeriesConfigs) {
- const colorFacetFieldName = manualSeriesConfigs[hoveredPointIndex].pointColor?.field ?? '';
- const sizeFacetFieldName = manualSeriesConfigs[hoveredPointIndex].pointSize?.field ?? '';
+ const colorFacetFieldName = manualSeriesConfigs[hoveredPointIndex]?.pointColor?.field ?? '';
+ const sizeFacetFieldName = manualSeriesConfigs[hoveredPointIndex]?.pointSize?.field ?? '';
const colorFacet = colorFacetFieldName ? findField(frame, colorFacetFieldName) : undefined;
const sizeFacet = sizeFacetFieldName ? findField(frame, sizeFacetFieldName) : undefined;
From bf5fa1813710bfa928062b6f8cac4f67be5a3f7a Mon Sep 17 00:00:00 2001
From: brendamuir <100768211+brendamuir@users.noreply.github.com>
Date: Wed, 26 Jul 2023 09:18:13 +0200
Subject: [PATCH 08/64] Docs: updates to alert rule docs (#72313)
* Docs: updates to alert rule docs
* removes steps
* edits to numbering
* description parameter edit
* fixing description frontmatter
---
.../create-grafana-managed-rule.md | 14 ++---
...reate-mimir-loki-managed-recording-rule.md | 6 +-
.../create-mimir-loki-managed-rule.md | 8 +--
.../edit-mimir-loki-namespace-group.md | 63 -------------------
.../alert-rules/organising-alerts.md | 19 +++---
5 files changed, 19 insertions(+), 91 deletions(-)
delete mode 100644 docs/sources/alerting/alerting-rules/edit-mimir-loki-namespace-group.md
diff --git a/docs/sources/alerting/alerting-rules/create-grafana-managed-rule.md b/docs/sources/alerting/alerting-rules/create-grafana-managed-rule.md
index 3ad30c6a4bc..8ed5b22cd95 100644
--- a/docs/sources/alerting/alerting-rules/create-grafana-managed-rule.md
+++ b/docs/sources/alerting/alerting-rules/create-grafana-managed-rule.md
@@ -17,7 +17,7 @@ labels:
- enterprise
- oss
title: Configure Grafana-managed alert rules
-weight: 400
+weight: 100
---
# Configure Grafana-managed alert rules
@@ -36,12 +36,6 @@ In the following sections, we’ll guide you through the process of creating you
To create a Grafana-managed alert rule, use the in-product alert creation flow and follow these steps to help you.
-1. Enter an alert rule name
-1. Define query and alert condition
-1. Set evaluation behavior
-1. Add annotations
-1. Configure notifications
-
## Set alert rule name
1. Click **Alerts & IRM** -> **Alert rules** -> **+ New alert rule**.
@@ -140,15 +134,15 @@ All alert rules and instances, irrespective of their labels, match the default n
Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.
-2. Preview your alert instance routing set up.
+1. Preview your alert instance routing set up.
Based on the labels added, alert instances are routed to the following notification policies displayed.
Expand each notification policy below to view more details.
-3. Click **See details** to view alert routing details and an email preview.
+1. Click **See details** to view alert routing details and an email preview.
-4. Click **Save rule**.
+1. Click **Save rule**.
### Single and multi-dimensional rule
diff --git a/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-recording-rule.md b/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-recording-rule.md
index dc3151bc699..929f6276c25 100644
--- a/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-recording-rule.md
+++ b/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-recording-rule.md
@@ -17,7 +17,7 @@ labels:
- enterprise
- oss
title: Configure recording rules
-weight: 400
+weight: 300
---
# Configure recording rules
@@ -46,8 +46,8 @@ This setting has precedence over each individual rule frequency. If a rule frequ
To create recording rules, follow these steps.
-1. Click **Alerts & IRM** and then **Alerting**.
-1. Click **Alert rules**.
+1. Click **Alerts & IRM** -> **Alerting** ->
+ **Alert rules**.
1. Click the **More** dropdown and then **New recording rule**.
1. Set rule name.
diff --git a/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-rule.md b/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-rule.md
index 9090458fe61..cc58c44ae51 100644
--- a/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-rule.md
+++ b/docs/sources/alerting/alerting-rules/create-mimir-loki-managed-rule.md
@@ -17,7 +17,7 @@ labels:
- enterprise
- oss
title: Configure data source-managed alert rules
-weight: 400
+weight: 200
---
# Configure data source-managed alert rules
@@ -48,12 +48,6 @@ In the following sections, we’ll guide you through the process of creating you
To create a data source-managed alert rule, use the in-product alert creation flow and follow these steps to help you.
-1. Enter an alert rule name
-2. Define query and alert condition
-3. Set evaluation behavior
-4. Add annotations
-5. Configure notifications
-
## Set alert rule name
1. Click **Alerts & IRM** -> **Alert rules** -> **+ New alert rule**.
diff --git a/docs/sources/alerting/alerting-rules/edit-mimir-loki-namespace-group.md b/docs/sources/alerting/alerting-rules/edit-mimir-loki-namespace-group.md
deleted file mode 100644
index 7a9c35d2575..00000000000
--- a/docs/sources/alerting/alerting-rules/edit-mimir-loki-namespace-group.md
+++ /dev/null
@@ -1,63 +0,0 @@
----
-aliases:
- - ../unified-alerting/alerting-rules/edit-cortex-loki-namespace-group/
- - ../unified-alerting/alerting-rules/edit-mimir-loki-namespace-group/
-canonical: https://grafana.com/docs/grafana/latest/alerting/alerting-rules/edit-mimir-loki-namespace-group/
-description: Edit Grafana Mimir or Loki rule groups and namespaces
-keywords:
- - grafana
- - alerting
- - guide
- - group
- - namespace
- - grafana mimir
- - loki
-labels:
- products:
- - cloud
- - enterprise
- - oss
-title: Grafana Mimir or Loki rule groups and namespaces
-weight: 405
----
-
-# Grafana Mimir or Loki rule groups and namespaces
-
-A namespace contains one or more groups. The rules within a group are run sequentially at a regular interval. The default interval is one (1) minute. You can rename Grafana Mimir or Loki rule namespaces and groups, and edit group evaluation intervals.
-
-{{< figure src="/static/img/docs/alerting/unified/rule-list-edit-mimir-loki-icon-8-2.png" caption="Rule group list" alt="Group list" >}}
-
-
-
-## Rename a namespace
-
-To rename a namespace:
-
-1. In the left-side menu, click **Alerts & IRM** and then **Alerting**.
-1. Click **Alert rules** to view the list of existing alerts.
-1. Find a Grafana Mimir or Loki managed rule with the group that belongs to the namespace you want to edit.
-1. Click the **Edit** (pen) icon.
-1. Enter a new name in the **Namespace** field, then click **Save changes**.
-
-A new namespace is created and all groups are copied into this namespace from the old one. The old namespace is deleted.
-
-## Rename rule group or change the rule group evaluation interval
-
-The rules within a group are run sequentially at a regular interval, the default interval is one (1) minute. You can modify this interval using the following instructions.
-
-1. In the left-side menu, click the **Alerts & IRM** and then **Alerting**.
-1. Click **Alert rules** to view the list of existing alerts.
-1. Find a Grafana Mimir or Loki managed rule with the group you want to edit.
-1. Click **Edit** (pen) icon.
-1. Modify the **Rule group** and **Rule group evaluation interval** information as necessary.
-1. Click **Save changes**.
-
-When you rename the group, a new group with all the rules from the old group is created. The old group is deleted.
-
-
-
-
diff --git a/docs/sources/alerting/fundamentals/alert-rules/organising-alerts.md b/docs/sources/alerting/fundamentals/alert-rules/organising-alerts.md
index e078524b4cc..5e5244c593e 100644
--- a/docs/sources/alerting/fundamentals/alert-rules/organising-alerts.md
+++ b/docs/sources/alerting/fundamentals/alert-rules/organising-alerts.md
@@ -1,6 +1,9 @@
---
+aliases:
+ - ../unified-alerting/alerting-rules/edit-cortex-loki-namespace-group/
+ - ../unified-alerting/alerting-rules/edit-mimir-loki-namespace-group/
canonical: https://grafana.com/docs/grafana/latest/alerting/fundamentals/alert-rules/organising-alerts/
-description: Learn how to organize alert rules
+description: Namespaces, folders, and groups
keywords:
- grafana
- alerting
@@ -10,22 +13,22 @@ labels:
- cloud
- enterprise
- oss
-title: Organising alert rules
+title: Namespaces, folders, and groups
weight: 105
---
-## Namespaces and groups
+## Namespaces, folders, and groups
-Alerts can be organized using Folders for Grafana-managed rules and namespaces for Mimir or Loki rules and group names.
+Alerts can be organized using folders for Grafana-managed rules and namespaces for Mimir or Loki rules and group names.
-### Namespaces
+### Namespaces and folders
When creating Grafana-managed rules, the folder can be used to perform access control and grant or deny access to all rules within a specific folder.
+A namespace contains one or more groups. The rules within a group are run sequentially at a regular interval. The default interval is one (1) minute. You can rename Grafana Mimir or Loki rule namespaces and groups, and edit group evaluation intervals.
+
### Groups
-All rules within a group are evaluated at the same **interval**.
-
-Alert rules and recording rules within a group will always be evaluated **sequentially**, meaning no rules will be evaluated at the same time and in order of appearance.
+The rules within a group are run sequentially at a regular interval, meaning no rules will be evaluated at the same time and in order of appearance.. The default interval is one (1) minute. You can rename Grafana Mimir or Loki rule namespaces and groups, and edit group evaluation intervals.
> **Note** If you want rules to be evaluated concurrently and with different intervals, consider storing them in different groups.
From 5ce3a7c6db090ef9b325a4cd3cb5b962c2502434 Mon Sep 17 00:00:00 2001
From: linoman <2051016+linoman@users.noreply.github.com>
Date: Wed, 26 Jul 2023 09:21:16 +0200
Subject: [PATCH 09/64] Doc's: Add google support for team sync (#72316)
Add google support for team sync
---
.../setup-grafana/configure-security/configure-team-sync.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/sources/setup-grafana/configure-security/configure-team-sync.md b/docs/sources/setup-grafana/configure-security/configure-team-sync.md
index a557e48d34c..2f74e9137db 100644
--- a/docs/sources/setup-grafana/configure-security/configure-team-sync.md
+++ b/docs/sources/setup-grafana/configure-security/configure-team-sync.md
@@ -31,6 +31,7 @@ This mechanism allows Grafana to remove an existing synchronized user from a tea
- [Azure AD]({{< relref "./configure-authentication/azuread#team-sync-enterprise-only" >}})
- [GitHub OAuth]({{< relref "./configure-authentication/github#configure-team-synchronization" >}})
- [GitLab OAuth]({{< relref "./configure-authentication/gitlab#configure-team-synchronization" >}})
+- [Google OAuth]({{< relref "./configure-authentication/google#configure-team-sync-for-google-oauth" >}})
- [LDAP]({{< relref "./configure-authentication/enhanced-ldap#ldap-group-synchronization-for-teams" >}})
- [Okta]({{< relref "./configure-authentication/okta#configure-team-synchronization-enterprise-only" >}})
- [SAML]({{< relref "./configure-authentication/saml#configure-team-sync" >}})
From da31b8083ad703ab54f0b424d4e9485ddae67597 Mon Sep 17 00:00:00 2001
From: "grafana-delivery-bot[bot]"
<132647405+grafana-delivery-bot[bot]@users.noreply.github.com>
Date: Wed, 26 Jul 2023 08:00:18 +0000
Subject: [PATCH 10/64] Changelog: Updated changelog for 9.5.7 (#72321)
Co-authored-by: grafanabot
---
CHANGELOG.md | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90da0d8c979..c114a045b91 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -407,6 +407,46 @@ The `database` field has been deprecated in the Elasticsearch datasource provisi
- **InteractiveTable:** Updated design and minor tweak to Correlactions page. [#66443](https://github.com/grafana/grafana/issues/66443), [@torkelo](https://github.com/torkelo)
+
+
+# 9.5.7 (2023-07-20)
+
+### Features and enhancements
+
+- **Alerting:** Sort NumberCaptureValues in EvaluationString. [#71930](https://github.com/grafana/grafana/issues/71930), [@grobinson-grafana](https://github.com/grobinson-grafana)
+- **Alerting:** No longer silence paused alerts during legacy migration. [#71765](https://github.com/grafana/grafana/issues/71765), [@JacobsonMT](https://github.com/JacobsonMT)
+- **Chore:** Upgrade Go to 1.20.6. [#71446](https://github.com/grafana/grafana/issues/71446), [@sakjur](https://github.com/sakjur)
+- **Alerting:** Remove and revert flag alertingBigTransactions. [#70910](https://github.com/grafana/grafana/issues/70910), [@santihernandezc](https://github.com/santihernandezc)
+- **Alerting:** Migrate unknown NoData\Error settings to the default. [#70905](https://github.com/grafana/grafana/issues/70905), [@yuri-tceretian](https://github.com/yuri-tceretian)
+- **Tempo:** Escape regex-sensitive characters in span name before building promql query. [#68318](https://github.com/grafana/grafana/issues/68318), [@joey-grafana](https://github.com/joey-grafana)
+- **Alerting:** Update grafana/alerting to ce9fba9. [#67685](https://github.com/grafana/grafana/issues/67685), [@grobinson-grafana](https://github.com/grobinson-grafana)
+- **Chore:** Upgrade Go to 1.20.6. (Enterprise)
+
+### Bug fixes
+
+- **Plugins:** Only configure plugin proxy transport once. [#71741](https://github.com/grafana/grafana/issues/71741), [@wbrowne](https://github.com/wbrowne)
+- **Alerting:** Fix unique violation when updating rule group with title chains/cycles. [#71330](https://github.com/grafana/grafana/issues/71330), [@grobinson-grafana](https://github.com/grobinson-grafana)
+- **Fix:** Change getExistingDashboardByTitleAndFolder to get dashboard by title, not slug. [#70961](https://github.com/grafana/grafana/issues/70961), [@yangkb09](https://github.com/yangkb09)
+- **Alerting:** Convert 'Both' type Prometheus queries to 'Range' in migration. [#70907](https://github.com/grafana/grafana/issues/70907), [@JacobsonMT](https://github.com/JacobsonMT)
+- **Alerting:** Support newer http_config struct. [#69718](https://github.com/grafana/grafana/issues/69718), [@gillesdemey](https://github.com/gillesdemey)
+- **InfluxDB:** Interpolate retention policies. [#69299](https://github.com/grafana/grafana/issues/69299), [@itsmylife](https://github.com/itsmylife)
+- **StatusHistory:** Fix rendering of value-mapped null. [#69107](https://github.com/grafana/grafana/issues/69107), [@leeoniya](https://github.com/leeoniya)
+- **Alerting:** Fix provenance guard checks for Alertmanager configuration to not cause panic when compared nested objects. [#69092](https://github.com/grafana/grafana/issues/69092), [@yuri-tceretian](https://github.com/yuri-tceretian)
+- **AnonymousAuth:** Fix concurrent read-write crash. [#68802](https://github.com/grafana/grafana/issues/68802), [@Jguer](https://github.com/Jguer)
+- **AzureMonitor:** Ensure legacy properties containing template variables are correctly migrated. [#68790](https://github.com/grafana/grafana/issues/68790), [@aangelisc](https://github.com/aangelisc)
+- **Explore:** Remove data source onboarding page. [#68643](https://github.com/grafana/grafana/issues/68643), [@harisrozajac](https://github.com/harisrozajac)
+- **Dashboard:** Re-align Save form. [#68625](https://github.com/grafana/grafana/issues/68625), [@polibb](https://github.com/polibb)
+- **Azure Monitor:** Fix bug that did not show alert rule preview. [#68582](https://github.com/grafana/grafana/issues/68582), [@alyssabull](https://github.com/alyssabull)
+- **Histogram:** Respect min/max panel settings for x-axis. [#68244](https://github.com/grafana/grafana/issues/68244), [@leeoniya](https://github.com/leeoniya)
+- **Heatmap:** Fix color rendering for value ranges < 1. [#68163](https://github.com/grafana/grafana/issues/68163), [@leeoniya](https://github.com/leeoniya)
+- **Heatmap:** Handle unsorted timestamps in calculate mode. [#68150](https://github.com/grafana/grafana/issues/68150), [@leeoniya](https://github.com/leeoniya)
+- **Google Cloud Monitor:** Fix mem usage for dropdown. [#67949](https://github.com/grafana/grafana/issues/67949), [@asimpson](https://github.com/asimpson)
+- **AzureMonitor:** Fix logs query multi-resource and timespan values. [#67932](https://github.com/grafana/grafana/issues/67932), [@aangelisc](https://github.com/aangelisc)
+- **Utils:** Reimplement util.GetRandomString to avoid modulo bias. [#66970](https://github.com/grafana/grafana/issues/66970), [@DanCech](https://github.com/DanCech)
+- **License:** Enable FeatureUserLimit for all products. (Enterprise)
+- **Auth:** Remove ldap init sync. (Enterprise)
+
+
# 9.5.6 (2023-07-11)
From e094adb5a129157a510b41086c0dc8dacaab9aea Mon Sep 17 00:00:00 2001
From: Konrad Lalik
Date: Wed, 26 Jul 2023 10:37:22 +0200
Subject: [PATCH 11/64] Alerting: Fix refetching grafana rules on alert list
panel (#72242)
---
.../panel/alertlist/UnifiedAlertList.tsx | 56 +++++++++++++------
1 file changed, 40 insertions(+), 16 deletions(-)
diff --git a/public/app/plugins/panel/alertlist/UnifiedAlertList.tsx b/public/app/plugins/panel/alertlist/UnifiedAlertList.tsx
index 5f8c608b484..a29404959f7 100644
--- a/public/app/plugins/panel/alertlist/UnifiedAlertList.tsx
+++ b/public/app/plugins/panel/alertlist/UnifiedAlertList.tsx
@@ -135,18 +135,53 @@ export function UnifiedAlertList(props: PanelProps) {
[parsedOptions.alertInstanceLabelFilter]
);
+ // If the datasource is not defined we should NOT skip the query
+ // Undefined dataSourceName means that there is no datasource filter applied and we should fetch all the rules
+ const shouldFetchGrafanaRules = !dataSourceName || dataSourceName === GRAFANA_RULES_SOURCE_NAME;
+
+ //For grafana managed rules, get the result using RTK Query to avoid the need of using the redux store
+ //See https://github.com/grafana/grafana/pull/70482
+ const {
+ currentData: grafanaPromRules = [],
+ isLoading: grafanaRulesLoading,
+ refetch: refetchGrafanaPromRules,
+ } = usePrometheusRulesByNamespaceQuery(
+ {
+ limitAlerts: limitInstances ? INSTANCES_DISPLAY_LIMIT : undefined,
+ matcher: matcherList,
+ state: stateList,
+ },
+ { skip: !shouldFetchGrafanaRules }
+ );
+
useEffect(() => {
//we need promRules and rulerRules for getting the uid when creating the alert link in panel in case of being a rulerRule.
if (!promRulesRequests.loading) {
fetchPromAndRuler({ dispatch, limitInstances, matcherList, dataSourceName, stateList });
}
- const sub = dashboard?.events.subscribe(TimeRangeUpdatedEvent, () =>
- fetchPromAndRuler({ dispatch, limitInstances, matcherList, dataSourceName, stateList })
- );
+ const sub = dashboard?.events.subscribe(TimeRangeUpdatedEvent, () => {
+ if (shouldFetchGrafanaRules) {
+ refetchGrafanaPromRules();
+ }
+
+ if (!dataSourceName || dataSourceName !== GRAFANA_RULES_SOURCE_NAME) {
+ fetchPromAndRuler({ dispatch, limitInstances, matcherList, dataSourceName, stateList });
+ }
+ });
return () => {
sub?.unsubscribe();
};
- }, [dispatch, dashboard, matcherList, stateList, limitInstances, dataSourceName, promRulesRequests.loading]);
+ }, [
+ dispatch,
+ dashboard,
+ matcherList,
+ stateList,
+ limitInstances,
+ dataSourceName,
+ refetchGrafanaPromRules,
+ shouldFetchGrafanaRules,
+ promRulesRequests.loading,
+ ]);
const handleInstancesLimit = (limit: boolean) => {
if (limit) {
@@ -158,18 +193,7 @@ export function UnifiedAlertList(props: PanelProps) {
}
};
- //For grafana managed rules, get the result using RTK Query to avoid the need of using the redux store
- //See https://github.com/grafana/grafana/pull/70482
- const { currentData: promRules = [], isLoading: grafanaRulesLoading } = usePrometheusRulesByNamespaceQuery(
- {
- limitAlerts: limitInstances ? INSTANCES_DISPLAY_LIMIT : undefined,
- matcher: matcherList,
- state: stateList,
- },
- { skip: dataSourceName !== GRAFANA_RULES_SOURCE_NAME }
- );
-
- const combinedRules = useCombinedRuleNamespaces(undefined, promRules);
+ const combinedRules = useCombinedRuleNamespaces(undefined, grafanaPromRules);
const someRulerRulesDispatched = isAsyncRequestMapSlicePartiallyDispatched(rulerRulesRequests);
const haveResults = isAsyncRequestMapSlicePartiallyFulfilled(promRulesRequests);
From 2dea069443557b5822847f1923a5e613f4c61e9c Mon Sep 17 00:00:00 2001
From: "grafana-delivery-bot[bot]"
<132647405+grafana-delivery-bot[bot]@users.noreply.github.com>
Date: Wed, 26 Jul 2023 11:47:32 +0300
Subject: [PATCH 12/64] Changelog: Updated changelog for 10.0.3 (#72324)
Co-authored-by: grafanabot
---
CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c114a045b91..d77da361b82 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,36 @@
+
+
+# 10.0.3 (2023-07-18)
+
+### Features and enhancements
+
+- **Alerting:** Sort NumberCaptureValues in EvaluationString. [#71931](https://github.com/grafana/grafana/issues/71931), [@grobinson-grafana](https://github.com/grobinson-grafana)
+- **Alerting:** No longer silence paused alerts during legacy migration. [#71761](https://github.com/grafana/grafana/issues/71761), [@JacobsonMT](https://github.com/JacobsonMT)
+- **Auth:** Add support for custom signing keys in auth.azure_ad. [#71708](https://github.com/grafana/grafana/issues/71708), [@Jguer](https://github.com/Jguer)
+- **Chore:** Upgrade Go to 1.20.6. [#71445](https://github.com/grafana/grafana/issues/71445), [@sakjur](https://github.com/sakjur)
+- **Chore:** Upgrade Go to 1.20.6. (Enterprise)
+
+### Bug fixes
+
+- **Alerting:** Fix edit / view of webhook contact point when no authorization is set. [#71972](https://github.com/grafana/grafana/issues/71972), [@gillesdemey](https://github.com/gillesdemey)
+- **AzureMonitor:** Set timespan in Logs Portal URL link. [#71910](https://github.com/grafana/grafana/issues/71910), [@aangelisc](https://github.com/aangelisc)
+- **Plugins:** Only configure plugin proxy transport once. [#71742](https://github.com/grafana/grafana/issues/71742), [@wbrowne](https://github.com/wbrowne)
+- **Elasticsearch:** Fix multiple max depth flatten of multi-level objects. [#71636](https://github.com/grafana/grafana/issues/71636), [@fridgepoet](https://github.com/fridgepoet)
+- **Elasticsearch:** Fix histogram colors in backend mode. [#71447](https://github.com/grafana/grafana/issues/71447), [@gabor](https://github.com/gabor)
+- **Alerting:** Fix state in expressions footer. [#71443](https://github.com/grafana/grafana/issues/71443), [@soniaAguilarPeiron](https://github.com/soniaAguilarPeiron)
+- **AppChromeService:** Fixes update to breadcrumb parent URL. [#71418](https://github.com/grafana/grafana/issues/71418), [@torkelo](https://github.com/torkelo)
+- **Elasticsearch:** Fix using multiple indexes with comma separated string. [#71322](https://github.com/grafana/grafana/issues/71322), [@gabor](https://github.com/gabor)
+- **Alerting:** Fix Alertmanager change detection for receivers with secure settings. [#71320](https://github.com/grafana/grafana/issues/71320), [@JacobsonMT](https://github.com/JacobsonMT)
+- **Transformations:** Fix `extractFields` throwing Error if one value is undefined or null. [#71267](https://github.com/grafana/grafana/issues/71267), [@svennergr](https://github.com/svennergr)
+- **XYChart:** Point size editor should reflect correct default (5). [#71229](https://github.com/grafana/grafana/issues/71229), [@Develer](https://github.com/Develer)
+- **Annotations:** Fix database lock while updating annotations. [#71207](https://github.com/grafana/grafana/issues/71207), [@sakjur](https://github.com/sakjur)
+- **TimePicker:** Fix issue with previous fiscal quarter not parsing correctly. [#71093](https://github.com/grafana/grafana/issues/71093), [@ashharrison90](https://github.com/ashharrison90)
+- **AzureMonitor:** Correctly build multi-resource queries for Application Insights components. [#71039](https://github.com/grafana/grafana/issues/71039), [@aangelisc](https://github.com/aangelisc)
+- **AzureMonitor:** Fix metric names for multi-resources. [#70994](https://github.com/grafana/grafana/issues/70994), [@asimpson](https://github.com/asimpson)
+- **Logs:** Do not insert log-line into log-fields in json download. [#70954](https://github.com/grafana/grafana/issues/70954), [@gabor](https://github.com/gabor)
+- **Loki:** Fix wrong query expression with inline comments. [#70948](https://github.com/grafana/grafana/issues/70948), [@svennergr](https://github.com/svennergr)
+
+
# 10.0.2 (2023-07-11)
From 0da199324a67ff8db86fa5633d7b9d9a1f94012b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Farkas?=
Date: Wed, 26 Jul 2023 10:56:26 +0200
Subject: [PATCH 13/64] logs: log-details: handle dataplane-compliant
dataframes (#71935)
* logs: log-details: handle dataplane-compliant dataframes
* lint fix, removed unused import
---
public/app/features/explore/Logs/Logs.tsx | 1 -
.../features/explore/Logs/LogsTable.test.tsx | 34 +--
.../app/features/explore/Logs/LogsTable.tsx | 29 ++-
.../logs/components/logParser.test.ts | 207 +++++++++++++++++-
.../app/features/logs/components/logParser.ts | 134 ++++++------
5 files changed, 292 insertions(+), 113 deletions(-)
diff --git a/public/app/features/explore/Logs/Logs.tsx b/public/app/features/explore/Logs/Logs.tsx
index aa461951f34..72190ecebdb 100644
--- a/public/app/features/explore/Logs/Logs.tsx
+++ b/public/app/features/explore/Logs/Logs.tsx
@@ -667,7 +667,6 @@ class UnthemedLogs extends PureComponent {