[v9.2.x] Expressions: Fixes the issue showing expressions editor (#62626)
* Expressions: Fixes the issue showing expressions editor (#62510)
* Use suggested value for uid
* update the snapshot
* use __expr__
* replace all -100 with __expr__
* update snapshot
* more changes
* revert redundant change
* Use expr.DatasourceUID where it's possible
* generate files
(cherry picked from commit 91221bc436)
* unit text fix
This commit is contained in:
@@ -23,7 +23,7 @@ apiVersion: 1
|
||||
# # evaluation - should be obtained via the API
|
||||
# data:
|
||||
# - refId: A
|
||||
# datasourceUid: "-100"
|
||||
# datasourceUid: "__expr__"
|
||||
# model:
|
||||
# conditions:
|
||||
# - evaluator:
|
||||
@@ -40,7 +40,7 @@ apiVersion: 1
|
||||
# type: query
|
||||
# datasource:
|
||||
# type: __expr__
|
||||
# uid: "-100"
|
||||
# uid: "__expr__"
|
||||
# expression: 1==0
|
||||
# intervalMs: 1000
|
||||
# maxDataPoints: 43200
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ groups:
|
||||
# evaluation - should be obtained trough the API
|
||||
data:
|
||||
- refId: A
|
||||
datasourceUid: '-100'
|
||||
datasourceUid: '__expr__'
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -86,7 +86,7 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: '-100'
|
||||
uid: '__expr__'
|
||||
expression: 1==0
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
|
||||
+2
-2
@@ -275,7 +275,7 @@ resource "grafana_rule_group" "my_rule_group" {
|
||||
|
||||
// The query was configured to obtain data from the last 60 seconds. Let's alert on the average value of that series using a Reduce stage.
|
||||
data {
|
||||
datasource_uid = "-100"
|
||||
datasource_uid = "__expr__"
|
||||
// You can also create a rule in the UI, then GET that rule to obtain the JSON.
|
||||
// This can be helpful when using more complex reduce expressions.
|
||||
model = <<EOT
|
||||
@@ -291,7 +291,7 @@ EOT
|
||||
// Now, let's use a math expression as our threshold.
|
||||
// We want to alert when the value of stage "B" above exceeds 70.
|
||||
data {
|
||||
datasource_uid = "-100"
|
||||
datasource_uid = "__expr__"
|
||||
ref_id = "C"
|
||||
relative_time_range {
|
||||
from = 0
|
||||
|
||||
@@ -821,36 +821,36 @@ Status: Bad Request
|
||||
|
||||
**Properties**
|
||||
|
||||
| Name | Type | Go type | Required | Default | Description | Example |
|
||||
| --------------------------------------------------------- | ----------------------------------------- | ------------------- | :------: | ------- | -------------------------------------------------------------------------------------------------- | ------- |
|
||||
| DatasourceUID | string | `string` | | | Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation. | |
|
||||
| Model | object | `interface{}` | | | JSON is the raw JSON query and includes the above properties as well as custom properties. | |
|
||||
| QueryType | string | `string` | | | QueryType is an optional identifier for the type of query. |
|
||||
| Name | Type | Go type | Required | Default | Description | Example |
|
||||
| --------------------------------------------------------- | ----------------------------------------- | ------------------- | :------: | ------- | ------------------------------------------------------------------------------------------------------ | ------- |
|
||||
| DatasourceUID | string | `string` | | | Grafana data source unique identifier; it should be '**expr**' for a Server Side Expression operation. | |
|
||||
| Model | object | `interface{}` | | | JSON is the raw JSON query and includes the above properties as well as custom properties. | |
|
||||
| QueryType | string | `string` | | | QueryType is an optional identifier for the type of query. |
|
||||
| It can be used to distinguish different types of queries. | |
|
||||
| RefID | string | `string` | | | RefID is the unique identifier of the query, set by the frontend call. | |
|
||||
| relativeTimeRange | [RelativeTimeRange](#relative-time-range) | `RelativeTimeRange` | | | | |
|
||||
| RefID | string | `string` | | | RefID is the unique identifier of the query, set by the frontend call. | |
|
||||
| relativeTimeRange | [RelativeTimeRange](#relative-time-range) | `RelativeTimeRange` | | | | |
|
||||
|
||||
### <span id="alert-rule"></span> AlertRule
|
||||
|
||||
**Properties**
|
||||
|
||||
| Name | Type | Go type | Required | Default | Description | Example |
|
||||
| ------------ | ---------------------------- | ------------------- | :------: | ------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Annotations | map of string | `map[string]string` | | | | `{"runbook_url":"https://supercoolrunbook.com/page/13"}` |
|
||||
| Condition | string | `string` | ✓ | | | `A` |
|
||||
| Data | [][alertquery](#alert-query) | `[]*AlertQuery` | ✓ | | | `[{"datasourceUid":"-100","model":{"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":[]},"reducer":{"params":[],"type":"avg"},"type":"query"}],"datasource":{"type":"__expr__","uid":"__expr__"},"expression":"1 == 1","hide":false,"intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"},"queryType":"","refId":"A","relativeTimeRange":{"from":0,"to":0}}]` |
|
||||
| ExecErrState | string | `string` | ✓ | | Allowed values: "OK", "Alerting", "Error" | |
|
||||
| FolderUID | string | `string` | ✓ | | | `project_x` |
|
||||
| ID | int64 (formatted integer) | `int64` | | | | |
|
||||
| Labels | map of string | `map[string]string` | | | | `{"team":"sre-team-1"}` |
|
||||
| NoDataState | string | `string` | ✓ | | Allowed values: "OK", "NoData", "Error" | |
|
||||
| OrgID | int64 (formatted integer) | `int64` | ✓ | | | |
|
||||
| RuleGroup | string | `string` | ✓ | | | `eval_group_1` |
|
||||
| Title | string | `string` | ✓ | | | `Always firing` |
|
||||
| UID | string | `string` | | | | |
|
||||
| Updated | date-time (formatted string) | `strfmt.DateTime` | | | | |
|
||||
| for | [Duration](#duration) | `Duration` | ✓ | | | |
|
||||
| provenance | string | `Provenance` | | | | |
|
||||
| Name | Type | Go type | Required | Default | Description | Example |
|
||||
| ------------ | ---------------------------- | ------------------- | :------: | ------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Annotations | map of string | `map[string]string` | | | | `{"runbook_url":"https://supercoolrunbook.com/page/13"}` |
|
||||
| Condition | string | `string` | ✓ | | | `A` |
|
||||
| Data | [][alertquery](#alert-query) | `[]*AlertQuery` | ✓ | | | `[{"datasourceUid":"__expr__","model":{"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":[]},"reducer":{"params":[],"type":"avg"},"type":"query"}],"datasource":{"type":"__expr__","uid":"__expr__"},"expression":"1 == 1","hide":false,"intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"},"queryType":"","refId":"A","relativeTimeRange":{"from":0,"to":0}}]` |
|
||||
| ExecErrState | string | `string` | ✓ | | Allowed values: "OK", "Alerting", "Error" | |
|
||||
| FolderUID | string | `string` | ✓ | | | `project_x` |
|
||||
| ID | int64 (formatted integer) | `int64` | | | | |
|
||||
| Labels | map of string | `map[string]string` | | | | `{"team":"sre-team-1"}` |
|
||||
| NoDataState | string | `string` | ✓ | | Allowed values: "OK", "NoData", "Error" | |
|
||||
| OrgID | int64 (formatted integer) | `int64` | ✓ | | | |
|
||||
| RuleGroup | string | `string` | ✓ | | | `eval_group_1` |
|
||||
| Title | string | `string` | ✓ | | | `Always firing` |
|
||||
| UID | string | `string` | | | | |
|
||||
| Updated | date-time (formatted string) | `strfmt.DateTime` | | | | |
|
||||
| for | [Duration](#duration) | `Duration` | ✓ | | | |
|
||||
| provenance | string | `Provenance` | | | | |
|
||||
|
||||
### <span id="alert-rule-group"></span> AlertRuleGroup
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -624,7 +625,7 @@ func insertTestRule(t *testing.T, sqlStore *sqlstore.SQLStore, foderOrgID int64,
|
||||
Data: []alertQuery{
|
||||
{
|
||||
RefID: "A",
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -570,7 +571,7 @@ func withClassicConditionSingleQuery() func(r *ngmodels.AlertRule) {
|
||||
RefID: "B",
|
||||
QueryType: "",
|
||||
RelativeTimeRange: ngmodels.RelativeTimeRange{From: ngmodels.Duration(0), To: ngmodels.Duration(0)},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(fmt.Sprintf(classicConditionsModel, "A", "B")),
|
||||
},
|
||||
}
|
||||
@@ -599,21 +600,21 @@ func withExpressionsMultiQuery() func(r *ngmodels.AlertRule) {
|
||||
RefID: "C",
|
||||
QueryType: "",
|
||||
RelativeTimeRange: ngmodels.RelativeTimeRange{From: ngmodels.Duration(0), To: ngmodels.Duration(0)},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(fmt.Sprintf(reduceLastExpressionModel, "A", "C")),
|
||||
},
|
||||
{
|
||||
RefID: "D",
|
||||
QueryType: "",
|
||||
RelativeTimeRange: ngmodels.RelativeTimeRange{From: ngmodels.Duration(0), To: ngmodels.Duration(0)},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(fmt.Sprintf(reduceLastExpressionModel, "B", "D")),
|
||||
},
|
||||
{
|
||||
RefID: "E",
|
||||
QueryType: "",
|
||||
RelativeTimeRange: ngmodels.RelativeTimeRange{From: ngmodels.Duration(0), To: ngmodels.Duration(0)},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(fmt.Sprintf(mathExpressionModel, "A", "B", "E")),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ const classicConditionsModel = `
|
||||
}],
|
||||
"datasource": {
|
||||
"type": "__expr__",
|
||||
"uid": "-100"
|
||||
"uid": "__expr__"
|
||||
},
|
||||
"hide": false,
|
||||
"intervalMs": 1000,
|
||||
|
||||
@@ -227,7 +227,9 @@ func (api *API) authorize(method, path string) web.Handler {
|
||||
// authorizeDatasourceAccessForRule checks that user has access to all data sources declared by the rule
|
||||
func authorizeDatasourceAccessForRule(rule *ngmodels.AlertRule, evaluator func(evaluator ac.Evaluator) bool) bool {
|
||||
for _, query := range rule.Data {
|
||||
if query.QueryType == expr.DatasourceType || query.DatasourceUID == expr.OldDatasourceUID {
|
||||
if query.QueryType == expr.DatasourceType || query.DatasourceUID == expr.DatasourceUID || query.
|
||||
DatasourceUID == expr.
|
||||
OldDatasourceUID {
|
||||
continue
|
||||
}
|
||||
if !evaluator(ac.EvalPermission(datasources.ActionQuery, datasources.ScopeProvider.GetResourceScopeUID(query.DatasourceUID))) {
|
||||
|
||||
@@ -401,7 +401,7 @@ func TestCheckDatasourcePermissionsForRule(t *testing.T) {
|
||||
expressionByType := models.GenerateAlertQuery()
|
||||
expressionByType.QueryType = expr.DatasourceType
|
||||
expressionByUID := models.GenerateAlertQuery()
|
||||
expressionByUID.DatasourceUID = expr.OldDatasourceUID
|
||||
expressionByUID.DatasourceUID = expr.DatasourceUID
|
||||
|
||||
var data []models.AlertQuery
|
||||
var scopes []string
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "query",
|
||||
"hide": false,
|
||||
@@ -50,7 +50,7 @@
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "$reduced > 10",
|
||||
"hide": false,
|
||||
@@ -95,7 +95,7 @@
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "$A",
|
||||
"intervalMs": 2000,
|
||||
@@ -112,4 +112,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "query",
|
||||
"hide": false,
|
||||
@@ -57,7 +57,7 @@
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "$reduced > 10",
|
||||
"hide": false,
|
||||
@@ -102,7 +102,7 @@
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "$A",
|
||||
"intervalMs": 2000,
|
||||
@@ -119,4 +119,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ content-type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "query",
|
||||
"hide": false,
|
||||
@@ -116,7 +116,7 @@ content-type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "$reduced > 10",
|
||||
"hide": false,
|
||||
@@ -184,7 +184,7 @@ content-type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "query",
|
||||
"hide": false,
|
||||
@@ -202,7 +202,7 @@ content-type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "$reduced > 42",
|
||||
"hide": false,
|
||||
@@ -283,7 +283,7 @@ Content-Type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "query",
|
||||
"hide": false,
|
||||
@@ -301,7 +301,7 @@ Content-Type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "$reduced > 42",
|
||||
"hide": false,
|
||||
@@ -317,4 +317,4 @@ Content-Type: application/json
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"type": "math",
|
||||
"expression": "2 + 2 > 1"
|
||||
@@ -18,4 +18,4 @@
|
||||
],
|
||||
"now": "2021-03-11T14:50:42.218+02:00"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ content-type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"type":"math",
|
||||
"expression":"1 < 2"
|
||||
@@ -56,7 +56,7 @@ content-type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "$A",
|
||||
"intervalMs": 2000,
|
||||
@@ -113,7 +113,7 @@ content-type: application/json
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"type":"math",
|
||||
"expression":"1 < 2"
|
||||
@@ -121,7 +121,7 @@ content-type: application/json
|
||||
}
|
||||
]
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
### grafana recipient - lotex payload
|
||||
POST http://admin:admin@localhost:3000/api/v1/rule/test/{{grafanaRecipient}}
|
||||
@@ -129,4 +129,4 @@ content-type: application/json
|
||||
|
||||
{
|
||||
"expr": "rate({cluster=\"us-central1\", job=\"loki-prod/loki-canary\"}[1m]) > 0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
"AlertQuery": {
|
||||
"properties": {
|
||||
"datasourceUid": {
|
||||
"description": "Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation.",
|
||||
"description": "Grafana data source unique identifier; it should be '__expr__' for a Server Side Expression operation.",
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
@@ -2053,7 +2053,7 @@
|
||||
"data": {
|
||||
"example": [
|
||||
{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"conditions": [
|
||||
{
|
||||
@@ -3278,6 +3278,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"properties": {
|
||||
"alerts": {
|
||||
"description": "alerts",
|
||||
@@ -3517,6 +3518,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
},
|
||||
@@ -4496,4 +4498,4 @@
|
||||
}
|
||||
},
|
||||
"swagger": "2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ type ProvisionedAlertRule struct {
|
||||
// example: A
|
||||
Condition string `json:"condition"`
|
||||
// required: true
|
||||
// example: [{"refId":"A","queryType":"","relativeTimeRange":{"from":0,"to":0},"datasourceUid":"-100","model":{"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":[]},"reducer":{"params":[],"type":"avg"},"type":"query"}],"datasource":{"type":"__expr__","uid":"__expr__"},"expression":"1 == 1","hide":false,"intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"}}]
|
||||
// example: [{"refId":"A","queryType":"","relativeTimeRange":{"from":0,"to":0},"datasourceUid":"__expr__","model":{"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":[]},"reducer":{"params":[],"type":"avg"},"type":"query"}],"datasource":{"type":"__expr__","uid":"__expr__"},"expression":"1 == 1","hide":false,"intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"}}]
|
||||
Data []models.AlertQuery `json:"data"`
|
||||
// readonly: true
|
||||
Updated time.Time `json:"updated,omitempty"`
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
"AlertQuery": {
|
||||
"properties": {
|
||||
"datasourceUid": {
|
||||
"description": "Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation.",
|
||||
"description": "Grafana data source unique identifier; it should be '__expr__' for a Server Side Expression operation.",
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
@@ -2053,7 +2053,7 @@
|
||||
"data": {
|
||||
"example": [
|
||||
{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"conditions": [
|
||||
{
|
||||
@@ -3278,7 +3278,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"properties": {
|
||||
"alerts": {
|
||||
"description": "alerts",
|
||||
@@ -3705,6 +3704,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"receiver": {
|
||||
"description": "Receiver receiver",
|
||||
"properties": {
|
||||
"active": {
|
||||
"description": "active",
|
||||
@@ -6245,4 +6245,4 @@
|
||||
}
|
||||
},
|
||||
"swagger": "2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2534,7 +2534,7 @@
|
||||
"title": "AlertQuery represents a single query associated with an alert definition.",
|
||||
"properties": {
|
||||
"datasourceUid": {
|
||||
"description": "Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation.",
|
||||
"description": "Grafana data source unique identifier; it should be '__expr__' for a Server Side Expression operation.",
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
@@ -4506,7 +4506,7 @@
|
||||
},
|
||||
"example": [
|
||||
{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"conditions": [
|
||||
{
|
||||
@@ -5715,7 +5715,6 @@
|
||||
}
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"alerts",
|
||||
@@ -6150,6 +6149,7 @@
|
||||
"$ref": "#/definitions/postableSilence"
|
||||
},
|
||||
"receiver": {
|
||||
"description": "Receiver receiver",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"active",
|
||||
@@ -6280,4 +6280,4 @@
|
||||
"type": "basic"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ type AlertQuery struct {
|
||||
// RelativeTimeRange is the relative Start and End of the query as sent by the frontend.
|
||||
RelativeTimeRange RelativeTimeRange `json:"relativeTimeRange"`
|
||||
|
||||
// Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation.
|
||||
// Grafana data source unique identifier; it should be '__expr__' for a Server Side Expression operation.
|
||||
DatasourceUID string `json:"datasourceUid"`
|
||||
|
||||
// JSON is the raw JSON query and includes the above properties as well as custom properties.
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -29,7 +30,7 @@ func TestAlertQuery(t *testing.T) {
|
||||
"queryType": "metricQuery",
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
},
|
||||
expectedIsExpression: true,
|
||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||
|
||||
@@ -282,7 +282,7 @@ func CreateClassicConditionExpression(refID string, inputRefID string, reducer s
|
||||
return AlertQuery{
|
||||
RefID: refID,
|
||||
QueryType: expr.DatasourceType,
|
||||
DatasourceUID: expr.OldDatasourceUID,
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
// the format corresponds to model `ClassicConditionJSON` in /pkg/expr/classic/classic.go
|
||||
Model: json.RawMessage(fmt.Sprintf(`
|
||||
{
|
||||
@@ -316,6 +316,6 @@ func CreateClassicConditionExpression(refID string, inputRefID string, reducer s
|
||||
}
|
||||
}
|
||||
]
|
||||
}`, refID, inputRefID, operation, threshold, reducer, expr.OldDatasourceUID, expr.DatasourceType)),
|
||||
}`, refID, inputRefID, operation, threshold, reducer, expr.DatasourceUID, expr.DatasourceType)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/store"
|
||||
@@ -371,7 +372,7 @@ func createTestRule(title string, groupTitle string, orgID int64) models.AlertRu
|
||||
{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage("{}"),
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
RelativeTimeRange: models.RelativeTimeRange{
|
||||
From: models.Duration(60),
|
||||
To: models.Duration(0),
|
||||
|
||||
@@ -539,13 +539,13 @@ func withQueryForState(t *testing.T, evalResult eval.State) models.AlertRuleMuta
|
||||
switch evalResult {
|
||||
case eval.Normal:
|
||||
expression = `{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"type":"math",
|
||||
"expression":"2 + 1 < 1"
|
||||
}`
|
||||
case eval.Pending, eval.Alerting:
|
||||
expression = `{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"type":"math",
|
||||
"expression":"2 + 2 > 1"
|
||||
}`
|
||||
@@ -554,7 +554,7 @@ func withQueryForState(t *testing.T, evalResult eval.State) models.AlertRuleMuta
|
||||
}
|
||||
case eval.Error:
|
||||
expression = `{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"type":"math",
|
||||
"expression":"$A"
|
||||
}`
|
||||
@@ -566,7 +566,7 @@ func withQueryForState(t *testing.T, evalResult eval.State) models.AlertRuleMuta
|
||||
rule.Condition = "A"
|
||||
rule.Data = []models.AlertQuery{
|
||||
{
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(expression),
|
||||
RelativeTimeRange: models.RelativeTimeRange{
|
||||
From: models.Duration(5 * time.Hour),
|
||||
|
||||
@@ -127,7 +127,7 @@ func CreateTestAlertRuleWithLabels(t *testing.T, ctx context.Context, dbstore *s
|
||||
Data: []models.AlertQuery{
|
||||
{
|
||||
Model: json.RawMessage(`{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"type":"math",
|
||||
"expression":"2 + 2 > 1"
|
||||
}`),
|
||||
|
||||
Vendored
+2
-2
@@ -31,7 +31,7 @@ groups:
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -49,7 +49,7 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ groups:
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -48,7 +48,7 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ groups:
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -48,7 +48,7 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ groups:
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -48,7 +48,7 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
|
||||
+5
-5
@@ -30,7 +30,7 @@ groups:
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -48,7 +48,7 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
@@ -84,7 +84,7 @@ groups:
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -102,9 +102,9 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
refId: B
|
||||
type: classic_conditions
|
||||
type: classic_conditions
|
||||
|
||||
@@ -30,7 +30,7 @@ apiVersion: 1
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -48,7 +48,7 @@ apiVersion: 1
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
|
||||
+4
-4
@@ -41,7 +41,7 @@
|
||||
"from": 0,
|
||||
"to": 0
|
||||
},
|
||||
"datasourceUID": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"conditions": [
|
||||
{
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
"reducer": {
|
||||
"params": [
|
||||
|
||||
|
||||
],
|
||||
"type": "last"
|
||||
},
|
||||
@@ -70,7 +70,7 @@
|
||||
],
|
||||
"datasource": {
|
||||
"type": "__expr__",
|
||||
"uid": "-100"
|
||||
"uid": "__expr__"
|
||||
},
|
||||
"hide": false,
|
||||
"intervalMs": 1000,
|
||||
@@ -84,4 +84,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ groups:
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -48,7 +48,7 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ groups:
|
||||
relativeTimeRange:
|
||||
from: 0
|
||||
to: 0
|
||||
datasourceUID: "-100"
|
||||
datasourceUid: "__expr__"
|
||||
model:
|
||||
conditions:
|
||||
- evaluator:
|
||||
@@ -48,7 +48,7 @@ groups:
|
||||
type: query
|
||||
datasource:
|
||||
type: __expr__
|
||||
uid: "-100"
|
||||
uid: "__expr__"
|
||||
hide: false
|
||||
intervalMs: 1000
|
||||
maxDataPoints: 43200
|
||||
|
||||
@@ -524,7 +524,7 @@ func (c *fakePluginClient) QueryData(ctx context.Context, req *backend.QueryData
|
||||
c.req = req
|
||||
|
||||
// If an expression query ends up getting directly queried, we want it to return an error in our test.
|
||||
if req.PluginContext.PluginID == "__expr__" {
|
||||
if req.PluginContext.PluginID == expr.DatasourceUID {
|
||||
return nil, errors.New("cant query an expression datasource")
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ func migrateAlertRuleQueries(data []alertQuery) ([]alertQuery, error) {
|
||||
result := make([]alertQuery, 0, len(data))
|
||||
for _, d := range data {
|
||||
// queries that are expression are not relevant, skip them.
|
||||
if d.DatasourceUID == expr.OldDatasourceUID {
|
||||
if d.DatasourceUID == expr.DatasourceType {
|
||||
result = append(result, d)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
@@ -187,7 +188,7 @@ func transConditions(set dashAlertSettings, orgID int64, dsUIDMap dsUIDLookup) (
|
||||
ccAlertQuery := alertQuery{
|
||||
RefID: ccRefID,
|
||||
Model: exprModelJSON,
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
}
|
||||
|
||||
newCond.Data = append(newCond.Data, ccAlertQuery)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -186,7 +187,7 @@ func TestAdminConfiguration_SendingToExternalAlertmanagers(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -207,7 +208,7 @@ func TestAdminConfiguration_SendingToExternalAlertmanagers(t *testing.T) {
|
||||
_ = postRequest(t, ruleURL, buf.String(), http.StatusAccepted)
|
||||
}
|
||||
|
||||
//Eventually, our Alertmanagers should receiver the alert.
|
||||
// Eventually, our Alertmanagers should receiver the alert.
|
||||
{
|
||||
require.Eventually(t, func() bool {
|
||||
return fakeAM1.AlertsCount() == 1 && fakeAM2.AlertsCount() == 1
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -502,7 +503,7 @@ func TestAlertAndGroupsQuery(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -641,7 +642,7 @@ func TestRulerAccess(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -742,7 +743,7 @@ func TestDeleteFolderWithRules(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "2 + 3 > 1",
|
||||
"intervalMs": 1000,
|
||||
@@ -896,7 +897,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -926,7 +927,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -956,7 +957,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -987,7 +988,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -1047,7 +1048,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -1106,7 +1107,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -1126,7 +1127,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -1197,7 +1198,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 3 \u003e 1",
|
||||
"intervalMs":1000,
|
||||
@@ -1233,7 +1234,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 3 \u003e 1",
|
||||
"intervalMs":1000,
|
||||
@@ -1291,7 +1292,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 < 1"
|
||||
@@ -1364,7 +1365,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 < 1"
|
||||
@@ -1398,7 +1399,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -1472,7 +1473,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 < 1"
|
||||
@@ -1540,7 +1541,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 3 \u003C 1",
|
||||
"intervalMs":1000,
|
||||
@@ -1589,7 +1590,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 < 1"
|
||||
@@ -1649,7 +1650,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 3 \u003C 1",
|
||||
"intervalMs":1000,
|
||||
@@ -1734,7 +1735,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 3 \u003C 1",
|
||||
"intervalMs":1000,
|
||||
@@ -1960,7 +1961,7 @@ func TestQuota(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -1995,7 +1996,7 @@ func TestQuota(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 4 > 1"
|
||||
@@ -2054,7 +2055,7 @@ func TestQuota(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 4 \u003E 1",
|
||||
"intervalMs":1000,
|
||||
@@ -2123,7 +2124,7 @@ func TestEval(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model": {
|
||||
"type":"math",
|
||||
"expression":"1 < 2"
|
||||
@@ -2187,7 +2188,7 @@ func TestEval(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"type":"math",
|
||||
"expression":"1 > 2"
|
||||
@@ -2251,7 +2252,7 @@ func TestEval(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"type":"math",
|
||||
"expression":"1 > 2"
|
||||
@@ -2352,7 +2353,7 @@ func TestEval(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"type":"math",
|
||||
"expression":"1 < 2"
|
||||
@@ -2408,7 +2409,7 @@ func TestEval(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"type":"math",
|
||||
"expression":"1 > 2"
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
@@ -968,7 +969,7 @@ func getRulesConfig(t *testing.T) string {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -1627,7 +1628,7 @@ const alertmanagerConfig = `
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "slack_recv2",
|
||||
"grafana_managed_receiver_configs": [
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -102,7 +103,7 @@ func TestPrometheusRules(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -122,7 +123,7 @@ func TestPrometheusRules(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -178,7 +179,7 @@ func TestPrometheusRules(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -235,7 +236,7 @@ func TestPrometheusRules(t *testing.T) {
|
||||
"rules": [{
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiring",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"-100\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"duration": 10,
|
||||
"annotations": {
|
||||
"annotation1": "val1"
|
||||
@@ -250,7 +251,7 @@ func TestPrometheusRules(t *testing.T) {
|
||||
}, {
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiringButSilenced",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"-100\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"health": "ok",
|
||||
"type": "alerting",
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
@@ -287,7 +288,7 @@ func TestPrometheusRules(t *testing.T) {
|
||||
"rules": [{
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiring",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"-100\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"duration": 10,
|
||||
"annotations": {
|
||||
"annotation1": "val1"
|
||||
@@ -302,7 +303,7 @@ func TestPrometheusRules(t *testing.T) {
|
||||
}, {
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiringButSilenced",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"-100\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"health": "ok",
|
||||
"type": "alerting",
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
@@ -367,7 +368,7 @@ func TestPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -387,7 +388,7 @@ func TestPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -430,7 +431,7 @@ func TestPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
"rules": [{
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiring",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"-100\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"duration": 10,
|
||||
"annotations": {
|
||||
"__dashboardUid__": "%s",
|
||||
@@ -443,7 +444,7 @@ func TestPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
}, {
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiringButSilenced",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"-100\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"health": "ok",
|
||||
"type": "alerting",
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
@@ -465,7 +466,7 @@ func TestPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
"rules": [{
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiring",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"-100\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"duration": 10,
|
||||
"annotations": {
|
||||
"__dashboardUid__": "%s",
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -99,7 +100,7 @@ func TestAlertRulePermissions(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 3 \u003E 1",
|
||||
"intervalMs":1000,
|
||||
@@ -149,7 +150,7 @@ func TestAlertRulePermissions(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 3 \u003E 1",
|
||||
"intervalMs":1000,
|
||||
@@ -222,7 +223,7 @@ func TestAlertRulePermissions(t *testing.T) {
|
||||
"from":18000,
|
||||
"to":10800
|
||||
},
|
||||
"datasourceUid":"-100",
|
||||
"datasourceUid":"__expr__",
|
||||
"model":{
|
||||
"expression":"2 + 3 \u003E 1",
|
||||
"intervalMs":1000,
|
||||
@@ -295,7 +296,7 @@ func createRule(t *testing.T, client apiClient, folder string) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -431,7 +432,7 @@ func TestRulerRulesFilterByDashboard(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -451,7 +452,7 @@ func TestRulerRulesFilterByDashboard(t *testing.T) {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -493,7 +494,7 @@ func TestRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "2 + 3 \u003e 1",
|
||||
"intervalMs": 1000,
|
||||
@@ -526,7 +527,7 @@ func TestRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "2 + 3 \u003e 1",
|
||||
"intervalMs": 1000,
|
||||
@@ -571,7 +572,7 @@ func TestRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"expression": "2 + 3 \u003e 1",
|
||||
"intervalMs": 1000,
|
||||
@@ -879,7 +880,7 @@ func newTestingRuleConfig(t *testing.T) apimodels.PostableRuleGroupConfig {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
@@ -906,7 +907,7 @@ func newTestingRuleConfig(t *testing.T) apimodels.PostableRuleGroupConfig {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -104,7 +105,7 @@ func alertRuleGen() func() apimodels.PostableExtendedRuleNode {
|
||||
From: ngmodels.Duration(time.Duration(5) * time.Hour),
|
||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||
},
|
||||
DatasourceUID: "-100",
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{
|
||||
"type": "math",
|
||||
"expression": "2 + 3 > 1"
|
||||
|
||||
@@ -10881,7 +10881,7 @@
|
||||
"title": "AlertQuery represents a single query associated with an alert definition.",
|
||||
"properties": {
|
||||
"datasourceUid": {
|
||||
"description": "Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation.",
|
||||
"description": "Grafana data source unique identifier; it should be '__expr__' for a Server Side Expression operation.",
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
@@ -15381,7 +15381,7 @@
|
||||
},
|
||||
"example": [
|
||||
{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"conditions": [
|
||||
{
|
||||
@@ -17420,9 +17420,8 @@
|
||||
"type": "string"
|
||||
},
|
||||
"URL": {
|
||||
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.",
|
||||
"type": "object",
|
||||
"title": "A URL represents a parsed URL (technically, a URI reference).",
|
||||
"title": "URL is a custom URL type that allows validation at configuration load time.",
|
||||
"properties": {
|
||||
"ForceQuery": {
|
||||
"type": "boolean"
|
||||
@@ -18413,6 +18412,7 @@
|
||||
"$ref": "#/definitions/Duration"
|
||||
},
|
||||
"gettableAlert": {
|
||||
"description": "GettableAlert gettable alert",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"labels",
|
||||
@@ -18523,6 +18523,7 @@
|
||||
}
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
@@ -20100,4 +20101,4 @@
|
||||
"name": "service_accounts"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { render, act, waitFor } from '@testing-library/react';
|
||||
import { act, render, waitFor } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import { Router } from 'react-router-dom';
|
||||
@@ -324,7 +324,7 @@ describe('PanelAlertTabContent', () => {
|
||||
},
|
||||
{
|
||||
refId: 'B',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
queryType: '',
|
||||
model: {
|
||||
refId: 'B',
|
||||
@@ -333,7 +333,7 @@ describe('PanelAlertTabContent', () => {
|
||||
type: 'classic_conditions',
|
||||
datasource: {
|
||||
type: ExpressionDatasourceRef.type,
|
||||
uid: '-100',
|
||||
uid: '__expr__',
|
||||
},
|
||||
conditions: [
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('rule-editor', () => {
|
||||
|
||||
const classicCondition = {
|
||||
refId: 'B',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
queryType: '',
|
||||
model: {
|
||||
refId: 'B',
|
||||
@@ -50,7 +50,7 @@ describe('rule-editor', () => {
|
||||
|
||||
const mathExpression = {
|
||||
refId: 'B',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
queryType: '',
|
||||
model: {
|
||||
refId: 'B',
|
||||
@@ -63,7 +63,7 @@ describe('rule-editor', () => {
|
||||
|
||||
const reduceExpression = {
|
||||
refId: 'B',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
queryType: '',
|
||||
model: {
|
||||
refId: 'B',
|
||||
@@ -77,7 +77,7 @@ describe('rule-editor', () => {
|
||||
|
||||
const resampleExpression = {
|
||||
refId: 'A',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
model: {
|
||||
refId: 'A',
|
||||
type: 'resample',
|
||||
|
||||
@@ -102,7 +102,7 @@ const grafanaAlert = {
|
||||
refId: 'B',
|
||||
queryType: '',
|
||||
relativeTimeRange: { from: 0, to: 0 },
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
model: {
|
||||
conditions: [
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('timeRange', () => {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'B',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
model: {
|
||||
queryType: 'query',
|
||||
datasource: '__expr__',
|
||||
@@ -40,7 +40,7 @@ describe('timeRange', () => {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'C',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
model: {
|
||||
queryType: 'query',
|
||||
datasource: '__expr__',
|
||||
@@ -80,7 +80,7 @@ describe('timeRange', () => {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'B',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
model: {
|
||||
queryType: 'query',
|
||||
datasource: '__expr__',
|
||||
@@ -105,7 +105,7 @@ describe('timeRange', () => {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'C',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
model: {
|
||||
queryType: 'query',
|
||||
datasource: '__expr__',
|
||||
@@ -142,7 +142,7 @@ describe('timeRange', () => {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'B',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
model: {
|
||||
queryType: 'query',
|
||||
datasource: '__expr__',
|
||||
@@ -175,7 +175,7 @@ describe('timeRange', () => {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'B',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
datasourceUid: '__expr__',
|
||||
model: {
|
||||
queryType: 'query',
|
||||
datasource: '__expr__',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Observable, from, mergeMap } from 'rxjs';
|
||||
import { from, mergeMap, Observable } from 'rxjs';
|
||||
|
||||
import {
|
||||
DataQueryRequest,
|
||||
@@ -61,10 +61,9 @@ export class ExpressionDatasourceApi extends DataSourceWithBackend<ExpressionQue
|
||||
}
|
||||
|
||||
/**
|
||||
* MATCHES a constant in DataSourceWithBackend, this should be '__expr__'
|
||||
* @deprecated
|
||||
* MATCHES a constant in DataSourceWithBackend
|
||||
*/
|
||||
export const ExpressionDatasourceUID = '-100';
|
||||
export const ExpressionDatasourceUID = '__expr__';
|
||||
|
||||
export const instanceSettings: DataSourceInstanceSettings = {
|
||||
id: -100,
|
||||
|
||||
@@ -2322,7 +2322,7 @@
|
||||
"AlertQuery": {
|
||||
"properties": {
|
||||
"datasourceUid": {
|
||||
"description": "Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation.",
|
||||
"description": "Grafana data source unique identifier; it should be '__expr__' for a Server Side Expression operation.",
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
@@ -6807,7 +6807,7 @@
|
||||
"data": {
|
||||
"example": [
|
||||
{
|
||||
"datasourceUid": "-100",
|
||||
"datasourceUid": "__expr__",
|
||||
"model": {
|
||||
"conditions": [
|
||||
{
|
||||
@@ -8861,7 +8861,6 @@
|
||||
"type": "string"
|
||||
},
|
||||
"URL": {
|
||||
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.",
|
||||
"properties": {
|
||||
"ForceQuery": {
|
||||
"type": "boolean"
|
||||
@@ -8894,7 +8893,7 @@
|
||||
"$ref": "#/components/schemas/Userinfo"
|
||||
}
|
||||
},
|
||||
"title": "A URL represents a parsed URL (technically, a URI reference).",
|
||||
"title": "URL is a custom URL type that allows validation at configuration load time.",
|
||||
"type": "object"
|
||||
},
|
||||
"UpdateAlertNotificationCommand": {
|
||||
@@ -9854,6 +9853,7 @@
|
||||
"$ref": "#/components/schemas/Duration"
|
||||
},
|
||||
"gettableAlert": {
|
||||
"description": "GettableAlert gettable alert",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"$ref": "#/components/schemas/labelSet"
|
||||
@@ -9964,6 +9964,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/gettableSilence"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user