+
+
+
+ );
+ default:
+ return null;
}
}
function RecoveryForSingleValue({ allowOnblur }: RecoveryProps) {
- if (condition.evaluator.type === EvalFunction.IsAbove) {
- return (
-
-
- {
- allowOnblur.current && onUnloadValueChange(event, 0);
- }}
- defaultValue={condition.unloadEvaluator?.params[0]}
- />
-
-
- );
- } else {
- return (
-
-
- {
- allowOnblur.current && onUnloadValueChange(event, 0);
- }}
- defaultValue={condition.unloadEvaluator?.params[0]}
- />
-
-
- );
+ switch (condition.evaluator.type) {
+ case EvalFunction.IsAbove:
+ return (
+
+
+ {
+ allowOnblur.current && onUnloadValueChange(event, 0);
+ }}
+ defaultValue={condition.unloadEvaluator?.params[0]}
+ />
+
+
+ );
+ case EvalFunction.IsBelow:
+ return (
+
+
+ {
+ allowOnblur.current && onUnloadValueChange(event, 0);
+ }}
+ defaultValue={condition.unloadEvaluator?.params[0]}
+ />
+
+
+ );
+ case EvalFunction.IsEqual:
+ return (
+
+
+ {
+ allowOnblur.current && onUnloadValueChange(event, 0);
+ }}
+ defaultValue={condition.unloadEvaluator?.params[0]}
+ />
+
+
+ );
+ case EvalFunction.IsNotEqual:
+ return (
+
+
+ {
+ allowOnblur.current && onUnloadValueChange(event, 0);
+ }}
+ defaultValue={condition.unloadEvaluator?.params[0]}
+ />
+
+
+ );
+ case EvalFunction.IsGreaterThanEqual:
+ return (
+
+
+ {
+ allowOnblur.current && onUnloadValueChange(event, 0);
+ }}
+ defaultValue={condition.unloadEvaluator?.params[0]}
+ />
+
+
+ );
+ case EvalFunction.IsLessThanEqual:
+ return (
+
+
+ {
+ allowOnblur.current && onUnloadValueChange(event, 0);
+ }}
+ defaultValue={condition.unloadEvaluator?.params[0]}
+ />
+
+
+ );
+ default:
+ return null;
}
}
}
diff --git a/public/app/features/expressions/components/thresholdReducer.ts b/public/app/features/expressions/components/thresholdReducer.ts
index 7fa1e428a98..503baa3e727 100644
--- a/public/app/features/expressions/components/thresholdReducer.ts
+++ b/public/app/features/expressions/components/thresholdReducer.ts
@@ -104,12 +104,30 @@ function getUnloadEvaluatorTypeFromEvaluatorType(type: EvalFunction) {
if (type === EvalFunction.IsBelow) {
return EvalFunction.IsAbove;
}
+ if (type === EvalFunction.IsEqual) {
+ return EvalFunction.IsNotEqual;
+ }
+ if (type === EvalFunction.IsNotEqual) {
+ return EvalFunction.IsEqual;
+ }
+ if (type === EvalFunction.IsGreaterThanEqual) {
+ return EvalFunction.IsLessThanEqual;
+ }
+ if (type === EvalFunction.IsLessThanEqual) {
+ return EvalFunction.IsGreaterThanEqual;
+ }
if (type === EvalFunction.IsWithinRange) {
return EvalFunction.IsOutsideRange;
}
if (type === EvalFunction.IsOutsideRange) {
return EvalFunction.IsWithinRange;
}
+ if (type === EvalFunction.IsWithinRangeIncluded) {
+ return EvalFunction.IsOutsideRangeIncluded;
+ }
+ if (type === EvalFunction.IsOutsideRangeIncluded) {
+ return EvalFunction.IsWithinRangeIncluded;
+ }
return EvalFunction.IsBelow;
}
@@ -126,7 +144,12 @@ export function isInvalid(condition: ClassicCondition) {
const { type, params: loadParams } = evaluator;
const { params: unloadParams } = unloadEvaluator;
- if (type === EvalFunction.IsWithinRange || type === EvalFunction.IsOutsideRange) {
+ if (
+ type === EvalFunction.IsWithinRange ||
+ type === EvalFunction.IsOutsideRange ||
+ type === EvalFunction.IsWithinRangeIncluded ||
+ type === EvalFunction.IsOutsideRangeIncluded
+ ) {
if (unloadParams[0] === undefined || Number.isNaN(unloadParams[0])) {
return { errorMsgFrom: 'This value cannot be empty' };
}
@@ -149,6 +172,26 @@ export function isInvalid(condition: ClassicCondition) {
return { errorMsg: `Enter a number more than or equal to ${firstParamInEvaluator}` };
}
break;
+ case EvalFunction.IsEqual:
+ if (firstParamInUnloadEvaluator === firstParamInEvaluator) {
+ return { errorMsg: `Enter a different number than ${firstParamInEvaluator}` };
+ }
+ break;
+ case EvalFunction.IsNotEqual:
+ if (firstParamInUnloadEvaluator !== firstParamInEvaluator) {
+ return { errorMsg: `Enter the same number as ${firstParamInEvaluator}` };
+ }
+ break;
+ case EvalFunction.IsGreaterThanEqual:
+ if (firstParamInUnloadEvaluator >= firstParamInEvaluator) {
+ return { errorMsg: `Enter a number less than ${firstParamInEvaluator}` };
+ }
+ break;
+ case EvalFunction.IsLessThanEqual:
+ if (firstParamInUnloadEvaluator <= firstParamInEvaluator) {
+ return { errorMsg: `Enter a number more than ${firstParamInEvaluator}` };
+ }
+ break;
case EvalFunction.IsOutsideRange:
if (firstParamInUnloadEvaluator < firstParamInEvaluator) {
return { errorMsgFrom: `Enter a number more than or equal to ${firstParamInEvaluator}` };
@@ -165,6 +208,22 @@ export function isInvalid(condition: ClassicCondition) {
return { errorMsgTo: `Enter a number be more than or equal to ${secondParamInEvaluator}` };
}
break;
+ case EvalFunction.IsOutsideRangeIncluded:
+ if (firstParamInUnloadEvaluator <= firstParamInEvaluator) {
+ return { errorMsgFrom: `Enter a number more than ${firstParamInEvaluator}` };
+ }
+ if (secondParamInUnloadEvaluator >= secondParamInEvaluator) {
+ return { errorMsgTo: `Enter a number less than ${secondParamInEvaluator}` };
+ }
+ break;
+ case EvalFunction.IsWithinRangeIncluded:
+ if (firstParamInUnloadEvaluator >= firstParamInEvaluator) {
+ return { errorMsgFrom: `Enter a number less than ${firstParamInEvaluator}` };
+ }
+ if (secondParamInUnloadEvaluator <= secondParamInEvaluator) {
+ return { errorMsgTo: `Enter a number be more than ${secondParamInEvaluator}` };
+ }
+ break;
default:
throw new Error(`evaluator function type ${type} not supported.`);
}
diff --git a/public/app/features/expressions/types.ts b/public/app/features/expressions/types.ts
index a1f88729c1e..a132670f00f 100644
--- a/public/app/features/expressions/types.ts
+++ b/public/app/features/expressions/types.ts
@@ -126,8 +126,14 @@ export const upsamplingTypes: Array> = [
export const thresholdFunctions: Array> = [
{ value: EvalFunction.IsAbove, label: 'Is above' },
{ value: EvalFunction.IsBelow, label: 'Is below' },
+ { value: EvalFunction.IsEqual, label: 'Is equal to' },
+ { value: EvalFunction.IsNotEqual, label: 'Is not equal to' },
+ { value: EvalFunction.IsGreaterThanEqual, label: 'Is above or equal to' },
+ { value: EvalFunction.IsLessThanEqual, label: 'Is below or equal to' },
{ value: EvalFunction.IsWithinRange, label: 'Is within range' },
{ value: EvalFunction.IsOutsideRange, label: 'Is outside range' },
+ { value: EvalFunction.IsWithinRangeIncluded, label: 'Is within range included' },
+ { value: EvalFunction.IsOutsideRangeIncluded, label: 'Is outside range included' },
];
/**
diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json
index 88c3d0aa34b..0e93bc677a7 100644
--- a/public/locales/en-US/grafana.json
+++ b/public/locales/en-US/grafana.json
@@ -528,6 +528,19 @@
},
"pause": {
"label": "Pause evaluation"
+ },
+ "threshold": {
+ "recovery": {
+ "stop-alerting-above": "Stop alerting when above",
+ "stop-alerting-bellow": "Stop alerting when below",
+ "stop-alerting-equal": "Stop alerting when equal to",
+ "stop-alerting-inside-range": "Stop alerting when inside range",
+ "stop-alerting-less": "Stop alerting when less than",
+ "stop-alerting-more": "Stop alerting when more than",
+ "stop-alerting-not-equal": "Stop alerting when not equal to",
+ "stop-alerting-outside-range": "Stop alerting when outside range",
+ "title": "Custom recovery threshold"
+ }
}
},
"rule-groups": {
diff --git a/public/locales/pseudo-LOCALE/grafana.json b/public/locales/pseudo-LOCALE/grafana.json
index f4b2de7e6dc..583a6e6832f 100644
--- a/public/locales/pseudo-LOCALE/grafana.json
+++ b/public/locales/pseudo-LOCALE/grafana.json
@@ -528,6 +528,19 @@
},
"pause": {
"label": "Päūşę ęväľūäŧįőʼn"
+ },
+ "threshold": {
+ "recovery": {
+ "stop-alerting-above": "Ŝŧőp äľęřŧįʼnģ ŵĥęʼn äþővę",
+ "stop-alerting-bellow": "Ŝŧőp äľęřŧįʼnģ ŵĥęʼn þęľőŵ",
+ "stop-alerting-equal": "Ŝŧőp äľęřŧįʼnģ ŵĥęʼn ęqūäľ ŧő",
+ "stop-alerting-inside-range": "Ŝŧőp äľęřŧįʼnģ ŵĥęʼn įʼnşįđę řäʼnģę",
+ "stop-alerting-less": "Ŝŧőp äľęřŧįʼnģ ŵĥęʼn ľęşş ŧĥäʼn",
+ "stop-alerting-more": "Ŝŧőp äľęřŧįʼnģ ŵĥęʼn mőřę ŧĥäʼn",
+ "stop-alerting-not-equal": "Ŝŧőp äľęřŧįʼnģ ŵĥęʼn ʼnőŧ ęqūäľ ŧő",
+ "stop-alerting-outside-range": "Ŝŧőp äľęřŧįʼnģ ŵĥęʼn őūŧşįđę řäʼnģę",
+ "title": "Cūşŧőm řęčővęřy ŧĥřęşĥőľđ"
+ }
}
},
"rule-groups": {
From d1dfa0576b49f94c62f1d023abd9687291a31c7e Mon Sep 17 00:00:00 2001
From: Yuri Tseretyan
Date: Fri, 21 Feb 2025 12:51:38 -0500
Subject: [PATCH 15/22] Alerting: Support Jira Integration (#100480)
---
go.mod | 2 +-
go.sum | 4 +-
.../ngalert/api/compat_contact_points.go | 12 ++
.../api/tooling/definitions/contact_points.go | 24 +++
.../channels_config/available_channels.go | 151 +++++++++++++++++-
.../available_channels_test.go | 22 ++-
.../notifier/channels_config/plugin.go | 2 +
.../provisioning/contactpoints_test.go | 3 +
pkg/storage/unified/apistore/go.mod | 2 +-
pkg/storage/unified/apistore/go.sum | 4 +-
pkg/storage/unified/resource/go.mod | 2 +-
pkg/storage/unified/resource/go.sum | 4 +-
.../notifications/receivers/receiver_test.go | 6 +
13 files changed, 226 insertions(+), 12 deletions(-)
diff --git a/go.mod b/go.mod
index 8e2e1792445..c9a91001aec 100644
--- a/go.mod
+++ b/go.mod
@@ -71,7 +71,7 @@ require (
github.com/googleapis/gax-go/v2 v2.14.1 // @grafana/grafana-backend-group
github.com/gorilla/mux v1.8.1 // @grafana/grafana-backend-group
github.com/gorilla/websocket v1.5.3 // @grafana/grafana-app-platform-squad
- github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0 // @grafana/alerting-backend
+ github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb // @grafana/alerting-backend
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 // @grafana/identity-access-team
github.com/grafana/authlib/types v0.0.0-20250219092154-21ce22b49f31 // @grafana/identity-access-team
github.com/grafana/dataplane/examples v0.0.1 // @grafana/observability-metrics
diff --git a/go.sum b/go.sum
index 88780f81fc9..a467f87cba7 100644
--- a/go.sum
+++ b/go.sum
@@ -1511,8 +1511,8 @@ github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7Fsg
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0 h1:LGH+tVzHCDrR9hsltmkP4jmNRg5IreQw5CNFbJKlnts=
-github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
+github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb h1:WfCsiuZXhGXIdzImQ9/Kjfn9M4e6f7z5mddcSKCRxmI=
+github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 h1:NTMmow+74I3Jb033xhbRgWQS7A//5TDhiM4tl7bsVP4=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7/go.mod h1:T3X4z0ejGfJOiOmZLFeKCRT/yxWJq/RtclAc/PHj/w4=
github.com/grafana/authlib/types v0.0.0-20250219092154-21ce22b49f31 h1:EokLC5grHwLPs4tXW8T6E8187H1e5G9AP0QQ5B60HbA=
diff --git a/pkg/services/ngalert/api/compat_contact_points.go b/pkg/services/ngalert/api/compat_contact_points.go
index d10c3859598..1299af0bb64 100644
--- a/pkg/services/ngalert/api/compat_contact_points.go
+++ b/pkg/services/ngalert/api/compat_contact_points.go
@@ -91,6 +91,13 @@ func ContactPointToContactPointExport(cp definitions.ContactPoint) (notify.APIRe
}
integration = append(integration, el)
}
+ for _, i := range cp.Jira {
+ el, err := marshallIntegration(j, "jira", i, i.DisableResolveMessage)
+ if err != nil {
+ errs = append(errs, err)
+ }
+ integration = append(integration, el)
+ }
for _, i := range cp.Kafka {
el, err := marshallIntegration(j, "kafka", i, i.DisableResolveMessage)
if err != nil {
@@ -271,6 +278,11 @@ func parseIntegration(json jsoniter.API, result *definitions.ContactPoint, recei
if err = json.Unmarshal(data, &integration); err == nil {
result.Googlechat = append(result.Googlechat, integration)
}
+ case "jira":
+ integration := definitions.JiraIntegration{DisableResolveMessage: disable}
+ if err = json.Unmarshal(data, &integration); err == nil {
+ result.Jira = append(result.Jira, integration)
+ }
case "kafka":
integration := definitions.KafkaIntegration{DisableResolveMessage: disable}
if err = json.Unmarshal(data, &integration); err == nil {
diff --git a/pkg/services/ngalert/api/tooling/definitions/contact_points.go b/pkg/services/ngalert/api/tooling/definitions/contact_points.go
index 9df9b8ee444..498ac6f0d37 100644
--- a/pkg/services/ngalert/api/tooling/definitions/contact_points.go
+++ b/pkg/services/ngalert/api/tooling/definitions/contact_points.go
@@ -62,6 +62,29 @@ type GooglechatIntegration struct {
Message *string `json:"message,omitempty" yaml:"message,omitempty" hcl:"message"`
}
+type JiraIntegration struct {
+ DisableResolveMessage *bool `json:"-" yaml:"-" hcl:"disable_resolve_message"`
+
+ URL string `yaml:"api_url,omitempty" json:"api_url,omitempty" hcl:"api_url"`
+ Project string `yaml:"project,omitempty" json:"project,omitempty" hcl:"project"`
+ IssueType string `yaml:"issue_type,omitempty" json:"issue_type,omitempty" hcl:"issue_type"`
+
+ Summary *string `yaml:"summary,omitempty" json:"summary,omitempty" hcl:"summary"`
+ Description *string `yaml:"description,omitempty" json:"description,omitempty" hcl:"description"`
+ Labels *[]string `yaml:"labels,omitempty" json:"labels,omitempty" hcl:"labels"`
+ Priority *string `yaml:"priority,omitempty" json:"priority,omitempty" hcl:"priority"`
+ ReopenTransition *string `yaml:"reopen_transition,omitempty" json:"reopen_transition,omitempty" hcl:"reopen_transition"`
+ ResolveTransition *string `yaml:"resolve_transition,omitempty" json:"resolve_transition,omitempty" hcl:"resolve_transition"`
+ WontFixResolution *string `yaml:"wont_fix_resolution,omitempty" json:"wont_fix_resolution,omitempty" hcl:"wont_fix_resolution"`
+ ReopenDuration *string `yaml:"reopen_duration,omitempty" json:"reopen_duration,omitempty" hcl:"reopen_duration"`
+ DedupKeyFieldName *string `yaml:"dedup_key_field,omitempty" json:"dedup_key_field,omitempty" hcl:"dedup_key_field"`
+ Fields *map[string]any `yaml:"fields,omitempty" json:"fields,omitempty" hcl:"fields"`
+
+ User *Secret `yaml:"user,omitempty" json:"user,omitempty" hcl:"user"`
+ Password *Secret `yaml:"password,omitempty" json:"password,omitempty" hcl:"password"`
+ Token *Secret `yaml:"api_token,omitempty" json:"api_token,omitempty" hcl:"api_token"`
+}
+
type KafkaIntegration struct {
DisableResolveMessage *bool `json:"-" yaml:"-" hcl:"disable_resolve_message"`
@@ -321,6 +344,7 @@ type ContactPoint struct {
Discord []DiscordIntegration `json:"discord" yaml:"discord" hcl:"discord,block"`
Email []EmailIntegration `json:"email" yaml:"email" hcl:"email,block"`
Googlechat []GooglechatIntegration `json:"googlechat" yaml:"googlechat" hcl:"googlechat,block"`
+ Jira []JiraIntegration `json:"jira" yaml:"jira" hcl:"jira,block"`
Kafka []KafkaIntegration `json:"kafka" yaml:"kafka" hcl:"kafka,block"`
Line []LineIntegration `json:"line" yaml:"line" hcl:"line,block"`
Mqtt []MqttIntegration `json:"mqtt" yaml:"mqtt" hcl:"mqtt,block"`
diff --git a/pkg/services/ngalert/notifier/channels_config/available_channels.go b/pkg/services/ngalert/notifier/channels_config/available_channels.go
index e1748a7550b..a64c641a40e 100644
--- a/pkg/services/ngalert/notifier/channels_config/available_channels.go
+++ b/pkg/services/ngalert/notifier/channels_config/available_channels.go
@@ -5,6 +5,7 @@ import (
"os"
"strings"
+ "github.com/grafana/alerting/receivers/jira"
alertingMqtt "github.com/grafana/alerting/receivers/mqtt"
alertingOpsgenie "github.com/grafana/alerting/receivers/opsgenie"
alertingPagerduty "github.com/grafana/alerting/receivers/pagerduty"
@@ -365,7 +366,7 @@ func GetAvailableNotifiers() []*NotifierPlugin {
InputType: InputTypeText,
PropertyName: "details",
},
- { //New in 11.1
+ { // New in 11.1
Label: "URL",
Description: "The URL to send API requests to",
Element: ElementTypeInput,
@@ -1708,6 +1709,154 @@ func GetAvailableNotifiers() []*NotifierPlugin {
},
},
},
+ { // Since Grafana 11.6
+ Type: "jira",
+ Name: "Jira",
+ Description: "Creates Jira issues from alerts",
+ Heading: "Jira settings",
+ Options: []NotifierOption{
+ {
+ Label: "API URL of Jira instance, including version of API",
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: "https://grafana.atlassian.net/rest/api/3",
+ PropertyName: "api_url",
+ Description: "Supported v2 or v3 APIs",
+ Required: true,
+ },
+ {
+ Label: "HTTP Basic Authentication - Username",
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ PropertyName: "user",
+ Description: "Username to use for Jira authentication.",
+ Secure: true,
+ Required: false,
+ },
+ {
+ Label: "HTTP Basic Authentication - Password",
+ Element: ElementTypeInput,
+ InputType: InputTypePassword,
+ PropertyName: "password",
+ // Go to https://id.atlassian.com/manage-profile/security/api-tokens to obtain a token.
+ Description: "Password to use for Jira authentication.",
+ Secure: true,
+ Required: false,
+ },
+ {
+ Label: "Authorization Header - Personal Access Token",
+ Element: ElementTypeInput,
+ InputType: InputTypePassword,
+ PropertyName: "api_token",
+ // Go to https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html for how to obtain a token.
+ Description: "Personal Access Token that is used as a bearer authorization header.",
+ Secure: true,
+ Required: false,
+ },
+ {
+ Label: "Project Key",
+ Description: "The project key associated with the relevant Jira project",
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: "Grafana",
+ PropertyName: "project",
+ Required: true,
+ },
+ {
+ Label: "Issue Type",
+ Description: "The type of the Jira issue (e.g., Bug, Task, Story). You can use templates to customize this field.",
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: "Task",
+ Required: true,
+ PropertyName: "issue_type",
+ },
+ {
+ Label: "Summary",
+ Description: fmt.Sprintf("The summary of the Jira issue. You can use templates to customize this field. Maximum length is %d characters.", jira.MaxSummaryLenRunes),
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: jira.DefaultSummary,
+ PropertyName: "summary",
+ },
+ {
+ Label: "Description",
+ Description: fmt.Sprintf("The description of the Jira issue. You can use templates to customize this field. Maximum length is %d characters.", jira.MaxDescriptionLenRunes),
+ Element: ElementTypeTextArea,
+ InputType: InputTypeText,
+ Placeholder: jira.DefaultDescription,
+ PropertyName: "description",
+ },
+ {
+ Label: "Labels",
+ Description: "Labels to assign to the Jira issue. You can use templates to customize this field.",
+ Element: ElementStringArray,
+ Placeholder: "",
+ PropertyName: "labels",
+ },
+ {
+ Label: "Priority",
+ Description: "The priority of the Jira issue (e.g., High, Medium, Low). You can use templates to customize this field.",
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: jira.DefaultPriority,
+ PropertyName: "priority",
+ Required: false,
+ },
+ {
+ Label: "Resolve Transition",
+ Description: `Name of the workflow transition to resolve an issue. The target status must have the category "done". If not set, the issue will not be resolved.`,
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: "",
+ PropertyName: "resolve_transition",
+ Required: false,
+ },
+ {
+ Label: "Reopen Transition",
+ Description: `Name of the workflow transition to resolve an issue. The target status must not have the category "done". If not set, the issue will not be reopened.`,
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: "",
+ PropertyName: "reopen_transition",
+ Required: false,
+ },
+ {
+ Label: "Reopen Duration",
+ Description: "Reopen the issue when it is not older than this value in minutes. Otherwise, create a new issue.",
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: "10m",
+ PropertyName: "reopen_duration",
+ },
+ {
+ Label: "\"Won't fix\" Transition",
+ Description: `If reopen transition is defined, ignore issues with that resolution.`,
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: "",
+ PropertyName: "wont_fix_resolution",
+ Required: false,
+ },
+ {
+ Label: "Custom field ID for deduplication",
+ Description: "Id of the custom field where the deduplication key should be stored. Otherwise, it is added to labels in format 'ALERT($KEY).'",
+ Element: ElementTypeInput,
+ InputType: InputTypeText,
+ Placeholder: "10000",
+ ValidationRule: "^[0-9]+$",
+ PropertyName: "dedup_key_field",
+ },
+ {
+ Label: "Custom Field Data",
+ Description: "Custom field data to set on the Jira issue.",
+ Element: ElementTypeKeyValueMap,
+ InputType: InputTypeText,
+ Placeholder: "",
+ PropertyName: "fields",
+ },
+ },
+ },
}
}
diff --git a/pkg/services/ngalert/notifier/channels_config/available_channels_test.go b/pkg/services/ngalert/notifier/channels_config/available_channels_test.go
index 5e305cb1224..cc2defa2c80 100644
--- a/pkg/services/ngalert/notifier/channels_config/available_channels_test.go
+++ b/pkg/services/ngalert/notifier/channels_config/available_channels_test.go
@@ -27,20 +27,38 @@ func TestGetSecretKeysForContactPointType(t *testing.T) {
{receiverType: "prometheus-alertmanager", expectedSecretFields: []string{"basicAuthPassword"}},
{receiverType: "discord", expectedSecretFields: []string{"url"}},
{receiverType: "googlechat", expectedSecretFields: []string{"url"}},
- {receiverType: "line", expectedSecretFields: []string{"token"}},
+ {receiverType: "LINE", expectedSecretFields: []string{"token"}},
{receiverType: "threema", expectedSecretFields: []string{"api_secret"}},
{receiverType: "opsgenie", expectedSecretFields: []string{"apiKey"}},
{receiverType: "webex", expectedSecretFields: []string{"bot_token"}},
{receiverType: "sns", expectedSecretFields: []string{"sigv4.access_key", "sigv4.secret_key"}},
+ {receiverType: "mqtt", expectedSecretFields: []string{"password", "tlsConfig.caCertificate", "tlsConfig.clientCertificate", "tlsConfig.clientKey"}},
+ {receiverType: "jira", expectedSecretFields: []string{"user", "password", "api_token"}},
}
+ n := GetAvailableNotifiers()
+ allTypes := make(map[string]struct{}, len(n))
+ for _, plugin := range n {
+ allTypes[plugin.Type] = struct{}{}
+ }
+
for _, testCase := range testCases {
+ delete(allTypes, testCase.receiverType)
t.Run(testCase.receiverType, func(t *testing.T) {
got, err := GetSecretKeysForContactPointType(testCase.receiverType)
require.NoError(t, err)
- t.Logf("got secret fields: %#v", got)
require.ElementsMatch(t, testCase.expectedSecretFields, got)
})
}
+
+ for integrationType := range allTypes {
+ t.Run(integrationType, func(t *testing.T) {
+ got, err := GetSecretKeysForContactPointType(integrationType)
+ require.NoError(t, err)
+ require.Emptyf(t, got, "secret keys for %s should be empty", integrationType)
+ })
+ }
+
+ require.Emptyf(t, allTypes, "not all types are covered: %s", allTypes)
}
func Test_getSecretFields(t *testing.T) {
diff --git a/pkg/services/ngalert/notifier/channels_config/plugin.go b/pkg/services/ngalert/notifier/channels_config/plugin.go
index f390ee1d9fc..5a8b7527604 100644
--- a/pkg/services/ngalert/notifier/channels_config/plugin.go
+++ b/pkg/services/ngalert/notifier/channels_config/plugin.go
@@ -45,6 +45,8 @@ const (
ElementTypeSubform = "subform"
// ElementSubformArray will render a multiple sub-forms with schema defined in SubformOptions
ElementSubformArray = "subform_array"
+ // ElementStringArray will render a set of fields to manage an array of strings.
+ ElementStringArray = "string_array"
)
// InputType is the type of input that can be rendered in the frontend.
diff --git a/pkg/services/ngalert/provisioning/contactpoints_test.go b/pkg/services/ngalert/provisioning/contactpoints_test.go
index 7a8c5e5bd10..cab8dd42400 100644
--- a/pkg/services/ngalert/provisioning/contactpoints_test.go
+++ b/pkg/services/ngalert/provisioning/contactpoints_test.go
@@ -423,6 +423,9 @@ func TestRemoveSecretsForContactPoint(t *testing.T) {
"webhook": func(settings map[string]any) { // add additional field to the settings because valid config does not allow it to be specified along with password
settings["authorization_credentials"] = "test-authz-creds"
},
+ "jira": func(settings map[string]any) { // add additional field to the settings because valid config does not allow it to be specified along with password
+ settings["api_token"] = "test-token"
+ },
}
configs := notify.AllKnownConfigsForTesting
diff --git a/pkg/storage/unified/apistore/go.mod b/pkg/storage/unified/apistore/go.mod
index d99962d0d35..16380887a73 100644
--- a/pkg/storage/unified/apistore/go.mod
+++ b/pkg/storage/unified/apistore/go.mod
@@ -192,7 +192,7 @@ require (
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
- github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0 // indirect
+ github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb // indirect
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 // indirect
github.com/grafana/dataplane/sdata v0.0.9 // indirect
github.com/grafana/dskit v0.0.0-20241105154643-a6b453a88040 // indirect
diff --git a/pkg/storage/unified/apistore/go.sum b/pkg/storage/unified/apistore/go.sum
index 4d78ed949da..40c89cf0360 100644
--- a/pkg/storage/unified/apistore/go.sum
+++ b/pkg/storage/unified/apistore/go.sum
@@ -566,8 +566,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0 h1:LGH+tVzHCDrR9hsltmkP4jmNRg5IreQw5CNFbJKlnts=
-github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
+github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb h1:WfCsiuZXhGXIdzImQ9/Kjfn9M4e6f7z5mddcSKCRxmI=
+github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 h1:NTMmow+74I3Jb033xhbRgWQS7A//5TDhiM4tl7bsVP4=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7/go.mod h1:T3X4z0ejGfJOiOmZLFeKCRT/yxWJq/RtclAc/PHj/w4=
github.com/grafana/authlib/types v0.0.0-20250219092154-21ce22b49f31 h1:EokLC5grHwLPs4tXW8T6E8187H1e5G9AP0QQ5B60HbA=
diff --git a/pkg/storage/unified/resource/go.mod b/pkg/storage/unified/resource/go.mod
index 57c54262114..f2ab921a4f6 100644
--- a/pkg/storage/unified/resource/go.mod
+++ b/pkg/storage/unified/resource/go.mod
@@ -117,7 +117,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/mux v1.8.1 // indirect
- github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0 // indirect
+ github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb // indirect
github.com/grafana/dataplane/sdata v0.0.9 // indirect
github.com/grafana/grafana-app-sdk/logging v0.30.0 // indirect
github.com/grafana/grafana-aws-sdk v0.31.5 // indirect
diff --git a/pkg/storage/unified/resource/go.sum b/pkg/storage/unified/resource/go.sum
index 9ee7f749839..40fcf6f458a 100644
--- a/pkg/storage/unified/resource/go.sum
+++ b/pkg/storage/unified/resource/go.sum
@@ -397,8 +397,8 @@ github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z
github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
-github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0 h1:LGH+tVzHCDrR9hsltmkP4jmNRg5IreQw5CNFbJKlnts=
-github.com/grafana/alerting v0.0.0-20250219153626-c475b1a572b0/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
+github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb h1:WfCsiuZXhGXIdzImQ9/Kjfn9M4e6f7z5mddcSKCRxmI=
+github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 h1:NTMmow+74I3Jb033xhbRgWQS7A//5TDhiM4tl7bsVP4=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7/go.mod h1:T3X4z0ejGfJOiOmZLFeKCRT/yxWJq/RtclAc/PHj/w4=
github.com/grafana/authlib/types v0.0.0-20250219092154-21ce22b49f31 h1:EokLC5grHwLPs4tXW8T6E8187H1e5G9AP0QQ5B60HbA=
diff --git a/pkg/tests/apis/alerting/notifications/receivers/receiver_test.go b/pkg/tests/apis/alerting/notifications/receivers/receiver_test.go
index 283d996f177..c483b6938ae 100644
--- a/pkg/tests/apis/alerting/notifications/receivers/receiver_test.go
+++ b/pkg/tests/apis/alerting/notifications/receivers/receiver_test.go
@@ -1392,9 +1392,15 @@ func TestIntegrationCRUD(t *testing.T) {
t.Run("should return secrets in secureFields but not settings", func(t *testing.T) {
for _, integration := range get.Spec.Integrations {
t.Run(integration.Type, func(t *testing.T) {
+ expected := notify.AllKnownConfigsForTesting[strings.ToLower(integration.Type)]
+ var fields map[string]any
+ require.NoError(t, json.Unmarshal([]byte(expected.Config), &fields))
secretFields, err := channels_config.GetSecretKeysForContactPointType(integration.Type)
require.NoError(t, err)
for _, field := range secretFields {
+ if _, ok := fields[field]; !ok { // skip field that is not in the original setting
+ continue
+ }
assert.Contains(t, integration.SecureFields, field)
assert.Truef(t, integration.SecureFields[field], "secure field should be always true")
From bfc234779930af778bf7c2effd7c9a3381d4dc13 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 21 Feb 2025 13:04:21 -0500
Subject: [PATCH 16/22] Bump github.com/go-sourcemap/sourcemap from
2.1.3+incompatible to 2.1.4+incompatible (#98639)
Bump github.com/go-sourcemap/sourcemap
Bumps [github.com/go-sourcemap/sourcemap](https://github.com/go-sourcemap/sourcemap) from 2.1.3+incompatible to 2.1.4+incompatible.
- [Commits](https://github.com/go-sourcemap/sourcemap/compare/v2.1.3...v2.1.4)
---
updated-dependencies:
- dependency-name: github.com/go-sourcemap/sourcemap
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
go.mod | 2 +-
go.sum | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/go.mod b/go.mod
index c9a91001aec..744aa4d529e 100644
--- a/go.mod
+++ b/go.mod
@@ -54,7 +54,7 @@ require (
github.com/go-openapi/runtime v0.28.0 // @grafana/alerting-backend
github.com/go-openapi/strfmt v0.23.0 // @grafana/alerting-backend
github.com/go-redis/redis/v8 v8.11.5 // @grafana/grafana-backend-group
- github.com/go-sourcemap/sourcemap v2.1.3+incompatible // @grafana/grafana-backend-group
+ github.com/go-sourcemap/sourcemap v2.1.4+incompatible // @grafana/grafana-backend-group
github.com/go-sql-driver/mysql v1.8.1 // @grafana/grafana-search-and-storage
github.com/go-stack/stack v1.8.1 // @grafana/grafana-backend-group
github.com/gobwas/glob v0.2.3 // @grafana/grafana-backend-group
diff --git a/go.sum b/go.sum
index a467f87cba7..85c8855cce6 100644
--- a/go.sum
+++ b/go.sum
@@ -1281,8 +1281,8 @@ github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-resty/resty/v2 v2.15.3 h1:bqff+hcqAflpiF591hhJzNdkRsFhlB96CYfBwSFvql8=
github.com/go-resty/resty/v2 v2.15.3/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
-github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
-github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
+github.com/go-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q=
+github.com/go-sourcemap/sourcemap v2.1.4+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
From 9780a9c49fd312da2d9df6210c66ae0bac0caf7a Mon Sep 17 00:00:00 2001
From: Larissa Wandzura <126723338+lwandz13@users.noreply.github.com>
Date: Fri, 21 Feb 2025 13:09:04 -0600
Subject: [PATCH 17/22] Docs: Overhaul of PostgreSQL data source documenation
(#99908)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* created new topic docs
* added info to config doc
* updates to config doc
* updates to config doc
* finished config doc
* updated Query editor doc
* final edits
* rename, ref URI work
* a few more updates prior to PR issue
* fixed the double Macros heading issue
* final edits and cleanup
* edits based on feedback
* ran prettier
* added updates
* updates based on feedback
* vale linter issues
* more vale linting issues addressed
* small addition on main page
* ran prettier again
* changed title
* Update docs/sources/datasources/postgres/query-editor/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/configure/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/configure/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/query-editor/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/configure/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/configure/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/configure/_index.md
Co-authored-by: Jack Baldry
* changed Grafana's
* added changes
* Update docs/sources/datasources/postgres/query-editor/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/query-editor/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/query-editor/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/query-editor/_index.md
Co-authored-by: Jack Baldry
* Update docs/sources/datasources/postgres/query-editor/_index.md
Co-authored-by: Jack Baldry
* ran prettier again
* Remove aliases
Signed-off-by: Jack Baldry
* Fix link
Signed-off-by: Jack Baldry
* Put code in `code`
Signed-off-by: Jack Baldry
* Avoid bold for emphasis
Signed-off-by: Jack Baldry
* Fix link
Signed-off-by: Jack Baldry
---------
Signed-off-by: Jack Baldry
Co-authored-by: Irene Rodríguez
Co-authored-by: Jack Baldry
---
docs/sources/datasources/postgres/_index.md | 524 ++----------------
.../datasources/postgres/configure/_index.md | 194 +++++++
.../postgres/query-editor/_index.md | 410 ++++++++++++++
3 files changed, 642 insertions(+), 486 deletions(-)
create mode 100644 docs/sources/datasources/postgres/configure/_index.md
create mode 100644 docs/sources/datasources/postgres/query-editor/_index.md
diff --git a/docs/sources/datasources/postgres/_index.md b/docs/sources/datasources/postgres/_index.md
index 3489b760f70..868a2bb7d9e 100644
--- a/docs/sources/datasources/postgres/_index.md
+++ b/docs/sources/datasources/postgres/_index.md
@@ -2,7 +2,7 @@
aliases:
- ../data-sources/postgres/
- ../features/datasources/postgres/
-description: Guide for using PostgreSQL in Grafana
+description: Introduction to the PostgreSQL data source in Grafana.
keywords:
- grafana
- postgresql
@@ -16,506 +16,58 @@ menuTitle: PostgreSQL
title: PostgreSQL data source
weight: 1200
refs:
- provisioning-data-sources:
- - pattern: /docs/grafana/
- destination: /docs/grafana//administration/provisioning/#datasources
- - pattern: /docs/grafana-cloud/
- destination: /docs/grafana//administration/provisioning/#datasources
- variables:
- - pattern: /docs/grafana/
- destination: /docs/grafana//dashboards/variables/
- - pattern: /docs/grafana-cloud/
- destination: /docs/grafana//dashboards/variables/
- add-template-variables-interval-ms:
- - pattern: /docs/grafana/
- destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval_ms
- - pattern: /docs/grafana-cloud/
- destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval_ms
- add-template-variables-interval:
- - pattern: /docs/grafana/
- destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval
- - pattern: /docs/grafana-cloud/
- destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval
annotate-visualizations:
- pattern: /docs/grafana/
destination: /docs/grafana//dashboards/build-dashboards/annotate-visualizations/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana//dashboards/build-dashboards/annotate-visualizations/
- configure-standard-options-display-name:
+ configure-postgres-data-source:
- pattern: /docs/grafana/
- destination: /docs/grafana//panels-visualizations/configure-standard-options/#display-name
+ destination: /docs/grafana//datasources/postgres/configure/
- pattern: /docs/grafana-cloud/
- destination: /docs/grafana//panels-visualizations/configure-standard-options/#display-name
- data-source-management:
+ destination: /docs/grafana//datasources/postgres/configure/
+ postgres-query-editor:
- pattern: /docs/grafana/
- destination: /docs/grafana//administration/data-source-management/
+ destination: /docs/grafana//datasources/postgres/query-editor/
- pattern: /docs/grafana-cloud/
- destination: /docs/grafana//administration/data-source-management/
- variable-syntax-advanced-variable-format-options:
+ destination: /docs/grafana//datasources/postgres/query-editor/
+ alerting:
- pattern: /docs/grafana/
- destination: /docs/grafana//dashboards/variables/variable-syntax/#advanced-variable-format-options
+ destination: /docs/grafana//alerting/
- pattern: /docs/grafana-cloud/
- destination: /docs/grafana//dashboards/variables/variable-syntax/#advanced-variable-format-options
+ destination: /docs/grafana-cloud/alerting-and-irm/alerting/
+ transformations:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//panels-visualizations/query-transform-data/transform-data/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana-cloud/visualizations/panels-visualizations/query-transform-data/transform-data/
+ visualizations:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//panels-visualizations/visualizations/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana-cloud/visualizations/panels-visualizations/visualizations/
---
# PostgreSQL data source
-Grafana ships with a built-in PostgreSQL data source plugin that allows you to query and visualize data from a PostgreSQL compatible database.
+Grafana includes a built-in PostgreSQL data source plugin, enabling you to query and visualize data from any PostgreSQL-compatible database. You don't need to install a plugin to add the PostgreSQL data source to your Grafana instance.
-For instructions on how to add a data source to Grafana, refer to the [administration documentation](ref:data-source-management).
-Only users with the organization administrator role can add data sources.
-Administrators can also [configure the data source via YAML](#provision-the-data-source) with Grafana's provisioning system.
+Grafana offers several configuration options for this data source as well as a visual and code-based query editor.
+
+## Get started with the PostgreSQL data source
+
+The following documents will help you get started with the PostgreSQL data source in Grafana:
+
+- [Configure the PostgreSQL data source](ref:configure-postgres-data-source)
+- [PostgreSQL query editor](ref:postgres-query-editor)
+
+After you have configured the data source you can:
+
+- Create a variety of [visualizations](ref:visualizations)
+- Add [annotations](ref:annotate-visualizations)
+- Set up [alerting](ref:alerting)
+- Add [transformations](ref:transformations)
+
+View a PostgreSQL overview on Grafana Play:
{{< docs/play title="PostgreSQL Overview" url="https://play.grafana.org/d/ddvpgdhiwjvuod/postgresql-overview" >}}
-
-## PostgreSQL settings
-
-To configure basic settings for the data source, complete the following steps:
-
-1. Click **Connections** in the left-side menu.
-1. Under Your connections, click **Data sources**.
-1. Enter `PostgreSQL` in the search bar.
-1. Select **PostgreSQL**.
-
- The **Settings** tab of the data source is displayed.
-
-1. Set the data source's basic configuration options:
-
-| Name | Description |
-| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **Name** | The data source name. This is how you refer to the data source in panels and queries. |
-| **Default** | Default data source means that it will be pre-selected for new panels. |
-| **Host** | The IP address/hostname and optional port of your PostgreSQL instance. _Do not_ include the database name. The connection string for connecting to Postgres will not be correct and it may cause errors. |
-| **Database** | Name of your PostgreSQL database. |
-| **User** | Database user's login/username |
-| **Password** | Database user's password |
-| **SSL Mode** | Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. When SSL Mode is disabled, SSL Method and Auth Details would not be visible. |
-| **SSL Auth Details Method** | Determines whether the SSL Auth details will be configured as a file path or file content. |
-| **SSL Auth Details Value** | File path or file content of SSL root certificate, client certificate and client key |
-| **Max open** | The maximum number of open connections to the database, default `100`. |
-| **Max idle** | The maximum number of connections in the idle connection pool, default `100`. |
-| **Auto (max idle)** | If set will set the maximum number of idle connections to the number of maximum open connections. Default is `true`. |
-| **Max lifetime** | The maximum amount of time in seconds a connection may be reused, default `14400`/4 hours. |
-| **Version** | Determines which functions are available in the query builder. |
-| **TimescaleDB** | A time-series database built as a PostgreSQL extension. When enabled, Grafana uses `time_bucket` in the `$__timeGroup` macro to display TimescaleDB specific aggregate functions in the query builder. For more information, see [TimescaleDB documentation](https://docs.timescale.com/timescaledb/latest/tutorials/grafana/grafana-timescalecloud/#connect-timescaledb-and-grafana). |
-
-### Min time interval
-
-A lower limit for the [`$__interval`](ref:add-template-variables-interval) and [`$__interval_ms`](ref:add-template-variables-interval-ms) variables.
-Recommended to be set to write frequency, for example `1m` if your data is written every minute.
-This option can also be overridden/configured in a dashboard panel under data source options. It's important to note that this value **needs** to be formatted as a
-number followed by a valid time identifier, e.g. `1m` (1 minute) or `30s` (30 seconds). The following time identifiers are supported:
-
-| Identifier | Description |
-| ---------- | ----------- |
-| `y` | year |
-| `M` | month |
-| `w` | week |
-| `d` | day |
-| `h` | hour |
-| `m` | minute |
-| `s` | second |
-| `ms` | millisecond |
-
-### Database user permissions (Important!)
-
-The database user you specify when you add the data source should only be granted SELECT permissions on
-the specified database and tables you want to query. Grafana does not validate that the query is safe. The query
-could include any SQL statement. For example, statements like `DELETE FROM user;` and `DROP TABLE user;` would be
-executed. To protect against this we **highly** recommend you create a specific PostgreSQL user with restricted permissions.
-
-Example:
-
-```sql
- CREATE USER grafanareader WITH PASSWORD 'password';
- GRANT USAGE ON SCHEMA schema TO grafanareader;
- GRANT SELECT ON schema.table TO grafanareader;
-```
-
-Make sure the user does not get any unwanted privileges from the public role.
-
-## Query builder
-
-{{< figure src="/static/img/docs/screenshot-postgres-query-editor.png" class="docs-image--no-shadow" caption="PostgreSQL query builder" >}}
-
-The PostgreSQL query builder is available when editing a panel using a PostgreSQL data source. The built query can be run by pressing the `Run query` button in the top right corner of the editor.
-
-### Format
-
-The response from PostgreSQL can be formatted as either a table or as a time series. To use the time series format one of the columns must be named `time`.
-
-### Dataset and table selection
-
-The dataset dropdown will be populated with the configured database to which the user has access.
-The table dropdown is populated with the tables that are available within that database.
-
-### Columns and Aggregation functions (SELECT)
-
-Using the dropdown, select a column to include in the data. You can also specify an optional aggregation function.
-
-Add further value columns by clicking the plus button and another column dropdown appears.
-
-{{< docs/shared source="grafana" lookup="datasources/sql-query-builder-macros.md" version="" >}}
-
-### Filter data (WHERE)
-
-To add a filter, toggle the **Filter** switch at the top of the editor.
-This reveals a **Filter by column value** section with two dropdown selectors.
-
-Use the first dropdown to choose whether all of the filters need to match (`AND`), or if only one of the filters needs to match (`OR`).
-Use the second dropdown to choose a filter.
-
-To filter on more columns, click the plus (`+`) button to the right of the condition dropdown.
-
-To remove a filter, click the `x` button next to that filter's dropdown.
-
-After selecting a date type column, you can choose Macros from the operators list and select timeFilter which will add the $\_\_timeFilter macro to the query with the selected date column.
-
-### Group By
-
-To group the results by column, flip the group switch at the top of the editor. You can then choose which column to group the results by. The group by clause can be removed by pressing the X button.
-
-### Preview
-
-By flipping the preview switch at the top of the editor, you can get a preview of the SQL query generated by the query builder.
-
-### Provision the data source
-
-It's now possible to configure data sources using config files with Grafana's provisioning system. You can read more about how it works and all the settings you can set for data sources on the [provisioning docs page](ref:provisioning-data-sources).
-
-#### Provisioning example
-
-```yaml
-apiVersion: 1
-
-datasources:
- - name: Postgres
- type: postgres
- url: localhost:5432
- user: grafana
- secureJsonData:
- password: 'Password!'
- jsonData:
- database: grafana
- sslmode: 'disable' # disable/require/verify-ca/verify-full
- maxOpenConns: 100
- maxIdleConns: 100
- maxIdleConnsAuto: true
- connMaxLifetime: 14400
- postgresVersion: 903 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
- timescaledb: false
-```
-
-{{% admonition type="note" %}}
-In the above code, the `postgresVersion` value of `10` refers to version PostgreSQL 10 and above.
-{{% /admonition %}}
-
-#### Troubleshoot provisioning
-
-If you encounter metric request errors or other issues:
-
-- Make sure your data source YAML file parameters exactly match the example. This includes parameter names and use of quotation marks.
-- Make sure the `database` name is not included in the `url`.
-
-## Code editor
-
-{{< figure src="/static/img/docs/v92/sql_code_editor.png" class="docs-image--no-shadow" >}}
-
-To make advanced queries, switch to the code editor by clicking `code` in the top right corner of the editor. The code editor support autocompletion of tables, columns, SQL keywords, standard sql functions, Grafana template variables and Grafana macros. Columns cannot be completed before a table has been specified.
-
-You can expand the code editor by pressing the `chevron` pointing downwards in the lower right corner of the code editor.
-
-`CTRL/CMD + Return` works as a keyboard shortcut to run the query.
-
-## Macros
-
-Macros can be used within a query to simplify syntax and allow for dynamic parts.
-
-| Macro example | Description |
-| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| `$__time(dateColumn)` | Will be replaced by an expression to convert to a UNIX timestamp and rename the column to `time_sec`. For example, _UNIX_TIMESTAMP(dateColumn) as time_sec_ |
-| `$__timeEpoch(dateColumn)` | Will be replaced by an expression to convert to a UNIX timestamp and rename the column to `time_sec`. For example, _UNIX_TIMESTAMP(dateColumn) as time_sec_ |
-| `$__timeFilter(dateColumn)` | Will be replaced by a time range filter using the specified column name. For example, _dateColumn BETWEEN FROM_UNIXTIME(1494410783) AND FROM_UNIXTIME(1494410983)_ |
-| `$__timeFrom()` | Will be replaced by the start of the currently active time selection. For example, _FROM_UNIXTIME(1494410783)_ |
-| `$__timeTo()` | Will be replaced by the end of the currently active time selection. For example, _FROM_UNIXTIME(1494410983)_ |
-| `$__timeGroup(dateColumn,'5m')` | Will be replaced by an expression usable in GROUP BY clause. For example, *cast(cast(UNIX_TIMESTAMP(dateColumn)/(300) as signed)*300 as signed),\* |
-| `$__timeGroup(dateColumn,'5m', 0)` | Same as above but with a fill parameter so missing points in that series will be added by grafana and 0 will be used as value (only works with time series queries). |
-| `$__timeGroup(dateColumn,'5m', NULL)` | Same as above but NULL will be used as value for missing points (only works with time series queries). |
-| `$__timeGroup(dateColumn,'5m', previous)` | Same as above but the previous value in that series will be used as fill value if no value has been seen yet NULL will be used (only works with time series queries). |
-| `$__timeGroupAlias(dateColumn,'5m')` | Will be replaced identical to $\_\_timeGroup but with an added column alias. |
-| `$__unixEpochFilter(dateColumn)` | Will be replaced by a time range filter using the specified column name with times represented as Unix timestamp. For example, _dateColumn > 1494410783 AND dateColumn < 1494497183_ |
-| `$__unixEpochFrom()` | Will be replaced by the start of the currently active time selection as Unix timestamp. For example, _1494410783_ |
-| `$__unixEpochTo()` | Will be replaced by the end of the currently active time selection as Unix timestamp. For example, _1494497183_ |
-| `$__unixEpochNanoFilter(dateColumn)` | Will be replaced by a time range filter using the specified column name with times represented as nanosecond timestamp. For example, _dateColumn > 1494410783152415214 AND dateColumn < 1494497183142514872_ |
-| `$__unixEpochNanoFrom()` | Will be replaced by the start of the currently active time selection as nanosecond timestamp. For example, _1494410783152415214_ |
-| `$__unixEpochNanoTo()` | Will be replaced by the end of the currently active time selection as nanosecond timestamp. For example, _1494497183142514872_ |
-| `$__unixEpochGroup(dateColumn,'5m', [fillmode])` | Same as $\_\_timeGroup but for times stored as Unix timestamp (`fillMode` only works with time series queries). |
-| `$__unixEpochGroupAlias(dateColumn,'5m', [fillmode])` | Same as above but also adds a column alias (`fillMode` only works with time series queries). |
-
-## Table queries
-
-If the `Format as` query option is set to `Table` then you can basically do any type of SQL query. The table panel will automatically show the results of whatever columns and rows your query returns.
-
-Query editor with example query:
-
-
-
-The query:
-
-```sql
-SELECT
- title as "Title",
- "user".login as "Created By",
- dashboard.created as "Created On"
-FROM dashboard
-INNER JOIN "user" on "user".id = dashboard.created_by
-WHERE $__timeFilter(dashboard.created)
-```
-
-You can control the name of the Table panel columns by using regular `as ` SQL column selection syntax.
-
-The resulting table panel:
-
-
-
-## Time series queries
-
-If you set Format as to _Time series_, then the query must have a column named time that returns either a SQL datetime or any numeric datatype representing Unix epoch in seconds. In addition, result sets of time series queries must be sorted by time for panels to properly visualize the result.
-
-A time series query result is returned in a [wide data frame format](https://grafana.com/developers/plugin-tools/key-concepts/data-frames#wide-format). Any column except time or of type string transforms into value fields in the data frame query result. Any string column transforms into field labels in the data frame query result.
-
-> For backward compatibility, there's an exception to the above rule for queries that return three columns including a string column named metric. Instead of transforming the metric column into field labels, it becomes the field name, and then the series name is formatted as the value of the metric column. See the example with the metric column below.
-
-To optionally customize the default series name formatting, refer to [Standard options definitions](ref:configure-standard-options-display-name).
-
-**Example with `metric` column:**
-
-```sql
-SELECT
- $__timeGroupAlias("time_date_time",'5m'),
- min("value_double"),
- 'min' as metric
-FROM test_data
-WHERE $__timeFilter("time_date_time")
-GROUP BY time
-ORDER BY time
-```
-
-Data frame result:
-
-```text
-+---------------------+-----------------+
-| Name: time | Name: min |
-| Labels: | Labels: |
-| Type: []time.Time | Type: []float64 |
-+---------------------+-----------------+
-| 2020-01-02 03:05:00 | 3 |
-| 2020-01-02 03:10:00 | 6 |
-+---------------------+-----------------+
-```
-
-**Example using the fill parameter in the $\_\_timeGroupAlias macro to convert null values to be zero instead:**
-
-```sql
-SELECT
- $__timeGroupAlias("createdAt",'5m',0),
- sum(value) as value,
- hostname
-FROM test_data
-WHERE
- $__timeFilter("createdAt")
-GROUP BY time, hostname
-ORDER BY time
-```
-
-Given the data frame result in the following example and using the graph panel, you will get two series named _value 10.0.1.1_ and _value 10.0.1.2_. To render the series with a name of _10.0.1.1_ and _10.0.1.2_ , use a [Standard options definitions](ref:configure-standard-options-display-name) display value of `${__field.labels.hostname}`.
-
-Data frame result:
-
-```text
-+---------------------+---------------------------+---------------------------+
-| Name: time | Name: value | Name: value |
-| Labels: | Labels: hostname=10.0.1.1 | Labels: hostname=10.0.1.2 |
-| Type: []time.Time | Type: []float64 | Type: []float64 |
-+---------------------+---------------------------+---------------------------+
-| 2020-01-02 03:05:00 | 3 | 4 |
-| 2020-01-02 03:10:00 | 6 | 7 |
-+---------------------+---------------------------+---------------------------+
-```
-
-**Example with multiple columns:**
-
-```sql
-SELECT
- $__timeGroupAlias("time_date_time",'5m'),
- min("value_double") as "min_value",
- max("value_double") as "max_value"
-FROM test_data
-WHERE $__timeFilter("time_date_time")
-GROUP BY time
-ORDER BY time
-```
-
-Data frame result:
-
-```text
-+---------------------+-----------------+-----------------+
-| Name: time | Name: min_value | Name: max_value |
-| Labels: | Labels: | Labels: |
-| Type: []time.Time | Type: []float64 | Type: []float64 |
-+---------------------+-----------------+-----------------+
-| 2020-01-02 03:04:00 | 3 | 4 |
-| 2020-01-02 03:05:00 | 6 | 7 |
-+---------------------+-----------------+-----------------+
-```
-
-## Templating
-
-Instead of hard-coding things like server, application and sensor name in your metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard.
-
-Refer to [Templates and variables](ref:variables) for an introduction to the templating feature and the different types of template variables.
-
-### Query variable
-
-If you add a template variable of the type `Query`, you can write a PostgreSQL query that can
-return things like measurement names, key names or key values that are shown as a dropdown select box.
-
-For example, you can have a variable that contains all values for the `hostname` column in a table if you specify a query like this in the templating variable _Query_ setting.
-
-```sql
-SELECT hostname FROM host
-```
-
-A query can return multiple columns and Grafana will automatically create a list from them. For example, the query below will return a list with values from `hostname` and `hostname2`.
-
-```sql
-SELECT host.hostname, other_host.hostname2 FROM host JOIN other_host ON host.city = other_host.city
-```
-
-To use time range dependent macros like `$__timeFilter(column)` in your query the refresh mode of the template variable needs to be set to _On Time Range Change_.
-
-```sql
-SELECT event_name FROM event_log WHERE $__timeFilter(time_column)
-```
-
-Another option is a query that can create a key/value variable. The query should return two columns that are named `__text` and `__value`. The `__text` column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with `hostname` as the text and `id` as the value:
-
-```sql
-SELECT hostname AS __text, id AS __value FROM host
-```
-
-You can also create nested variables. Using a variable named `region`, you could have
-the hosts variable only show hosts from the current selected region with a query like this (if `region` is a multi-value variable then use the `IN` comparison operator rather than `=` to match against multiple values):
-
-```sql
-SELECT hostname FROM host WHERE region IN($region)
-```
-
-#### Using `__searchFilter` to filter results in Query Variable
-
-Using `__searchFilter` in the query field will filter the query result based on what the user types in the dropdown select box.
-When nothing has been entered by the user the default value for `__searchFilter` is `%`.
-
-> Important that you surround the `__searchFilter` expression with quotes as Grafana does not do this for you.
-
-The example below shows how to use `__searchFilter` as part of the query field to enable searching for `hostname` while the user types in the dropdown select box.
-
-Query
-
-```sql
-SELECT hostname FROM my_host WHERE hostname LIKE '$__searchFilter'
-```
-
-### Using Variables in Queries
-
-Template variable values are only quoted when the template variable is a `multi-value`.
-
-If the variable is a multi-value variable then use the `IN` comparison operator rather than `=` to match against multiple values.
-
-There are two syntaxes:
-
-`$` Example with a template variable named `hostname`:
-
-```sql
-SELECT
- atimestamp as time,
- aint as value
-FROM table
-WHERE $__timeFilter(atimestamp) and hostname in($hostname)
-ORDER BY atimestamp ASC
-```
-
-`[[varname]]` Example with a template variable named `hostname`:
-
-```sql
-SELECT
- atimestamp as time,
- aint as value
-FROM table
-WHERE $__timeFilter(atimestamp) and hostname in([[hostname]])
-ORDER BY atimestamp ASC
-```
-
-#### Disabling quoting for multi-value variables
-
-Grafana automatically creates a quoted, comma-separated string for multi-value variables. For example: if `server01` and `server02` are selected then it will be formatted as: `'server01', 'server02'`. To disable quoting, use the csv formatting option for variables:
-
-`${servers:csv}`
-
-Read more about variable formatting options in the [Variables](ref:variable-syntax-advanced-variable-format-options) documentation.
-
-## Annotations
-
-[Annotations](ref:annotate-visualizations) allow you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view.
-
-**Example query using time column with epoch values:**
-
-```sql
-SELECT
- epoch_time as time,
- metric1 as text,
- concat_ws(', ', metric1::text, metric2::text) as tags
-FROM
- public.test_data
-WHERE
- $__unixEpochFilter(epoch_time)
-```
-
-**Example region query using time and timeend columns with epoch values:**
-
-```sql
-SELECT
- epoch_time as time,
- epoch_time_end as timeend,
- metric1 as text,
- concat_ws(', ', metric1::text, metric2::text) as tags
-FROM
- public.test_data
-WHERE
- $__unixEpochFilter(epoch_time)
-```
-
-**Example query using time column of native SQL date/time data type:**
-
-```sql
-SELECT
- native_date_time as time,
- metric1 as text,
- concat_ws(', ', metric1::text, metric2::text) as tags
-FROM
- public.test_data
-WHERE
- $__timeFilter(native_date_time)
-```
-
-| Name | Description |
-| --------- | ----------------------------------------------------------------------------------------------------------------- |
-| `time` | The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value. |
-| `timeend` | Optional name of the end date/time field. Could be a column with a native SQL date/time data type or epoch value. |
-| `text` | Event description field. |
-| `tags` | Optional field name to use for event tags as a comma separated string. |
-
-## Alerting
-
-Time series queries should work in alerting conditions. Table formatted queries are not yet supported in alert rule
-conditions.
diff --git a/docs/sources/datasources/postgres/configure/_index.md b/docs/sources/datasources/postgres/configure/_index.md
new file mode 100644
index 00000000000..7b6a66c0a70
--- /dev/null
+++ b/docs/sources/datasources/postgres/configure/_index.md
@@ -0,0 +1,194 @@
+---
+description: This document provides instructions for configuring the PostgreSQL data source.
+keywords:
+ - grafana
+ - postgresql
+ - guide
+labels:
+ products:
+ - cloud
+ - enterprise
+ - oss
+menuTitle: Configure the PostgreSQL data source
+title: Configure the PostgreSQL data source
+weight: 10
+refs:
+ provisioning-data-sources:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//administration/provisioning/#datasources
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//administration/provisioning/#datasources
+ variables:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//dashboards/variables/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//dashboards/variables/
+ add-template-variables-interval-ms:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval_ms
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval_ms
+ add-template-variables-interval:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval
+ data-source-management:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//administration/data-source-management/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//administration/data-source-management/
+ variable-syntax-advanced-variable-format-options:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//dashboards/variables/variable-syntax/#advanced-variable-format-options
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//dashboards/variables/variable-syntax/#advanced-variable-format-options
+---
+
+# Configure the PostgreSQL data source
+
+This document provides instructions for configuring the PostgreSQL data source and explains available configuration options. For general information on managing data sources refer to [Data source management](ref:data-source-management).
+
+## Before you begin
+
+You must have the `Organization administrator` role to configure the Postgres data source.
+Organization administrators can also [configure the data source via YAML](#provision-the-data-source) with the Grafana provisioning system.
+
+Grafana comes with a built-in PostgreSQL data source plugin, eliminating the need to install a plugin.
+
+{{< admonition type="note" >}}
+When adding a data source, the database user you specify should have only `SELECT` permissions on the relevant database and tables. Grafana does not validate the safety of queries, which means they can include potentially harmful SQL statements, such as `USE otherdb;` or `DROP TABLE user;`, that could be executed. To mitigate this risk, Grafana strongly recommends creating a dedicated PostgreSQL user with restricted permissions.
+{{< /admonition >}}
+
+Example:
+
+```sql
+ CREATE USER grafanareader WITH PASSWORD 'password';
+ GRANT USAGE ON SCHEMA schema TO grafanareader;
+ GRANT SELECT ON schema.table TO grafanareader;
+```
+
+## Add the PostgreSQL data source
+
+Complete the following steps to set up a new PostgreSQL data source:
+
+1. Click **Connections** in the left-side menu.
+1. Click **Add new connection**
+1. Type `PostgreSQL` in the search bar.
+1. Select the **PostgreSQL data source**.
+1. Click **Add new data source** in the upper right.
+
+You are taken to the **Settings** tab where you will configure the data source.
+
+## PostgreSQL configuration options
+
+Following is a list of PostgreSQL configuration options:
+
+- **Name** - Sets the name you use to refer to the data source in panels and queries. Examples: `PostgreSQL-DB-1`.
+- **Default** - Toggle to set this specific PostgreSQL data source as the default pre-selected data source in panels and visualizations.
+
+**Connection section:**
+
+- **Host URL** - The IP address/hostname and optional port of your PostgreSQL instance.
+- **Database name** - The name of your PostgreSQL database.
+
+**Authentication section:**
+
+- **Username** - Enter the username used to connect to your PostgreSQL database.
+- **Password** - Enter the password used to connect to the PostgreSQL database.
+- **TLS/SSL Mode** - Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. When **TLS/SSL Mode** is disabled, **TLS/SSL Method** and **TLS/SSL Auth Details** aren't visible options.
+- **TLS/SSL Method** - Determines how TLS/SSL certificates are configured.
+ - **File system path** - This option allows you to configure certificates by specifying paths to existing certificates on the local file system where Grafana is running. Ensure this file is readable by the user executing the Grafana process.
+ - **Certificate content** - This option allows you to configure certificate by specifying their content. The content is stored and encrypted in the Grafana database. When connecting to the database, the certificates are saved as files, on the local filesystem, in the Grafana data path.
+
+**TLS/SSL Auth Details**
+
+If you select the TLS/SSL Mode options **require**, **verify-ca** or **verify-full** and **file system path** the following are required:
+
+- **TLS/SSL Root Certificate** - Specify the path to the root certificate file.
+- **TLS/SSL Client Certificate** - Specify the path to the client certificate and ensure the file is accessible to the user running the Grafana process.
+- **TLS/SSL Client Key** - Specify the path to the client key file and ensure the file is accessible to the user running the Grafana process.
+
+If you select the TLS/SSL Mode option **require** and TLS/SSL Method certificate content the following are required:
+
+- **TLS/SSL Client Certificate** - Provide the client certificate.
+- **TLS/SSL Client Key** - Provide the client key.
+
+If you select the TLS/SSL Mode options **verify-ca** or **verify-full** with the TLS/SSL Method certificate content the following are required:
+
+- **TLS/SSL Client Certificate** - Provide the client certificate.
+- **TLS/SSL Root Certificate** - Provide the root certificate.
+- **TLS/SSL Client Key** - Provide the client key.
+
+**PostgreSQL Options:**
+
+- **Version** - Determines which functions are available in the query builder. The default is the current version.
+- **Min time interval** - Defines a lower limit for the auto group by by time interval. Grafana recommends aligning this setting with the data write frequency. For example, set it to `1m` if your data is written every minute. Refer to [Min time interval](#min-time-interval) for format examples.
+- **TimescaleDB** - A time-series database built as a PostgreSQL extension. When enabled, Grafana uses `time_bucket` in the `$__timeGroup` macro to display TimescaleDB specific aggregate functions in the query builder. For more information, refer to [TimescaleDB documentation](https://docs.timescale.com/timescaledb/latest/tutorials/grafana/grafana-timescalecloud/#connect-timescaledb-and-grafana).
+
+**Connection limits:**
+
+- **Max open** - The maximum number of open connections to the database. The default `100`.
+- **Auto max idle** - Toggle to set the maximum number of idle connections to the number of maximum open connections. This setting is toggled on by default.
+- **Max idle** - The maximum number of connections in the idle connection pool. The default `100`.
+- **Max lifetime** - The maximum amount of time in seconds a connection may be reused. The default is `14400`, or 4 hours.
+
+**Private data source connect** - _Only for Grafana Cloud users._ Private data source connect, or PDC, allows you to establish a private, secured connection between a Grafana Cloud instance, or stack, and data sources secured within a private network. Click the drop-down to locate the URL for PDC. For more information regarding Grafana PDC refer to [Private data source connect (PDC)](https://grafana.com/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/).
+
+Click **Manage private data source connect** to be taken to your PDC connection page, where you’ll find your PDC configuration details.
+
+After you have added your PostgreSQL connection settings, click **Save & test** to test and save the data source connection.
+
+### Min time interval
+
+The **Min time interval** setting defines a lower limit for the [`$__interval`](ref:add-template-variables-interval) and [`$__interval_ms`](ref:add-template-variables-interval-ms) variables.
+
+This option can also be configured or overridden in the dashboard panel under the data source settings.
+
+This value must be formatted as a number followed by a valid time identifier:
+
+| Identifier | Description |
+| ---------- | ----------- |
+| `y` | year |
+| `M` | month |
+| `w` | week |
+| `d` | day |
+| `h` | hour |
+| `m` | minute |
+| `s` | second |
+| `ms` | millisecond |
+
+## Provision the data source
+
+You can define and configure the data source in YAML files with [provisioning](/docs/grafana//administration/provisioning/#data-sources).
+For more information about provisioning, and available configuration options, refer to [Provision Grafana](ref:provisioning-data-sources).
+
+### PostgreSQL provisioning example
+
+```yaml
+apiVersion: 1
+
+datasources:
+ - name: Postgres
+ type: postgres
+ url: localhost:5432
+ user: grafana
+ secureJsonData:
+ password: 'Password!'
+ jsonData:
+ database: grafana
+ sslmode: 'disable' # disable/require/verify-ca/verify-full
+ maxOpenConns: 100
+ maxIdleConns: 100
+ maxIdleConnsAuto: true
+ connMaxLifetime: 14400
+ postgresVersion: 903 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
+ timescaledb: false
+```
+
+#### Troubleshoot provisioning issues
+
+If you encounter metric request errors or other issues:
+
+- Ensure that the parameters in your data source YAML file precisely match the example provided, including parameter names and the correct use of quotation marks.
+- Verify that the database name _isn't_ included in the URL.
diff --git a/docs/sources/datasources/postgres/query-editor/_index.md b/docs/sources/datasources/postgres/query-editor/_index.md
new file mode 100644
index 00000000000..5c37f7047e7
--- /dev/null
+++ b/docs/sources/datasources/postgres/query-editor/_index.md
@@ -0,0 +1,410 @@
+---
+description: This document describes the PostgreSQL query editor in Grafana.
+keywords:
+ - grafana
+ - postgresql
+ - guide
+labels:
+ products:
+ - cloud
+ - enterprise
+ - oss
+menuTitle: PostgreSQL query editor
+title: PostgreSQL query editor
+weight: 20
+refs:
+ variables:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//dashboards/variables/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//dashboards/variables/
+ add-template-variables-interval:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//dashboards/variables/add-template-variables/#__interval
+ explore:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//explore/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana//explore/
+ query-transform-data:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//panels-visualizations/query-transform-data/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana-cloud/visualizations/panels-visualizations/query-transform-data/
+ query-editor:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//panels-visualizations/query-transform-data/#query-editors
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana-cloud/visualizations/panels-visualizations/query-transform-data/#query-editors
+ alert-rules:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//alerting/fundamentals/alert-rules/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana-cloud/alerting-and-irm/alerting/alerting-rules/
+ template-annotations-and-labels:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//alerting/alerting-rules/templates/
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana-cloud/alerting-and-irm/alerting/alerting-rules/templates/
+ templates:
+ - pattern: /docs/grafana/
+ destination: /docs/grafana//dashboards/variables/#templates
+ - pattern: /docs/grafana-cloud/
+ destination: /docs/grafana-cloud/visualizations/dashboards/variables/#templates
+---
+
+# PostgreSQL query editor
+
+Grafana query editors are unique for each data source.
+
+For general information on Grafana query editors, refer to [Query editors](ref:query-editor).
+
+For general information on querying data sources in Grafana, refer to [Query and transform data](ref:query-transform-data).
+
+The PostgreSQL query editor is located on the [Explore page](ref:explore). You can also access the PostgreSQL query editor from a dashboard panel. Click the ellipsis in the upper right of the panel and select **Edit**.
+
+{{< figure src="/static/img/docs/screenshot-postgres-query-editor.png" class="docs-image--no-shadow" caption="PostgreSQL query builder" >}}
+
+## PostgreSQL query editor components
+
+The PostgreSQL query editor has two modes: **Builder** and **Code**.
+
+Builder mode helps you build a query using a visual interface. Code mode allows for advanced querying and offers support for complex SQL query writing.
+
+### PostgreSQL Builder mode
+
+The following components will help you build a PostgreSQL query:
+
+- **Format** - Select a format response from the drop-down for the PostgreSQL query. The default is **Table**. If you use the **Time series** format option, one of the columns must be `time`. Refer to [Time series queries](#time-series-queries) for more information.
+- **Table** - Select a table from the drop-down. Tables correspond to the chosen database.
+- **Data operations** - _Optional_ Select an aggregation from the drop-down. You can add multiple data operations by clicking the **+ sign**. Click the **garbage can icon** to remove data operations.
+- **Column** - Select a column on which to run the aggregation.
+- **Alias** - _Optional_ Add an alias from the drop-down. You can also add your own alias by typing it in the box and clicking **Enter**. Remove an alias by clicking the **X**.
+- **Filter** - Toggle to add filters.
+- **Filter by column value** - _Optional_ If you toggle **Filter** you can add a column to filter by from the drop-down. To filter on more columns, click the **+ sign** to the right of the condition drop-down. You can choose a variety of operators from the drop-down next to the condition. When multiple filters are added you can add an `AND` operator to display all true conditions or an `OR` operator to display any true conditions. Use the second drop-down to choose a filter. To remove a filter, click the `X` button next to that filter's drop-down. After selecting a date type column, you can choose **Macros** from the operators list and select `timeFilter` which will add the `$\_\_timeFilter` macro to the query with the selected date column.
+- **Group** - Toggle to add **Group by column**.
+- **Group by column** - Select a column to filter by from the drop-down. Click the **+sign** to filter by multiple columns. Click the **X** to remove a filter.
+- **Order** - Toggle to add an `ORDER BY` statement.
+- **Order by** - Select a column to order by from the drop-down. Select ascending (`ASC`) or descending (`DESC`) order.
+- **Limit** - You can add an optional limit on the number of retrieved results. Default is 50.
+- **Preview** - Toggle for a preview of the SQL query generated by the query builder. Preview is toggled on by default.
+
+## PostgreSQL Code mode
+
+To create advanced queries, switch to **Code mode** by clicking **Code** in the upper right of the editor window. Code mode supports the auto-completion of tables, columns, SQL keywords, standard SQL functions, Grafana template variables, and Grafana macros. Columns cannot be completed before a table has been specified.
+
+{{< figure src="/static/img/docs/v92/sql_code_editor.png" class="docs-image--no-shadow" >}}
+
+Select **Table** or **Time Series** as the format. Click the **{}** in the bottom right to format the query. Click the **downward caret** to expand the Code mode editor. **CTRL/CMD + Return** serves as a keyboard shortcut to execute the query.
+
+{{< admonition type="warning" >}}
+Changes made to a query in Code mode will not transfer to Builder mode and will be discarded. You will be prompted to copy your code to the clipboard to save any changes.
+{{< /admonition >}}
+
+## Macros
+
+You can add macros to your queries to simplify the syntax and enable dynamic elements, such as date range filters.
+
+| Macro example | Description |
+| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `$__time(dateColumn)` | Replaces the value with an expression to convert to a UNIX timestamp and renames the column to `time_sec`. Example: `UNIX_TIMESTAMP(dateColumn) AS time_sec`. |
+| `$__timeEpoch(dateColumn)` | Replaces the value with an expression to convert to a UNIX Epoch timestamp and renames the column to `time_sec`. Example: `UNIX_TIMESTAMP(dateColumn) AS time_sec`. |
+| `$__timeFilter(dateColumn)` | Replaces the value a time range filter using the specified column name. Example: `dateColumn BETWEEN FROM_UNIXTIME(1494410783) AND FROM_UNIXTIME(1494410983)` |
+| `$__timeFrom()` | Replaces the value with the start of the currently active time selection. Example: `FROM_UNIXTIME(1494410783)` |
+| `$__timeTo()` | Replaces the value with the end of the currently active time selection. Example: `FROM_UNIXTIME(1494410983)` |
+| `$__timeGroup(dateColumn,'5m')` | Replaces the value with an expression suitable for use in a `GROUP BY` clause. Example: `cast(cast(UNIX_TIMESTAMP(dateColumn)/(300) AS signed)*300 AS signed)` |
+| `$__timeGroup(dateColumn,'5m', 0)` | Same as the `$__timeGroup(dateColumn,'5m')` macro, but includes a fill parameter to ensure missing points in the series are added by Grafana, using 0 as the default value. **This applies only to time series queries.** |
+| `$__timeGroup(dateColumn,'5m', NULL)` | Same as the `$__timeGroup(dateColumn,'5m', 0)` but `NULL` is used as the value for missing points. _This applies only to time series queries._ |
+| `$__timeGroup(dateColumn,'5m', previous)` | Same as the `$__timeGroup(dateColumn,'5m', previous)` macro, but uses the previous value in the series as the fill value. If no previous value exists, it uses `NULL`. _This applies only to time series queries._ |
+| `$__timeGroupAlias(dateColumn,'5m')` | Replaces the value identical to `$__timeGroup` but with an added column alias. |
+| `$__unixEpochFilter(dateColumn)` | Replaces the value by a time range filter using the specified column name with times represented as a UNIX timestamp. Example: `dateColumn > 1494410783 AND dateColumn < 1494497183` |
+| `$__unixEpochFrom()` | Replaces the value with the start of the currently active time selection as a UNIX timestamp. Example: `1494410783` |
+| `$__unixEpochTo()` | Replaces the value with the end of the currently active time selection as a UNIX timestamp. Example: `1494497183` |
+| `$__unixEpochNanoFilter(dateColumn)` | Replaces the value with a time range filter using the specified column name with time represented as a nanosecond timestamp. Example: `dateColumn > 1494410783152415214 AND dateColumn < 1494497183142514872` |
+| `$__unixEpochNanoFrom()` | Replaces the value with the start of the currently active time selection as a nanosecond timestamp. Example: `1494410783152415214` |
+| `$__unixEpochNanoTo()` | Replaces the value with the end of the currently active time selection as nanosecond timestamp. Example: `1494497183142514872` |
+| `$__unixEpochGroup(dateColumn,'5m', [fillmode])` | Same as `$__timeGroup` but for times stored as Unix timestamp. `fillMode` only works with time series queries. |
+| `$__unixEpochGroupAlias(dateColumn,'5m', [fillmode])` | Same as `$__timeGroup` but also adds a column alias. `fillMode` only works with time series queries. |
+
+## Table SQL queries
+
+If the **Format** option is set to **Table**, you can execute virtually any type of SQL query. The Table panel will automatically display the resulting columns and rows from your query.
+
+
+
+You can change or customize the name of a Table panel column by using the SQL keyword `AS` syntax.
+
+```sql
+SELECT
+ title as "Title",
+ "user".login as "Created By",
+ dashboard.created as "Created On"
+FROM dashboard
+INNER JOIN "user" on "user".id = dashboard.created_by
+WHERE $__timeFilter(dashboard.created)
+```
+
+## Time series queries
+
+Set the **Format** option to **Time series** to create and run time series queries.
+
+{{< admonition type="note" >}}
+To run a time series query you must include a column named `time` that returns either a SQL `datetime` value or a numeric datatype representing the UNIX epoch time in seconds. Additionally, the query results must be sorted by the `time` column for proper visualization in panels.
+{{< /admonition >}}
+
+The examples in this section refer to the data in the following table:
+
+```text
++---------------------+--------------+---------------------+----------+
+| time_date_time | value_double | CreatedAt | hostname |
++---------------------+--------------+---------------------+----------+
+| 2020-01-02 03:05:00 | 3.0 | 2020-01-02 03:05:00 | 10.0.1.1 |
+| 2020-01-02 03:06:00 | 4.0 | 2020-01-02 03:06:00 | 10.0.1.2 |
+| 2020-01-02 03:10:00 | 6.0 | 2020-01-02 03:10:00 | 10.0.1.1 |
+| 2020-01-02 03:11:00 | 7.0 | 2020-01-02 03:11:00 | 10.0.1.2 |
+| 2020-01-02 03:20:00 | 5.0 | 2020-01-02 03:20:00 | 10.0.1.2 |
++---------------------+--------------+---------------------+----------+
+```
+
+Time series query results are returned in [wide data frame format](https://grafana.com/developers/plugin-tools/key-concepts/data-frames#wide-format). In the data frame query result, any column, except for time or string-type columns, transforms into value fields. String columns, on the other hand, become field labels.
+
+{{< admonition type="note" >}}
+For backward compatibility, an exception to this rule applies to queries that return three columns, one of which is a string column named `metric`. Instead of converting the metric column into field labels, it is used as the field name, while the series name is set to its value. See the following example for reference.
+{{< /admonition >}}
+
+**Example with `metric` column:**
+
+```sql
+SELECT
+ $__timeGroupAlias("time_date_time",'5m'),
+ min("value_double"),
+ 'min' as metric
+FROM test_data
+WHERE $__timeFilter("time_date_time")
+GROUP BY time
+ORDER BY time
+```
+
+Data frame result:
+
+```text
++---------------------+-----------------+
+| Name: time | Name: min |
+| Labels: | Labels: |
+| Type: []time.Time | Type: []float64 |
++---------------------+-----------------+
+| 2020-01-02 03:05:00 | 3 |
+| 2020-01-02 03:10:00 | 6 |
++---------------------+-----------------+
+```
+
+To customize default series name formatting, refer to [Standard options definitions](ref:configure-standard-options-display-name).
+
+Following are time series query examples.
+
+**Example using the fill parameter in the $\_\_timeGroupAlias macro to convert null values to be zero instead:**
+
+```sql
+SELECT
+ $__timeGroupAlias("createdAt",'5m',0),
+ sum(value) as value,
+ hostname
+FROM test_data
+WHERE
+ $__timeFilter("createdAt")
+GROUP BY time, hostname
+ORDER BY time
+```
+
+Based on the data frame result in the following example, the time series panel will generate two series named _value 10.0.1.1_ and _value 10.0.1.2_. To display the series names as _10.0.1.1_ and _10.0.1.2_, use the [Standard options definitions](ref:configure-standard-options-display-name) display value `${__field.labels.hostname}`.
+
+Data frame result:
+
+```text
++---------------------+---------------------------+---------------------------+
+| Name: time | Name: value | Name: value |
+| Labels: | Labels: hostname=10.0.1.1 | Labels: hostname=10.0.1.2 |
+| Type: []time.Time | Type: []float64 | Type: []float64 |
++---------------------+---------------------------+---------------------------+
+| 2020-01-02 03:05:00 | 3 | 4 |
+| 2020-01-02 03:10:00 | 6 | 7 |
++---------------------+---------------------------+---------------------------+
+```
+
+**Example with multiple columns:**
+
+```sql
+SELECT
+ $__timeGroupAlias("time_date_time",'5m'),
+ min("value_double") as "min_value",
+ max("value_double") as "max_value"
+FROM test_data
+WHERE $__timeFilter("time_date_time")
+GROUP BY time
+ORDER BY time
+```
+
+Data frame result:
+
+```text
++---------------------+-----------------+-----------------+
+| Name: time | Name: min_value | Name: max_value |
+| Labels: | Labels: | Labels: |
+| Type: []time.Time | Type: []float64 | Type: []float64 |
++---------------------+-----------------+-----------------+
+| 2020-01-02 03:04:00 | 3 | 4 |
+| 2020-01-02 03:05:00 | 6 | 7 |
++---------------------+-----------------+-----------------+
+```
+
+## Templating
+
+Instead of hard coding values like server, application, or sensor names in your metric queries, you can use variables. Variables appear as drop-down select boxes at the top of the dashboard. These drop-downs make it easy to change the data being displayed in your dashboard.
+
+Refer to [Templates](ref:templates) for an introduction to creating template variables as well as the different types.
+
+### Query variable
+
+If you add a `Query` template variable you can write a PostgreSQL query to retrieve items such as measurement names, key names, or key values, which will be displayed in the drop-down menu.
+
+For example, you can use a variable to retrieve all the values from the `hostname` column in a table by creating the following query in the templating variable _Query_ setting.
+
+```sql
+SELECT hostname FROM host
+```
+
+A query can return multiple columns, and Grafana will automatically generate a list based on the query results. For example, the following query returns a list with values from `hostname` and `hostname2`.
+
+```sql
+SELECT host.hostname, other_host.hostname2 FROM host JOIN other_host ON host.city = other_host.city
+```
+
+To use time range dependent macros like `$__timeFilter(column)` in your query, you must set the template variable's refresh mode to _On Time Range Change_.
+
+```sql
+SELECT event_name FROM event_log WHERE $__timeFilter(time_column)
+```
+
+Another option is a query that can create a key/value variable. The query should return two columns that are named `__text` and `__value`. The `__text` column must contain unique values (if not, only the first value is used). This allows the drop-down options to display a text-friendly name as the text while using an ID as the value. For example, a query could use `hostname` as the text and `id` as the value:
+
+```sql
+SELECT hostname AS __text, id AS __value FROM host
+```
+
+You can also create nested variables. For example, if you have a variable named `region`, you can configure the `hosts` variable to display only the hosts within the currently selected region as shown in the following example. If `region` is a multi-value variable, use the `IN` operator instead of `=` to match multiple values.
+
+```sql
+SELECT hostname FROM host WHERE region IN($region)
+```
+
+#### Using `__searchFilter` to filter results in Query Variable
+
+Using `__searchFilter` in the query field allows the query results to be filtered based on the user’s input in the drop-down selection box. If you do not enter anything, the default value for `__searchFilter` is `%`.
+
+Note that you must enclose the `__searchFilter` expression in quotes as Grafana does not add them automatically.
+
+The following example demonstrates how to use `__searchFilter` in the query field to enable real-time searching for `hostname` as the user type in the drop-down selection box.
+
+```sql
+SELECT hostname FROM my_host WHERE hostname LIKE '$__searchFilter'
+```
+
+### Using Variables in Queries
+
+Template variable values are only quoted when the template variable is a `multi-value`.
+
+If the variable is a multi-value variable, use the `IN` comparison operator instead of `=` to match against multiple values.
+
+You can use two different syntaxes:
+
+`$` Example with a template variable named `hostname`:
+
+```sql
+SELECT
+ atimestamp as time,
+ aint as value
+FROM table
+WHERE $__timeFilter(atimestamp) and hostname in($hostname)
+ORDER BY atimestamp ASC
+```
+
+`[[varname]]` Example with a template variable named `hostname`:
+
+```sql
+SELECT
+ atimestamp as time,
+ aint as value
+FROM table
+WHERE $__timeFilter(atimestamp) and hostname in([[hostname]])
+ORDER BY atimestamp ASC
+```
+
+#### Disabling quoting for multi-value variables
+
+Grafana automatically formats multi-value variables as a quoted, comma-separated string. For example, if `server01` and `server02` are selected, they are formatted as `'server01'`, `'server02'`. To remove the quotes, enable the CSV formatting option for the variables:
+
+`${servers:csv}`
+
+Read more about variable formatting options in the [Variables](ref:variable-syntax-advanced-variable-format-options) documentation.
+
+## Annotations
+
+[Annotations](ref:annotate-visualizations) allow you to overlay rich event information on top of graphs. Add annotation queries via the **Dashboard settings > Annotations view**.
+
+**Example query using a `time` column with epoch values:**
+
+```sql
+SELECT
+ epoch_time as time,
+ metric1 as text,
+ concat_ws(', ', metric1::text, metric2::text) as tags
+FROM
+ public.test_data
+WHERE
+ $__unixEpochFilter(epoch_time)
+```
+
+**Example region query using `time` and `timeend` columns with epoch values:**
+
+```sql
+SELECT
+ epoch_time as time,
+ epoch_time_end as timeend,
+ metric1 as text,
+ concat_ws(', ', metric1::text, metric2::text) as tags
+FROM
+ public.test_data
+WHERE
+ $__unixEpochFilter(epoch_time)
+```
+
+**Example query using a `time` column with a native SQL date/time data type:**
+
+```sql
+SELECT
+ native_date_time as time,
+ metric1 as text,
+ concat_ws(', ', metric1::text, metric2::text) as tags
+FROM
+ public.test_data
+WHERE
+ $__timeFilter(native_date_time)
+```
+
+| Name | Description |
+| --------- | --------------------------------------------------------------------------------------------------------------------- |
+| `time` | The name of the date/time field, which can be a column with a native SQL date/time data type or epoch value. |
+| `timeend` | Optional name of the end date/time field, which can be a column with a native SQL date/time data type or epoch value. |
+| `text` | Event description field. |
+| `tags` | Optional field name to use for event tags as a comma-separated string. |
+
+## Alerting
+
+Use time series queries to create alerts. Table formatted queries aren't yet supported in alert rule conditions.
+
+For more information regarding alerting refer to the following:
+
+- [Alert rules](ref:alert-rules)
+- [Template annotations and labels](ref:template-annotations-and-labels)
From 9f9c248766f8999cdd12613769c5f715dd204a13 Mon Sep 17 00:00:00 2001
From: Dave Henderson
Date: Fri, 21 Feb 2025 14:10:38 -0500
Subject: [PATCH 18/22] chore(deps): Remove unreferenced goavro dependency
(#101171)
Signed-off-by: Dave Henderson
---
go.mod | 1 -
go.sum | 2 --
pkg/extensions/main.go | 1 -
3 files changed, 4 deletions(-)
diff --git a/go.mod b/go.mod
index 744aa4d529e..2347415b45a 100644
--- a/go.mod
+++ b/go.mod
@@ -111,7 +111,6 @@ require (
github.com/jmoiron/sqlx v1.3.5 // @grafana/grafana-backend-group
github.com/json-iterator/go v1.1.12 // @grafana/grafana-backend-group
github.com/lib/pq v1.10.9 // @grafana/grafana-backend-group
- github.com/linkedin/goavro/v2 v2.10.0 // @grafana/grafana-backend-group
github.com/m3db/prometheus_remote_client_golang v0.4.4 // @grafana/grafana-backend-group
github.com/madflojo/testcerts v1.1.1 // @grafana/alerting-backend
github.com/magefile/mage v1.15.0 // @grafana/grafana-developer-enablement-squad
diff --git a/go.sum b/go.sum
index 85c8855cce6..e4bd6172c9a 100644
--- a/go.sum
+++ b/go.sum
@@ -1845,8 +1845,6 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
-github.com/linkedin/goavro/v2 v2.10.0 h1:eTBIRoInBM88gITGXYtUSqqxLTFXfOsJBiX8ZMW0o4U=
-github.com/linkedin/goavro/v2 v2.10.0/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA=
github.com/linode/linodego v1.43.0 h1:sGeBB3caZt7vKBoPS5p4AVzmlG4JoqQOdigIibx3egk=
github.com/linode/linodego v1.43.0/go.mod h1:n4TMFu1UVNala+icHqrTEFFaicYSF74cSAUG5zkTwfA=
github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
diff --git a/pkg/extensions/main.go b/pkg/extensions/main.go
index 98e324f8e5e..b4aace2cfad 100644
--- a/pkg/extensions/main.go
+++ b/pkg/extensions/main.go
@@ -19,7 +19,6 @@ import (
_ "github.com/grpc-ecosystem/go-grpc-middleware/v2"
_ "github.com/hashicorp/go-multierror"
_ "github.com/hashicorp/golang-lru/v2"
- _ "github.com/linkedin/goavro/v2"
_ "github.com/m3db/prometheus_remote_client_golang/promremote"
_ "github.com/phpdave11/gofpdi"
_ "github.com/robfig/cron/v3"
From c33e908baff25768d86e7ffb7e80a58940730acf Mon Sep 17 00:00:00 2001
From: William Wernert
Date: Fri, 21 Feb 2025 16:02:39 -0500
Subject: [PATCH 19/22] Alerting: Update alerting package to include SNS fix
(#101177)
* Update alerting package to include sns fix
* Update workspace
---
go.mod | 2 +-
go.sum | 4 +--
go.work.sum | 38 ++++++++++++++++++++++++++++-
pkg/storage/unified/apistore/go.mod | 2 +-
pkg/storage/unified/apistore/go.sum | 4 +--
pkg/storage/unified/resource/go.mod | 2 +-
pkg/storage/unified/resource/go.sum | 4 +--
7 files changed, 46 insertions(+), 10 deletions(-)
diff --git a/go.mod b/go.mod
index 2347415b45a..d512579c149 100644
--- a/go.mod
+++ b/go.mod
@@ -71,7 +71,7 @@ require (
github.com/googleapis/gax-go/v2 v2.14.1 // @grafana/grafana-backend-group
github.com/gorilla/mux v1.8.1 // @grafana/grafana-backend-group
github.com/gorilla/websocket v1.5.3 // @grafana/grafana-app-platform-squad
- github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb // @grafana/alerting-backend
+ github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44 // @grafana/alerting-backend
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 // @grafana/identity-access-team
github.com/grafana/authlib/types v0.0.0-20250219092154-21ce22b49f31 // @grafana/identity-access-team
github.com/grafana/dataplane/examples v0.0.1 // @grafana/observability-metrics
diff --git a/go.sum b/go.sum
index e4bd6172c9a..2b409ed61b5 100644
--- a/go.sum
+++ b/go.sum
@@ -1511,8 +1511,8 @@ github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7Fsg
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb h1:WfCsiuZXhGXIdzImQ9/Kjfn9M4e6f7z5mddcSKCRxmI=
-github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
+github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44 h1:vboqvbAO0s0CTALHnqfmNvhCP1ziBcZNpYDbORqvOgg=
+github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 h1:NTMmow+74I3Jb033xhbRgWQS7A//5TDhiM4tl7bsVP4=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7/go.mod h1:T3X4z0ejGfJOiOmZLFeKCRT/yxWJq/RtclAc/PHj/w4=
github.com/grafana/authlib/types v0.0.0-20250219092154-21ce22b49f31 h1:EokLC5grHwLPs4tXW8T6E8187H1e5G9AP0QQ5B60HbA=
diff --git a/go.work.sum b/go.work.sum
index 7dc97c7b7bb..6d37067853e 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -392,6 +392,7 @@ github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
+github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U=
github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic=
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM=
@@ -508,7 +509,9 @@ github.com/elastic/go-sysinfo v1.11.2 h1:mcm4OSYVMyws6+n2HIVMGkln5HOpo5Ie1ZmbbNn
github.com/elastic/go-sysinfo v1.11.2/go.mod h1:GKqR8bbMK/1ITnez9NIsIfXQr25aLhRJa7AfT8HpBFQ=
github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
+github.com/elazarl/goproxy v1.3.0/go.mod h1:X/5W/t+gzDyLfHW4DrMdpjqYjpXsURlBt9lpBDxZZZQ=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw=
+github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
@@ -546,10 +549,12 @@ github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU=
github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg=
github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea h1:DfZQkvEbdmOe+JK2TMtBM+0I9GSdzE2y/L1/AmD8xKc=
github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea/go.mod h1:Y7Vld91/HRbTBm7JwoI7HejdDB0u+e9AUBO9MB7yuZk=
+github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
+github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-pdf/fpdf v0.9.0 h1:PPvSaUuo1iMi9KkaAn90NuKi+P4gwMedWPHhj8YlJQw=
@@ -561,6 +566,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4=
github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
+github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
+github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 h1:TQcrn6Wq+sKGkpyPvppOz99zsMBaUOKXq6HSv655U1c=
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
@@ -579,7 +586,6 @@ github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfE
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/glog v1.2.3/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
-github.com/golang/glog v1.2.4/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12 h1:uK3X/2mt4tbSGoHvbLBHUny7CKiuwUip3MArtukol4E=
github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
@@ -609,17 +615,29 @@ github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
+github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/grafana/alerting v0.0.0-20250129195454-3e5b80036b7a/go.mod h1:QsnoKX/iYZxA4Cv+H+wC7uxutBD8qi8ZW5UJvD2TYmU=
+github.com/grafana/authlib v0.0.0-20250123104008-e99947858901/go.mod h1:/gYfphsNu9v1qYWXxpv1NSvMEMSwvdf8qb8YlgwIRl8=
github.com/grafana/authlib/types v0.0.0-20250120144156-d6737a7dc8f5/go.mod h1:qYjSd1tmJiuVoSICp7Py9/zD54O9uQQA3wuM6Gg4DFM=
+github.com/grafana/authlib/types v0.0.0-20250120145936-5f0e28e7a87c/go.mod h1:qYjSd1tmJiuVoSICp7Py9/zD54O9uQQA3wuM6Gg4DFM=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2/go.mod h1:w/aiO1POVIeXUQyl0VQSZjl5OAGDTL5aX+4v0RA1tcw=
github.com/grafana/cog v0.0.23 h1:/0CCJ24Z8XXM2DnboSd2FzoIswUroqIZzVr8oJWmMQs=
github.com/grafana/cog v0.0.23/go.mod h1:jrS9indvWuDs60RHEZpLaAkmZdgyoLKMOEUT0jiB1t0=
github.com/grafana/go-gelf/v2 v2.0.1 h1:BOChP0h/jLeD+7F9mL7tq10xVkDG15he3T1zHuQaWak=
github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD4s0CLobh90=
+github.com/grafana/grafana-plugin-sdk-go v0.263.0/go.mod h1:U43Cnrj/9DNYyvFcNdeUWNjMXTKNB0jcTcQGpWKd2gw=
+github.com/grafana/grafana/apps/advisor v0.0.0-20250123151950-b066a6313173/go.mod h1:goSDiy3jtC2cp8wjpPZdUHRENcoSUHae1/Px/MDfddA=
github.com/grafana/grafana/apps/advisor v0.0.0-20250220154326-6e5de80ef295/go.mod h1:9I1dKV3Dqr0NPR9Af0WJGxOytp5/6W3JLiNChOz8r+c=
+github.com/grafana/grafana/apps/alerting/notifications v0.0.0-20250121113133-e747350fee2d/go.mod h1:AvleS6icyPmcBjihtx5jYEvdzLmHGBp66NuE0AMR57A=
+github.com/grafana/grafana/apps/investigation v0.0.0-20250121113133-e747350fee2d/go.mod h1:HQprw3MmiYj5OUV9CZnkwA1FKDZBmYACuAB3oDvUOmI=
+github.com/grafana/grafana/apps/playlist v0.0.0-20250121113133-e747350fee2d/go.mod h1:DjJe5osrW/BKrzN9hAAOSElNWutj1bcriExa7iDP7kA=
+github.com/grafana/grafana/pkg/aggregator v0.0.0-20250121113133-e747350fee2d/go.mod h1:1sq0guad+G4SUTlBgx7SXfhnzy7D86K/LcVOtiQCiMA=
github.com/grafana/grafana/pkg/build v0.0.0-20250220114259-be81314e2118/go.mod h1:STVpVboMYeBAfyn6Zw6XHhTHqUxzMy7pzRiVgk1l0W0=
+github.com/grafana/grafana/pkg/semconv v0.0.0-20250121113133-e747350fee2d/go.mod h1:tfLnBpPYgwrBMRz4EXqPCZJyCjEG4Ev37FSlXnocJ2c=
+github.com/grafana/grafana/pkg/storage/unified/apistore v0.0.0-20250121113133-e747350fee2d/go.mod h1:CXpwZ3Mkw6xVlGKc0SqUxqXCP3Uv182q6qAQnLaLxRg=
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0 h1:bjh0PVYSVVFxzINqPFYJmAmJNrWPgnVjuSdYJGHmtFU=
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0/go.mod h1:7t5XR+2IA8P2qggOAHTj/GCZfoLBle3OvNSYh1VkRBU=
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
@@ -630,8 +648,10 @@ github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
github.com/hamba/avro/v2 v2.27.0 h1:IAM4lQ0VzUIKBuo4qlAiLKfqALSrFC+zi1iseTtbBKU=
github.com/hamba/avro/v2 v2.27.0/go.mod h1:jN209lopfllfrz7IGoZErlDz+AyUJ3vrBePQFZwYf5I=
+github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-msgpack/v2 v2.1.1 h1:xQEY9yB2wnHitoSzk/B9UjXWRQ67QKu5AOm8aFp8N3I=
github.com/hashicorp/go-msgpack/v2 v2.1.1/go.mod h1:upybraOAblm4S7rx0+jeNy+CWWhzywQsSRV5033mMu4=
+github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q=
github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE=
github.com/hashicorp/go.net v0.0.1 h1:sNCoNyDEvN1xa+X0baata4RdcpKwcMS6DH+xwfqPgjw=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
@@ -654,6 +674,7 @@ github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b h1:i44CesU68Z
github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b/go.mod h1:Z0kXnxzbTC2qrx4NaIzYkE1k66+6oEDQTvL95hQFh5Y=
github.com/influxdata/telegraf v1.16.3 h1:x0qeuSGGMg5y+YqP/5ZHwXZu3bcBrO8AAQOTNlYEb1c=
github.com/influxdata/telegraf v1.16.3/go.mod h1:fX/6k7qpIqzVPWyeIamb0wN5hbwc0ANUaTS80lPYFB8=
+github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/iris-contrib/schema v0.0.6 h1:CPSBLyx2e91H2yJzPuhGuifVRnZBBJ3pCOMbOvPZaTw=
github.com/iris-contrib/schema v0.0.6/go.mod h1:iYszG0IOsuIsfzjymw1kMzTL8YQcCWlm65f3wX8J5iA=
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGUK1IDqRa5lAAvEkZG1LKaCRc=
@@ -726,6 +747,7 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/leodido/ragel-machinery v0.0.0-20190525184631-5f46317e436b h1:11UHH39z1RhZ5dc4y4r/4koJo6IYFgTRMe/LlwRTEw0=
github.com/leodido/ragel-machinery v0.0.0-20190525184631-5f46317e436b/go.mod h1:WZxr2/6a/Ar9bMDc2rN/LJrE/hF6bXE4LPyDSIxwAfg=
+github.com/linkedin/goavro/v2 v2.10.0/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA=
github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4=
github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY=
@@ -737,6 +759,8 @@ github.com/mailgun/raymond/v2 v2.0.48 h1:5dmlB680ZkFG2RN/0lvTAghrSxIESeu9/2aeDqA
github.com/mailgun/raymond/v2 v2.0.48/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18=
github.com/matryer/moq v0.3.3 h1:pScMH9VyrdT4S93yiLpVyU8rCDqGQr24uOyBxmktG5Q=
github.com/matryer/moq v0.3.3/go.mod h1:RJ75ZZZD71hejp39j4crZLsEDszGk6iH4v4YsWFKH4s=
+github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
github.com/mfridman/xflag v0.1.0 h1:TWZrZwG1QklFX5S4j1vxfF1sZbZeZSGofMwPMLAF29M=
github.com/mfridman/xflag v0.1.0/go.mod h1:/483ywM5ZO5SuMVjrIGquYNE5CzLrj5Ux/LxWWnjRaE=
@@ -883,6 +907,7 @@ github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad h1:fiWzISvDn0Csy5H0iwgAuJ
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stoewer/parquet-cli v0.0.7 h1:rhdZODIbyMS3twr4OM3am8BPPT5pbfMcHLH93whDM5o=
github.com/stoewer/parquet-cli v0.0.7/go.mod h1:bskxHdj8q3H1EmfuCqjViFoeO3NEvs5lzZAQvI8Nfjk=
+github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/substrait-io/substrait v0.57.1 h1:GW8nnYfSowMseHR8Os82/X6lNtQGIK7p4p+lr6r+auw=
github.com/substrait-io/substrait v0.57.1/go.mod h1:q9s+tjo+gK0lsA+SqYB0lhojNuxvdPdfYlGUP0hjbrA=
github.com/substrait-io/substrait-go v1.2.0 h1:3ZNRkc8FYD7ifCagKEOZQtUcgMceMQfwo2N1NGaK4Q4=
@@ -1035,9 +1060,14 @@ go.opentelemetry.io/contrib/detectors/gcp v1.32.0/go.mod h1:TVqo0Sda4Cv8gCIixd7L
go.opentelemetry.io/contrib/exporters/autoexport v0.53.0 h1:13K+tY7E8GJInkrvRiPAhC0gi/7vKjzDNhtmCf+QXG8=
go.opentelemetry.io/contrib/exporters/autoexport v0.53.0/go.mod h1:lyQF6xQ4iDnMg4sccNdFs1zf62xd79YI8vZqKjOTwMs=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0/go.mod h1:azvtTADFQJA8mX80jIH/akaE7h+dbm/sVuaHqN13w74=
+go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.58.0/go.mod h1:HDBUsEjOuRC0EzKZ1bSaRGZWUBAzo+MhAcUUORSr4D0=
+go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.58.0/go.mod h1:uosvgpqTcTXtcPQORTbEkZNDQTCDOgTz1fe6aLSyqrQ=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg=
+go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0/go.mod h1:umTcuxiv1n/s/S6/c2AT/g2CQ7u5C59sHDNmfSwgz7Q=
go.opentelemetry.io/contrib/propagators/b3 v1.27.0 h1:IjgxbomVrV9za6bRi8fWCNXENs0co37SZedQilP2hm0=
go.opentelemetry.io/contrib/propagators/b3 v1.27.0/go.mod h1:Dv9obQz25lCisDvvs4dy28UPh974CxkahRDUPsY7y9E=
+go.opentelemetry.io/contrib/propagators/jaeger v1.33.0/go.mod h1:ku/EpGk44S5lyVMbtJRK2KFOnXEehxf6SDnhu1eZmjA=
+go.opentelemetry.io/contrib/samplers/jaegerremote v0.27.0/go.mod h1:IohbtCIY5Erb6wKnDddXOMNlG7GwyZnkrgcqjPmhpaA=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
@@ -1131,6 +1161,8 @@ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxb
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
+golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
+golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0 h1:OE9mWmgKkjJyEmDAAtGMPjXu+YNeGvK9VTSHY6+Qihc=
gonum.org/v1/plot v0.14.0 h1:+LBDVFYwFe4LHhdP8coW6296MBEY4nQ+Y4vuUpJopcE=
gonum.org/v1/plot v0.14.0/go.mod h1:MLdR9424SJed+5VqC6MsouEpig9pZX2VZ57H9ko2bXU=
@@ -1144,12 +1176,14 @@ google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a/go.
google.golang.org/genproto/googleapis/api v0.0.0-20241219192143-6b3ec007d9bb/go.mod h1:E5//3O5ZIG2l71Xnt+P/CYUY8Bxs8E7WMoZ9tlcMbAY=
google.golang.org/genproto/googleapis/bytestream v0.0.0-20250102185135-69823020774d h1:NZBSeFsuFS5YrgHMW/8xfTbzNXMshQPNgq2Yb7xipEs=
google.golang.org/genproto/googleapis/bytestream v0.0.0-20250102185135-69823020774d/go.mod h1:s4mHJ3FfG8P6A3O+gZ8TVqB3ufjOl9UG3ANCMMwCHmo=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219192143-6b3ec007d9bb/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422/go.mod h1:3ENsm/5D1mzDyhpzeRi1NR784I0BcofWBoSc5QqqMK4=
+google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
@@ -1180,6 +1214,8 @@ k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 h1:si3PfKm8dDYxgfbeA6orqrtLkv
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
+k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
+k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
modernc.org/cc/v3 v3.36.3 h1:uISP3F66UlixxWEcKuIWERa4TwrZENHSL8tWxZz8bHg=
modernc.org/ccgo/v3 v3.16.9 h1:AXquSwg7GuMk11pIdw7fmO1Y/ybgazVkMhsZWCV0mHM=
diff --git a/pkg/storage/unified/apistore/go.mod b/pkg/storage/unified/apistore/go.mod
index 16380887a73..b7abdb3bb91 100644
--- a/pkg/storage/unified/apistore/go.mod
+++ b/pkg/storage/unified/apistore/go.mod
@@ -192,7 +192,7 @@ require (
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
- github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb // indirect
+ github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44 // indirect
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 // indirect
github.com/grafana/dataplane/sdata v0.0.9 // indirect
github.com/grafana/dskit v0.0.0-20241105154643-a6b453a88040 // indirect
diff --git a/pkg/storage/unified/apistore/go.sum b/pkg/storage/unified/apistore/go.sum
index 40c89cf0360..87e7727af96 100644
--- a/pkg/storage/unified/apistore/go.sum
+++ b/pkg/storage/unified/apistore/go.sum
@@ -566,8 +566,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb h1:WfCsiuZXhGXIdzImQ9/Kjfn9M4e6f7z5mddcSKCRxmI=
-github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
+github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44 h1:vboqvbAO0s0CTALHnqfmNvhCP1ziBcZNpYDbORqvOgg=
+github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 h1:NTMmow+74I3Jb033xhbRgWQS7A//5TDhiM4tl7bsVP4=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7/go.mod h1:T3X4z0ejGfJOiOmZLFeKCRT/yxWJq/RtclAc/PHj/w4=
github.com/grafana/authlib/types v0.0.0-20250219092154-21ce22b49f31 h1:EokLC5grHwLPs4tXW8T6E8187H1e5G9AP0QQ5B60HbA=
diff --git a/pkg/storage/unified/resource/go.mod b/pkg/storage/unified/resource/go.mod
index f2ab921a4f6..833dd96a890 100644
--- a/pkg/storage/unified/resource/go.mod
+++ b/pkg/storage/unified/resource/go.mod
@@ -117,7 +117,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/mux v1.8.1 // indirect
- github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb // indirect
+ github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44 // indirect
github.com/grafana/dataplane/sdata v0.0.9 // indirect
github.com/grafana/grafana-app-sdk/logging v0.30.0 // indirect
github.com/grafana/grafana-aws-sdk v0.31.5 // indirect
diff --git a/pkg/storage/unified/resource/go.sum b/pkg/storage/unified/resource/go.sum
index 40fcf6f458a..7d566e2e658 100644
--- a/pkg/storage/unified/resource/go.sum
+++ b/pkg/storage/unified/resource/go.sum
@@ -397,8 +397,8 @@ github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z
github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
-github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb h1:WfCsiuZXhGXIdzImQ9/Kjfn9M4e6f7z5mddcSKCRxmI=
-github.com/grafana/alerting v0.0.0-20250220212119-4baca04e46bb/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
+github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44 h1:vboqvbAO0s0CTALHnqfmNvhCP1ziBcZNpYDbORqvOgg=
+github.com/grafana/alerting v0.0.0-20250221202230-9d7e00921e44/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7 h1:NTMmow+74I3Jb033xhbRgWQS7A//5TDhiM4tl7bsVP4=
github.com/grafana/authlib v0.0.0-20250219100139-6a3b1bbb50e7/go.mod h1:T3X4z0ejGfJOiOmZLFeKCRT/yxWJq/RtclAc/PHj/w4=
github.com/grafana/authlib/types v0.0.0-20250219092154-21ce22b49f31 h1:EokLC5grHwLPs4tXW8T6E8187H1e5G9AP0QQ5B60HbA=
From bbeae4610502bc2b6375eac60c354b915637f6a7 Mon Sep 17 00:00:00 2001
From: Yuri Tseretyan
Date: Fri, 21 Feb 2025 16:08:40 -0500
Subject: [PATCH 20/22] Alerting: Fix rule state history with annotations
backend (#101174)
* add alertUID to annotations API query parameter
* update state history UI to fetch rule by UID
---------
Signed-off-by: Yuri Tseretyan
---
pkg/api/annotations.go | 8 ++-
.../annotationsimpl/loki/historian_store.go | 12 +++--
.../loki/historian_store_test.go | 50 ++++++++++++++++++-
.../annotations/annotationsimpl/xorm_store.go | 7 ++-
pkg/services/annotations/models.go | 1 +
public/api-merged.json | 8 ++-
.../alerting/unified/api/annotations.test.ts | 2 +-
.../alerting/unified/api/annotations.ts | 4 +-
.../components/rule-viewer/tabs/History.tsx | 3 +-
.../rules/state-history/StateHistory.tsx | 6 +--
.../hooks/useManagedAlertStateHistory.ts | 6 +--
.../unified/hooks/useStateHistoryModal.tsx | 2 +-
.../alerting/unified/state/actions.ts | 2 +-
public/openapi3.json | 10 +++-
14 files changed, 97 insertions(+), 24 deletions(-)
diff --git a/pkg/api/annotations.go b/pkg/api/annotations.go
index 5612fd4a639..4720e25e91f 100644
--- a/pkg/api/annotations.go
+++ b/pkg/api/annotations.go
@@ -41,6 +41,7 @@ func (hs *HTTPServer) GetAnnotations(c *contextmodel.ReqContext) response.Respon
OrgID: c.SignedInUser.GetOrgID(),
UserID: c.QueryInt64("userId"),
AlertID: c.QueryInt64("alertId"),
+ AlertUID: c.Query("alertUID"),
DashboardID: c.QueryInt64("dashboardId"),
DashboardUID: c.Query("dashboardUID"),
PanelID: c.QueryInt64("panelId"),
@@ -744,10 +745,15 @@ type GetAnnotationsParams struct {
// in:query
// required:false
UserID int64 `json:"userId"`
- // Find annotations for a specified alert.
+ // Find annotations for a specified alert rule by its ID.
+ // deprecated: AlertID is deprecated and will be removed in future versions. Please use AlertUID instead.
// in:query
// required:false
AlertID int64 `json:"alertId"`
+ // Find annotations for a specified alert rule by its UID.
+ // in:query
+ // required:false
+ AlertUID string `json:"alertUID"`
// Find annotations that are scoped to a specific dashboard
// in:query
// required:false
diff --git a/pkg/services/annotations/annotationsimpl/loki/historian_store.go b/pkg/services/annotations/annotationsimpl/loki/historian_store.go
index 563d4435be7..5bc4e02d303 100644
--- a/pkg/services/annotations/annotationsimpl/loki/historian_store.go
+++ b/pkg/services/annotations/annotationsimpl/loki/historian_store.go
@@ -91,20 +91,22 @@ func (r *LokiHistorianStore) Get(ctx context.Context, query annotations.ItemQuer
return make([]*annotations.ItemDTO, 0), nil
}
- rule := &ngmodels.AlertRule{}
- if query.AlertID != 0 {
- var err error
- rule, err = r.ruleStore.GetRuleByID(ctx, ngmodels.GetAlertRuleByIDQuery{OrgID: query.OrgID, ID: query.AlertID})
+ var ruleUID string
+ if query.AlertUID != "" {
+ ruleUID = query.AlertUID
+ } else if query.AlertID != 0 {
+ rule, err := r.ruleStore.GetRuleByID(ctx, ngmodels.GetAlertRuleByIDQuery{OrgID: query.OrgID, ID: query.AlertID})
if err != nil {
if errors.Is(err, ngmodels.ErrAlertRuleNotFound) {
return make([]*annotations.ItemDTO, 0), ErrLokiStoreNotFound.Errorf("rule with ID %d does not exist", query.AlertID)
}
return make([]*annotations.ItemDTO, 0), ErrLokiStoreInternal.Errorf("failed to query rule: %w", err)
}
+ ruleUID = rule.UID
}
// No folders in the filter because it filter by Dashboard UID, and the request is already authorized.
- logQL, err := historian.BuildLogQuery(buildHistoryQuery(&query, accessResources.Dashboards, rule.UID), nil, r.client.MaxQuerySize())
+ logQL, err := historian.BuildLogQuery(buildHistoryQuery(&query, accessResources.Dashboards, ruleUID), nil, r.client.MaxQuerySize())
if err != nil {
grafanaErr := errutil.Error{}
if errors.As(err, &grafanaErr) {
diff --git a/pkg/services/annotations/annotationsimpl/loki/historian_store_test.go b/pkg/services/annotations/annotationsimpl/loki/historian_store_test.go
index f4e4bf6630a..67ebca32918 100644
--- a/pkg/services/annotations/annotationsimpl/loki/historian_store_test.go
+++ b/pkg/services/annotations/annotationsimpl/loki/historian_store_test.go
@@ -108,7 +108,34 @@ func TestIntegrationAlertStateHistoryStore(t *testing.T) {
require.Len(t, res, numTransitions)
})
- t.Run("should return ErrLokiStoreNotFound if rule is not found", func(t *testing.T) {
+ t.Run("can query history by alert uid", func(t *testing.T) {
+ rule := dashboardRules[dashboard1.UID][0]
+
+ fakeLokiClient.rangeQueryRes = []historian.Stream{
+ historian.StatesToStream(ruleMetaFromRule(t, rule), transitions, map[string]string{}, log.NewNopLogger()),
+ }
+
+ query := annotations.ItemQuery{
+ OrgID: 1,
+ AlertUID: rule.UID,
+ From: start.UnixMilli(),
+ To: start.Add(time.Second * time.Duration(numTransitions+1)).UnixMilli(),
+ }
+ res, err := store.Get(
+ context.Background(),
+ query,
+ &annotation_ac.AccessResources{
+ Dashboards: map[string]int64{
+ dashboard1.UID: dashboard1.ID,
+ },
+ CanAccessDashAnnotations: true,
+ },
+ )
+ require.NoError(t, err)
+ require.Len(t, res, numTransitions)
+ })
+
+ t.Run("should return ErrLokiStoreNotFound if rule is not found by ID", func(t *testing.T) {
var rules = slices.Concat(maps.Values(dashboardRules)...)
id := rand.Int63n(1000) // in Postgres ID is integer, so limit range
// make sure id is not known
@@ -137,6 +164,27 @@ func TestIntegrationAlertStateHistoryStore(t *testing.T) {
require.ErrorIs(t, err, ErrLokiStoreNotFound)
})
+ t.Run("should return empty response if rule is not found by UID", func(t *testing.T) {
+ query := annotations.ItemQuery{
+ OrgID: 1,
+ AlertUID: "not-found-uid",
+ From: start.UnixMilli(),
+ To: start.Add(time.Second * time.Duration(numTransitions+1)).UnixMilli(),
+ }
+ res, err := store.Get(
+ context.Background(),
+ query,
+ &annotation_ac.AccessResources{
+ Dashboards: map[string]int64{
+ dashboard1.UID: dashboard1.ID,
+ },
+ CanAccessDashAnnotations: true,
+ },
+ )
+ require.NoError(t, err)
+ require.Empty(t, res)
+ })
+
t.Run("can query history by dashboard id", func(t *testing.T) {
fakeLokiClient.rangeQueryRes = []historian.Stream{
historian.StatesToStream(ruleMetaFromRule(t, dashboardRules[dashboard1.UID][0]), transitions, map[string]string{}, log.NewNopLogger()),
diff --git a/pkg/services/annotations/annotationsimpl/xorm_store.go b/pkg/services/annotations/annotationsimpl/xorm_store.go
index 603ec3865e8..7b957189312 100644
--- a/pkg/services/annotations/annotationsimpl/xorm_store.go
+++ b/pkg/services/annotations/annotationsimpl/xorm_store.go
@@ -267,10 +267,10 @@ func (r *xormRepositoryImpl) Get(ctx context.Context, query annotations.ItemQuer
annotation.updated,
usr.email,
usr.login,
- alert.name as alert_name
+ r.title as alert_name
FROM annotation
LEFT OUTER JOIN ` + r.db.GetDialect().Quote("user") + ` as usr on usr.id = annotation.user_id
- LEFT OUTER JOIN alert on alert.id = annotation.alert_id
+ LEFT OUTER JOIN alert_rule as r on r.id = annotation.alert_id
INNER JOIN (
SELECT a.id from annotation a
`)
@@ -287,6 +287,9 @@ func (r *xormRepositoryImpl) Get(ctx context.Context, query annotations.ItemQuer
if query.AlertID != 0 {
sql.WriteString(` AND a.alert_id = ?`)
params = append(params, query.AlertID)
+ } else if query.AlertUID != "" {
+ sql.WriteString(` AND a.alert_id = (SELECT id FROM alert_rule WHERE uid = ? and org_id = ?)`)
+ params = append(params, query.AlertUID, query.OrgID)
}
if query.DashboardID != 0 {
diff --git a/pkg/services/annotations/models.go b/pkg/services/annotations/models.go
index c9f22140d6f..9dcd23755ea 100644
--- a/pkg/services/annotations/models.go
+++ b/pkg/services/annotations/models.go
@@ -11,6 +11,7 @@ type ItemQuery struct {
To int64 `json:"to"`
UserID int64 `json:"userId"`
AlertID int64 `json:"alertId"`
+ AlertUID string `json:"alertUID"`
DashboardID int64 `json:"dashboardId"`
DashboardUID string `json:"dashboardUID"`
PanelID int64 `json:"panelId"`
diff --git a/public/api-merged.json b/public/api-merged.json
index 04ffb5ef505..09bd1962ae9 100644
--- a/public/api-merged.json
+++ b/public/api-merged.json
@@ -1833,10 +1833,16 @@
{
"type": "integer",
"format": "int64",
- "description": "Find annotations for a specified alert.",
+ "description": "Find annotations for a specified alert rule by its ID.\ndeprecated: AlertID is deprecated and will be removed in future versions. Please use AlertUID instead.",
"name": "alertId",
"in": "query"
},
+ {
+ "type": "string",
+ "description": "Find annotations for a specified alert rule by its UID.",
+ "name": "alertUID",
+ "in": "query"
+ },
{
"type": "integer",
"format": "int64",
diff --git a/public/app/features/alerting/unified/api/annotations.test.ts b/public/app/features/alerting/unified/api/annotations.test.ts
index 01da8c9da97..f80d7e8f22c 100644
--- a/public/app/features/alerting/unified/api/annotations.test.ts
+++ b/public/app/features/alerting/unified/api/annotations.test.ts
@@ -21,7 +21,7 @@ describe('annotations', () => {
it('should fetch annotation for an alertId', () => {
const ALERT_ID = 'abc123';
fetchAnnotations(ALERT_ID);
- expect(get).toBeCalledWith('/api/annotations', { alertId: ALERT_ID });
+ expect(get).toBeCalledWith('/api/annotations', { alertUID: ALERT_ID });
});
});
diff --git a/public/app/features/alerting/unified/api/annotations.ts b/public/app/features/alerting/unified/api/annotations.ts
index 39195dc1f48..2e0d577ffbf 100644
--- a/public/app/features/alerting/unified/api/annotations.ts
+++ b/public/app/features/alerting/unified/api/annotations.ts
@@ -1,10 +1,10 @@
import { getBackendSrv } from '@grafana/runtime';
import { StateHistoryItem } from 'app/types/unified-alerting';
-export function fetchAnnotations(alertId: string): Promise {
+export function fetchAnnotations(alertUID: string): Promise {
return getBackendSrv()
.get('/api/annotations', {
- alertId,
+ alertUID,
})
.then((result) => {
return result?.sort(sortStateHistory);
diff --git a/public/app/features/alerting/unified/components/rule-viewer/tabs/History.tsx b/public/app/features/alerting/unified/components/rule-viewer/tabs/History.tsx
index bed499ce2a2..b946c0a65f7 100644
--- a/public/app/features/alerting/unified/components/rule-viewer/tabs/History.tsx
+++ b/public/app/features/alerting/unified/components/rule-viewer/tabs/History.tsx
@@ -26,13 +26,12 @@ const History = ({ rule }: HistoryProps) => {
? StateHistoryImplementation.Loki
: StateHistoryImplementation.Annotations;
- const ruleID = rule.grafana_alert.id ?? '';
const ruleUID = rule.grafana_alert.uid;
return (
{implementation === StateHistoryImplementation.Loki && }
- {implementation === StateHistoryImplementation.Annotations && }
+ {implementation === StateHistoryImplementation.Annotations && }
);
};
diff --git a/public/app/features/alerting/unified/components/rules/state-history/StateHistory.tsx b/public/app/features/alerting/unified/components/rules/state-history/StateHistory.tsx
index a0388b41464..128dbaf1087 100644
--- a/public/app/features/alerting/unified/components/rules/state-history/StateHistory.tsx
+++ b/public/app/features/alerting/unified/components/rules/state-history/StateHistory.tsx
@@ -27,16 +27,16 @@ type StateHistoryMap = Record;
type StateHistoryRow = DynamicTableItemProps;
interface Props {
- alertId: string;
+ ruleUID: string;
}
-const StateHistory = ({ alertId }: Props) => {
+const StateHistory = ({ ruleUID }: Props) => {
const [textFilter, setTextFilter] = useState('');
const handleTextFilter = useCallback((event: FormEvent) => {
setTextFilter(event.currentTarget.value);
}, []);
- const { loading, error, result = [] } = useManagedAlertStateHistory(alertId);
+ const { loading, error, result = [] } = useManagedAlertStateHistory(ruleUID);
const styles = useStyles2(getStyles);
diff --git a/public/app/features/alerting/unified/hooks/useManagedAlertStateHistory.ts b/public/app/features/alerting/unified/hooks/useManagedAlertStateHistory.ts
index 43b10d666f5..e7902fcf507 100644
--- a/public/app/features/alerting/unified/hooks/useManagedAlertStateHistory.ts
+++ b/public/app/features/alerting/unified/hooks/useManagedAlertStateHistory.ts
@@ -8,15 +8,15 @@ import { AsyncRequestState } from '../utils/redux';
import { useUnifiedAlertingSelector } from './useUnifiedAlertingSelector';
-export function useManagedAlertStateHistory(alertId: string) {
+export function useManagedAlertStateHistory(ruleUID: string) {
const dispatch = useDispatch();
const history = useUnifiedAlertingSelector>(
(state) => state.managedAlertStateHistory
);
useEffect(() => {
- dispatch(fetchGrafanaAnnotationsAction(alertId));
- }, [dispatch, alertId]);
+ dispatch(fetchGrafanaAnnotationsAction(ruleUID));
+ }, [dispatch, ruleUID]);
return history;
}
diff --git a/public/app/features/alerting/unified/hooks/useStateHistoryModal.tsx b/public/app/features/alerting/unified/hooks/useStateHistoryModal.tsx
index c5c527c414a..3da0bc08e07 100644
--- a/public/app/features/alerting/unified/hooks/useStateHistoryModal.tsx
+++ b/public/app/features/alerting/unified/hooks/useStateHistoryModal.tsx
@@ -61,7 +61,7 @@ function useStateHistoryModal() {
{implementation === StateHistoryImplementation.Loki && }
{implementation === StateHistoryImplementation.Annotations && (
-
+
)}
diff --git a/public/app/features/alerting/unified/state/actions.ts b/public/app/features/alerting/unified/state/actions.ts
index 7c05181fd53..91adf4a5568 100644
--- a/public/app/features/alerting/unified/state/actions.ts
+++ b/public/app/features/alerting/unified/state/actions.ts
@@ -183,7 +183,7 @@ export function fetchAllPromRulesAction(
export const fetchGrafanaAnnotationsAction = createAsyncThunk(
'unifiedalerting/fetchGrafanaAnnotations',
- (alertId: string): Promise => withSerializedError(fetchAnnotations(alertId))
+ (ruleUID: string): Promise => withSerializedError(fetchAnnotations(ruleUID))
);
interface UpdateAlertManagerConfigActionOptions {
diff --git a/public/openapi3.json b/public/openapi3.json
index 3aa7a775761..e5be6cd60ce 100644
--- a/public/openapi3.json
+++ b/public/openapi3.json
@@ -15316,7 +15316,7 @@
}
},
{
- "description": "Find annotations for a specified alert.",
+ "description": "Find annotations for a specified alert rule by its ID.\ndeprecated: AlertID is deprecated and will be removed in future versions. Please use AlertUID instead.",
"in": "query",
"name": "alertId",
"schema": {
@@ -15324,6 +15324,14 @@
"type": "integer"
}
},
+ {
+ "description": "Find annotations for a specified alert rule by its UID.",
+ "in": "query",
+ "name": "alertUID",
+ "schema": {
+ "type": "string"
+ }
+ },
{
"description": "Find annotations that are scoped to a specific dashboard",
"in": "query",
From 95b88e592dcaa04557c05e1a61d70964d8012dc7 Mon Sep 17 00:00:00 2001
From: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com>
Date: Fri, 21 Feb 2025 17:19:54 -0500
Subject: [PATCH 21/22] [DOC] Add shared note for Explore app rename to
Drilldown (#101166)
---
.../explore/simplified-exploration/_index.md | 4 +++-
.../simplified-exploration/metrics/index.md | 12 +++++++-----
docs/sources/shared/plugins/rename-note.md | 19 +++++++++++++++++++
3 files changed, 29 insertions(+), 6 deletions(-)
create mode 100644 docs/sources/shared/plugins/rename-note.md
diff --git a/docs/sources/explore/simplified-exploration/_index.md b/docs/sources/explore/simplified-exploration/_index.md
index bf43b04d41e..360b37aee5a 100644
--- a/docs/sources/explore/simplified-exploration/_index.md
+++ b/docs/sources/explore/simplified-exploration/_index.md
@@ -12,7 +12,7 @@ hero:
level: 1
width: 100
height: 100
- description: Use the Drilldown apps to investigate and identify issues using telemetry data.
+ description: Use the Grafana Drilldown apps to investigate and identify issues using telemetry data.
cards:
title_class: pt-0 lh-1
items:
@@ -40,6 +40,8 @@ The Grafana Drilldown apps are designed for effortless data exploration through
Easily explore telemetry signals with these specialized tools, tailored specifically for the Grafana databases to provide quick and accurate insights.
+{{< docs/shared source="grafana" lookup="plugins/rename-note.md" version="" >}}
+
To learn more, read:
- [From multi-line queries to no-code investigations: meeting Grafana users where they are](https://grafana.com/blog/2024/10/22/from-multi-line-queries-to-no-code-investigations-meeting-grafana-users-where-they-are/)
diff --git a/docs/sources/explore/simplified-exploration/metrics/index.md b/docs/sources/explore/simplified-exploration/metrics/index.md
index a9d5d291772..eb6d23509e5 100644
--- a/docs/sources/explore/simplified-exploration/metrics/index.md
+++ b/docs/sources/explore/simplified-exploration/metrics/index.md
@@ -16,7 +16,9 @@ weight: 200
Grafana Metrics Drilldown is a query-less experience for browsing **Prometheus-compatible** metrics. Quickly find related metrics with just a few simple clicks, without needing to write PromQL queries to retrieve metrics.
-With Grafana Metrics Drilldown, you can:
+{{< docs/shared source="grafana" lookup="plugins/rename-note.md" version="" >}}
+
+With Metrics Drilldown, you can:
- Easily segment metrics based on their labels, so you can immediately spot anomalies and identify issues.
- Automatically display the optimal visualization for each metric type (gauge vs. counter, for example) without manual setup.
@@ -25,13 +27,13 @@ With Grafana Metrics Drilldown, you can:
- View a history of user steps when navigating through metrics and their filters.
- Seamlessly pivot to related telemetry, including log data.
-{{< docs/play title="Grafana Metrics Drilldown" url="https://play.grafana.org/explore/metrics/trail?from=now-1h&to=now&var-ds=grafanacloud-demoinfra-prom&var-filters=&refresh=&metricPrefix=all" >}}
+{{< docs/play title="Metrics Drilldown" url="https://play.grafana.org/explore/metrics/trail?from=now-1h&to=now&var-ds=grafanacloud-demoinfra-prom&var-filters=&refresh=&metricPrefix=all" >}}
-You can access Grafana Metrics Drilldown either as a standalone experience or as part of Grafana dashboards.
+You can access Metrics Drilldown either as a standalone experience or as part of Grafana dashboards.
## Standalone experience
-To access Grafana Metrics Drilldown as a standalone experience:
+To access Metrics Drilldown as a standalone experience:
1. Click the arrow next to **Drilldown** in the Grafana left-side menu and click **Metrics**. You are taken to an overview page that shows recent metrics, bookmarks, and the option to select a new metric exploration.
1. To get started with a new exploration, click **Let's start!**.
@@ -63,7 +65,7 @@ After you have gathered your metrics exploration data you can:
## Dashboard experience
-To access Grafana Metrics Drilldown via a dashboard:
+To access Metrics Drilldown via a dashboard:
1. Navigate to your dashboard.
1. Select a time series panel.
diff --git a/docs/sources/shared/plugins/rename-note.md b/docs/sources/shared/plugins/rename-note.md
new file mode 100644
index 00000000000..5eaa9a1adf4
--- /dev/null
+++ b/docs/sources/shared/plugins/rename-note.md
@@ -0,0 +1,19 @@
+---
+headless: true
+labels:
+ products:
+ - enterprise
+ - oss
+---
+
+[//]: # 'This file contains a rename note for Explore to Drilldown apps.'
+[//]: # 'This shared file is included in a lot of files. Check the app docs in'
+[//]: # 'drilldown-traces, drilldown-logs, drilldown-profiles, grafana, and website/grafana-cloud.'
+[//]: # 'If you make changes to this file, verify that the meaning and content are not changed in any place where the file is included.'
+[//]: # 'Any links should be fully qualified and not relative: /docs/grafana/ instead of ../grafana/.'
+
+{{< admonition type="note" >}}
+The Grafana Explore apps have changed to Grafana Drilldown apps.
+For example, Explore Logs is now Logs Drilldown.
+To learn more, read [Grafana Drilldown apps: the improved queryless experience known as the Explore apps](https://grafana.com/blog/2025/02/20/grafana-drilldown-apps-the-improved-queryless-experience-formerly-known-as-the-explore-apps/).
+{{< /admonition >}}
From ba352af6638b91379bb6e898c1fb54e9cb27e927 Mon Sep 17 00:00:00 2001
From: Yuri Tseretyan
Date: Fri, 21 Feb 2025 18:46:03 -0500
Subject: [PATCH 22/22] Alerting: Github Action to update alerting module
(#100999)
---
.github/CODEOWNERS | 1 +
.github/workflows/alerting-update-module.yml | 130 +++++++++++++++++++
2 files changed, 131 insertions(+)
create mode 100644 .github/workflows/alerting-update-module.yml
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 90689b24a05..92581c315aa 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -757,6 +757,7 @@ embed.go @grafana/grafana-as-code
/.github/workflows/add-to-whats-new.yml @grafana/docs-tooling
/.github/workflows/auto-triager/ @grafana/plugins-platform-frontend
/.github/workflows/alerting-swagger-gen.yml @grafana/alerting-backend
+/.github/workflows/alerting-update-module.yml @grafana/alerting-backend
/.github/workflows/auto-milestone.yml @grafana/grafana-developer-enablement-squad
/.github/workflows/backport.yml @grafana/grafana-developer-enablement-squad
/.github/workflows/bump-version.yml @grafana/grafana-developer-enablement-squad
diff --git a/.github/workflows/alerting-update-module.yml b/.github/workflows/alerting-update-module.yml
new file mode 100644
index 00000000000..eece934525e
--- /dev/null
+++ b/.github/workflows/alerting-update-module.yml
@@ -0,0 +1,130 @@
+name: Update Alerting Module
+
+on:
+ workflow_dispatch:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ update-grafana:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
+
+ - name: Check if update branch exists
+ run: |
+ if git ls-remote --heads origin update-alerting-module | grep -q 'update-alerting-module'; then
+ echo "Branch 'update-alerting-module' already exists. There might be an open PR with Grafana updates."
+ echo "Please review and merge/close the existing PR before running this workflow again."
+ exit 1
+ fi
+
+ - name: Setup Go
+ uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # 5.3.0
+ with:
+ "go-version-file": "go.mod"
+
+ - name: Extract current commit hash of alerting module
+ id: current-commit
+ run: |
+ FROM_COMMIT=$(go list -m -json github.com/grafana/alerting | jq -r '.Version' | grep -oP '(?<=-)[a-f0-9]+$')
+ echo "from_commit=$FROM_COMMIT" >> $GITHUB_OUTPUT
+
+ - name: Get latest commit
+ id: latest-commit
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ TO_COMMIT=$(gh api repos/grafana/alerting/commits/main --jq '.sha')
+ if [ -z "$TO_COMMIT" ]; then
+ echo "Failed to fetch latest commit"
+ exit 1
+ fi
+ echo "to_commit=$TO_COMMIT" >> $GITHUB_OUTPUT
+
+ - name: Compare commit hashes
+ run: |
+ FROM_COMMIT="${{ steps.current-commit.outputs.from_commit }}"
+ TO_COMMIT="${{ steps.latest-commit.outputs.to_commit }}"
+
+ # Compare just the length of the shorter hash
+ SHORT_TO_COMMIT="${TO_COMMIT:0:${#FROM_COMMIT}}"
+
+ if [ "$FROM_COMMIT" = "$SHORT_TO_COMMIT" ]; then
+ echo "Current version ($FROM_COMMIT) is already at latest ($SHORT_TO_COMMIT). No update needed."
+ exit 0
+ fi
+ echo "Updates available: $FROM_COMMIT -> $TO_COMMIT"
+
+ - name: Check for commit history
+ id: check-commits
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ # get all commits that contains 'Alerting:' in the message
+ ALERTING_COMMITS=$(gh api repos/grafana/alerting/compare/${{ steps.current-commit.outputs.from_commit }}...${{ steps.latest-commit.outputs.to_commit }} \
+ --jq '.commits[].commit.message | split("\n")[0]') || true
+
+ # Use printf instead of echo -e for better multiline handling
+ printf "%s\n" "$ALERTING_COMMITS"
+
+ # make the list for markdown and replace PR numbers with links
+ ALERTING_COMMITS_FORMATTED=$(echo "$ALERTING_COMMITS" | while read -r line; do echo "- $line" | sed -E 's/\(#([0-9]+)\)/[#\1](https:\/\/github.com\/grafana\/grafana\/pull\/\1)/g'; done)
+
+ echo "alerting_commits<> $GITHUB_OUTPUT
+ echo "$ALERTING_COMMITS_FORMATTED" >> $GITHUB_OUTPUT
+ echo "EOF" >> $GITHUB_OUTPUT
+
+ - name: Update alerting module
+ env:
+ GOSUMDB: off
+ run: |
+ go get github.com/grafana/alerting@${{ steps.latest-commit.outputs.to_commit }}
+ make update-workspace
+
+ - id: get-secrets
+ uses: grafana/shared-workflows/actions/get-vault-secrets@28361cdb22223e5f1e34358c86c20908e7248760 # 1.1.0
+ with:
+ repo_secrets: |
+ GITHUB_APP_ID=github-app:app-id
+ GITHUB_APP_PRIVATE_KEY=github-app:private-key
+
+ - name: "Generate token"
+ id: generate_token
+ uses: actions/create-github-app-token@0d564482f06ca65fa9e77e2510873638c82206f2 # 1.11.5
+ with:
+ app-id: ${{ env.GITHUB_APP_ID }}
+ private-key: ${{ env.GITHUB_APP_PRIVATE_KEY }}
+
+ - name: Create Pull Request
+ uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # 7.0.6
+ id: create-pr
+ with:
+ token: '${{ steps.generate_token.outputs.token }}'
+ title: 'Alerting: Update alerting module to ${{ steps.latest-commit.outputs.to_commit }}'
+ branch: alerting/update-alerting-module
+ delete-branch: true
+ body: |
+ Updates Grafana Alerting module to latest version.
+
+ Compare changes: https://github.com/grafana/alerting/compare/${{ steps.current-commit.outputs.from_commit }}...${{ steps.latest-commit.outputs.to_commit }}
+
+ Commits
+
+ ${{ steps.check-commits.outputs.alerting_commits }}
+
+
+
+ Created by: [GitHub Action Job](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
+ - name: Add PR URL to Summary
+ if: steps.create-pr.outputs.pull-request-url != ''
+ run: |
+ echo "## Pull Request Created" >> $GITHUB_STEP_SUMMARY
+ echo "🔗 [View Pull Request](${{ steps.create-pr.outputs.pull-request-url }})" >> $GITHUB_STEP_SUMMARY
\ No newline at end of file