mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AlertingNG/SSE: Datasource UID and UID/ID only (drop name) (#33039)
SSE still will support ID until dashboard/frontend always requests UID update *.http examples Co-authored-by: gotjosh <josue@grafana.com>
This commit is contained in:
parent
5d1ec39224
commit
2c862678ab
@ -134,9 +134,14 @@ func (s *Service) buildGraph(req *backend.QueryDataRequest) (*simple.DirectedGra
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dsUID, err := rn.GetDatasourceUid()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var node graph.Node
|
var node graph.Node
|
||||||
switch dsName {
|
switch {
|
||||||
case DatasourceName:
|
case dsName == DatasourceName || dsUID == DatasourceUID:
|
||||||
node, err = buildCMDNode(dp, rn)
|
node, err = buildCMDNode(dp, rn)
|
||||||
default: // If it's not an expression query, it's a data source query.
|
default: // If it's not an expression query, it's a data source query.
|
||||||
node, err = s.buildDSNode(dp, rn, req.PluginContext.OrgID)
|
node, err = s.buildDSNode(dp, rn, req.PluginContext.OrgID)
|
||||||
|
@ -30,7 +30,7 @@ type rawNode struct {
|
|||||||
func (rn *rawNode) GetDatasourceName() (string, error) {
|
func (rn *rawNode) GetDatasourceName() (string, error) {
|
||||||
rawDs, ok := rn.Query["datasource"]
|
rawDs, ok := rn.Query["datasource"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("no datasource in query for refId %v", rn.RefID)
|
return "", nil
|
||||||
}
|
}
|
||||||
dsName, ok := rawDs.(string)
|
dsName, ok := rawDs.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -39,6 +39,18 @@ func (rn *rawNode) GetDatasourceName() (string, error) {
|
|||||||
return dsName, nil
|
return dsName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rn *rawNode) GetDatasourceUid() (string, error) {
|
||||||
|
rawDs, ok := rn.Query["datasourceUid"]
|
||||||
|
if !ok {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
dsUID, ok := rawDs.(string)
|
||||||
|
if !ok {
|
||||||
|
return "", fmt.Errorf("expected datasource identifier to be a string, got %T", rawDs)
|
||||||
|
}
|
||||||
|
return dsUID, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (rn *rawNode) GetCommandType() (c CommandType, err error) {
|
func (rn *rawNode) GetCommandType() (c CommandType, err error) {
|
||||||
rawType, ok := rn.Query["type"]
|
rawType, ok := rn.Query["type"]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -240,14 +240,14 @@ func (dc *dashConditionsJSON) GetNew(orgID int64) (*ngmodels.Condition, error) {
|
|||||||
ngCond.OrgID = orgID
|
ngCond.OrgID = orgID
|
||||||
|
|
||||||
exprModel := struct {
|
exprModel := struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
RefID string `json:"refId"`
|
RefID string `json:"refId"`
|
||||||
Datasource string `json:"datasource"`
|
DatasourceUID string `json:"datasourceUid"`
|
||||||
Conditions []classic.ClassicConditionJSON `json:"conditions"`
|
Conditions []classic.ClassicConditionJSON `json:"conditions"`
|
||||||
}{
|
}{
|
||||||
"classic_conditions",
|
"classic_conditions",
|
||||||
ccRefID,
|
ccRefID,
|
||||||
"__expr__",
|
expr.DatasourceUID,
|
||||||
conditions,
|
conditions,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "gdev-prometheus",
|
|
||||||
"datasourceUid": "000000002",
|
"datasourceUid": "000000002",
|
||||||
"expr": "http_request_duration_microseconds_count",
|
"expr": "http_request_duration_microseconds_count",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -96,7 +95,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "query",
|
"expression": "query",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -115,7 +113,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "$reduced > 10",
|
"expression": "$reduced > 10",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -162,7 +159,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "gdev-prometheus",
|
|
||||||
"datasourceUid": "000000002",
|
"datasourceUid": "000000002",
|
||||||
"expr": "http_request_duration_microseconds_count",
|
"expr": "http_request_duration_microseconds_count",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -181,7 +177,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "query",
|
"expression": "query",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -200,7 +195,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "$reduced > 42",
|
"expression": "$reduced > 42",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
|
@ -100,7 +100,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "query",
|
"expression": "query",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -119,7 +118,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "$reduced > 10",
|
"expression": "$reduced > 10",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -170,7 +168,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "gdev-prometheus",
|
|
||||||
"datasourceUid": "000000002",
|
"datasourceUid": "000000002",
|
||||||
"expr": "http_request_duration_microseconds_count",
|
"expr": "http_request_duration_microseconds_count",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -189,7 +186,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "query",
|
"expression": "query",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -208,7 +204,6 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "$reduced > 42",
|
"expression": "$reduced > 42",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -272,7 +267,6 @@ Content-Type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "gdev-prometheus",
|
|
||||||
"datasourceUid": "000000002",
|
"datasourceUid": "000000002",
|
||||||
"expr": "http_request_duration_microseconds_count",
|
"expr": "http_request_duration_microseconds_count",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -291,7 +285,6 @@ Content-Type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "query",
|
"expression": "query",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
@ -310,7 +303,6 @@ Content-Type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
|
||||||
"datasourceUid": "-100",
|
"datasourceUid": "-100",
|
||||||
"expression": "$reduced > 42",
|
"expression": "$reduced > 42",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
|
@ -16,7 +16,7 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"1 < 2"
|
"expression":"1 < 2"
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ content-type: application/json
|
|||||||
"to": 10800
|
"to": 10800
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"1 < 2"
|
"expression":"1 < 2"
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,8 @@ func (aq *AlertQuery) setModelProps() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// setDatasource sets DatasourceID.
|
// setDatasource sets DatasourceUID.
|
||||||
// If it's an expression sets DefaultExprDatasourceID.
|
// If it's an expression sets DefaultExprDatasourceUID.
|
||||||
func (aq *AlertQuery) setDatasource() error {
|
func (aq *AlertQuery) setDatasource() error {
|
||||||
if aq.modelProps == nil {
|
if aq.modelProps == nil {
|
||||||
err := aq.setModelProps()
|
err := aq.setModelProps()
|
||||||
@ -96,17 +96,6 @@ func (aq *AlertQuery) setDatasource() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dsName, ok := aq.modelProps["datasource"]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("failed to get datasource from query model")
|
|
||||||
}
|
|
||||||
|
|
||||||
if dsName == expr.DatasourceName {
|
|
||||||
aq.DatasourceUID = expr.DatasourceUID
|
|
||||||
aq.modelProps["datasourceUid"] = expr.DatasourceUID
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
i, ok := aq.modelProps["datasourceUid"]
|
i, ok := aq.modelProps["datasourceUid"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("failed to get datasourceUid from query model")
|
return fmt.Errorf("failed to get datasourceUid from query model")
|
||||||
|
@ -27,13 +27,12 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
alertQuery: AlertQuery{
|
alertQuery: AlertQuery{
|
||||||
RefID: "A",
|
RefID: "A",
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"queryType": "metricQuery",
|
"queryType": "metricQuery",
|
||||||
"extraParam": "some text"
|
"extraParam": "some text"
|
||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
expectedIsExpression: true,
|
expectedIsExpression: true,
|
||||||
expectedDatasource: expr.DatasourceName,
|
|
||||||
expectedDatasourceUID: expr.DatasourceUID,
|
expectedDatasourceUID: expr.DatasourceUID,
|
||||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||||
expectedIntervalMS: int64(defaultIntervalMS),
|
expectedIntervalMS: int64(defaultIntervalMS),
|
||||||
@ -43,14 +42,12 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
alertQuery: AlertQuery{
|
alertQuery: AlertQuery{
|
||||||
RefID: "A",
|
RefID: "A",
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "my datasource",
|
|
||||||
"datasourceUid": "000000001",
|
"datasourceUid": "000000001",
|
||||||
"queryType": "metricQuery",
|
"queryType": "metricQuery",
|
||||||
"extraParam": "some text"
|
"extraParam": "some text"
|
||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
expectedIsExpression: false,
|
expectedIsExpression: false,
|
||||||
expectedDatasource: "my datasource",
|
|
||||||
expectedDatasourceUID: "000000001",
|
expectedDatasourceUID: "000000001",
|
||||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||||
expectedIntervalMS: int64(defaultIntervalMS),
|
expectedIntervalMS: int64(defaultIntervalMS),
|
||||||
@ -60,7 +57,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
alertQuery: AlertQuery{
|
alertQuery: AlertQuery{
|
||||||
RefID: "A",
|
RefID: "A",
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "my datasource",
|
|
||||||
"datasourceUid": "000000001",
|
"datasourceUid": "000000001",
|
||||||
"queryType": "metricQuery",
|
"queryType": "metricQuery",
|
||||||
"maxDataPoints": 200,
|
"maxDataPoints": 200,
|
||||||
@ -68,7 +64,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
expectedIsExpression: false,
|
expectedIsExpression: false,
|
||||||
expectedDatasource: "my datasource",
|
|
||||||
expectedDatasourceUID: "000000001",
|
expectedDatasourceUID: "000000001",
|
||||||
expectedMaxPoints: 200,
|
expectedMaxPoints: 200,
|
||||||
expectedIntervalMS: int64(defaultIntervalMS),
|
expectedIntervalMS: int64(defaultIntervalMS),
|
||||||
@ -78,7 +73,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
alertQuery: AlertQuery{
|
alertQuery: AlertQuery{
|
||||||
RefID: "A",
|
RefID: "A",
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "my datasource",
|
|
||||||
"datasourceUid": "000000001",
|
"datasourceUid": "000000001",
|
||||||
"queryType": "metricQuery",
|
"queryType": "metricQuery",
|
||||||
"maxDataPoints": "invalid",
|
"maxDataPoints": "invalid",
|
||||||
@ -86,7 +80,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
expectedIsExpression: false,
|
expectedIsExpression: false,
|
||||||
expectedDatasource: "my datasource",
|
|
||||||
expectedDatasourceUID: "000000001",
|
expectedDatasourceUID: "000000001",
|
||||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||||
expectedIntervalMS: int64(defaultIntervalMS),
|
expectedIntervalMS: int64(defaultIntervalMS),
|
||||||
@ -96,7 +89,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
alertQuery: AlertQuery{
|
alertQuery: AlertQuery{
|
||||||
RefID: "A",
|
RefID: "A",
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "my datasource",
|
|
||||||
"datasourceUid": "000000001",
|
"datasourceUid": "000000001",
|
||||||
"queryType": "metricQuery",
|
"queryType": "metricQuery",
|
||||||
"maxDataPoints": 0,
|
"maxDataPoints": 0,
|
||||||
@ -104,7 +96,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
expectedIsExpression: false,
|
expectedIsExpression: false,
|
||||||
expectedDatasource: "my datasource",
|
|
||||||
expectedDatasourceUID: "000000001",
|
expectedDatasourceUID: "000000001",
|
||||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||||
expectedIntervalMS: int64(defaultIntervalMS),
|
expectedIntervalMS: int64(defaultIntervalMS),
|
||||||
@ -114,7 +105,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
alertQuery: AlertQuery{
|
alertQuery: AlertQuery{
|
||||||
RefID: "A",
|
RefID: "A",
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "my datasource",
|
|
||||||
"datasourceUid": "000000001",
|
"datasourceUid": "000000001",
|
||||||
"queryType": "metricQuery",
|
"queryType": "metricQuery",
|
||||||
"intervalMs": 2000,
|
"intervalMs": 2000,
|
||||||
@ -122,7 +112,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
expectedIsExpression: false,
|
expectedIsExpression: false,
|
||||||
expectedDatasource: "my datasource",
|
|
||||||
expectedDatasourceUID: "000000001",
|
expectedDatasourceUID: "000000001",
|
||||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||||
expectedIntervalMS: 2000,
|
expectedIntervalMS: 2000,
|
||||||
@ -132,7 +121,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
alertQuery: AlertQuery{
|
alertQuery: AlertQuery{
|
||||||
RefID: "A",
|
RefID: "A",
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "my datasource",
|
|
||||||
"datasourceUid": "000000001",
|
"datasourceUid": "000000001",
|
||||||
"queryType": "metricQuery",
|
"queryType": "metricQuery",
|
||||||
"intervalMs": "invalid",
|
"intervalMs": "invalid",
|
||||||
@ -140,7 +128,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
expectedIsExpression: false,
|
expectedIsExpression: false,
|
||||||
expectedDatasource: "my datasource",
|
|
||||||
expectedDatasourceUID: "000000001",
|
expectedDatasourceUID: "000000001",
|
||||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||||
expectedIntervalMS: int64(defaultIntervalMS),
|
expectedIntervalMS: int64(defaultIntervalMS),
|
||||||
@ -150,7 +137,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
alertQuery: AlertQuery{
|
alertQuery: AlertQuery{
|
||||||
RefID: "A",
|
RefID: "A",
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "my datasource",
|
|
||||||
"datasourceUid": "000000001",
|
"datasourceUid": "000000001",
|
||||||
"queryType": "metricQuery",
|
"queryType": "metricQuery",
|
||||||
"intervalMs": 0,
|
"intervalMs": 0,
|
||||||
@ -158,7 +144,6 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
}`),
|
}`),
|
||||||
},
|
},
|
||||||
expectedIsExpression: false,
|
expectedIsExpression: false,
|
||||||
expectedDatasource: "my datasource",
|
|
||||||
expectedDatasourceUID: "000000001",
|
expectedDatasourceUID: "000000001",
|
||||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||||
expectedIntervalMS: int64(defaultIntervalMS),
|
expectedIntervalMS: int64(defaultIntervalMS),
|
||||||
@ -204,13 +189,7 @@ func TestAlertQuery(t *testing.T) {
|
|||||||
err = json.Unmarshal(blob, &model)
|
err = json.Unmarshal(blob, &model)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
i, ok := model["datasource"]
|
i, ok := model["datasourceUid"]
|
||||||
require.True(t, ok)
|
|
||||||
datasource, ok := i.(string)
|
|
||||||
require.True(t, ok)
|
|
||||||
require.Equal(t, tc.expectedDatasource, datasource)
|
|
||||||
|
|
||||||
i, ok = model["datasourceUid"]
|
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
datasourceUID, ok := i.(string)
|
datasourceUID, ok := i.(string)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
@ -88,7 +88,7 @@ func TestCreatingAlertDefinition(t *testing.T) {
|
|||||||
Data: []models.AlertQuery{
|
Data: []models.AlertQuery{
|
||||||
{
|
{
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"2 + 3 > 1"
|
"expression":"2 + 3 > 1"
|
||||||
}`),
|
}`),
|
||||||
@ -129,7 +129,7 @@ func TestCreatingConflictionAlertDefinition(t *testing.T) {
|
|||||||
Data: []models.AlertQuery{
|
Data: []models.AlertQuery{
|
||||||
{
|
{
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"2 + 3 > 1"
|
"expression":"2 + 3 > 1"
|
||||||
}`),
|
}`),
|
||||||
@ -167,7 +167,7 @@ func TestUpdatingAlertDefinition(t *testing.T) {
|
|||||||
Data: []models.AlertQuery{
|
Data: []models.AlertQuery{
|
||||||
{
|
{
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"2 + 2 > 1"
|
"expression":"2 + 2 > 1"
|
||||||
}`),
|
}`),
|
||||||
@ -257,7 +257,7 @@ func TestUpdatingAlertDefinition(t *testing.T) {
|
|||||||
Data: []models.AlertQuery{
|
Data: []models.AlertQuery{
|
||||||
{
|
{
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"2 + 3 > 1"
|
"expression":"2 + 3 > 1"
|
||||||
}`),
|
}`),
|
||||||
@ -341,7 +341,7 @@ func TestUpdatingConflictingAlertDefinition(t *testing.T) {
|
|||||||
Data: []models.AlertQuery{
|
Data: []models.AlertQuery{
|
||||||
{
|
{
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"2 + 3 > 1"
|
"expression":"2 + 3 > 1"
|
||||||
}`),
|
}`),
|
||||||
@ -430,7 +430,7 @@ func createTestAlertDefinition(t *testing.T, dbstore *store.DBstore, intervalSec
|
|||||||
Data: []models.AlertQuery{
|
Data: []models.AlertQuery{
|
||||||
{
|
{
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"2 + 2 > 1"
|
"expression":"2 + 2 > 1"
|
||||||
}`),
|
}`),
|
||||||
|
@ -83,7 +83,7 @@ func createTestAlertRule(t *testing.T, dbstore *store.DBstore, intervalSeconds i
|
|||||||
Data: []models.AlertQuery{
|
Data: []models.AlertQuery{
|
||||||
{
|
{
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type":"math",
|
"type":"math",
|
||||||
"expression":"2 + 2 > 1"
|
"expression":"2 + 2 > 1"
|
||||||
}`),
|
}`),
|
||||||
|
@ -91,7 +91,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
|||||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||||
},
|
},
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type": "math",
|
"type": "math",
|
||||||
"expression": "2 + 3 > 1"
|
"expression": "2 + 3 > 1"
|
||||||
}`),
|
}`),
|
||||||
@ -112,7 +112,7 @@ func TestAlertRuleCRUD(t *testing.T) {
|
|||||||
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
To: ngmodels.Duration(time.Duration(3) * time.Hour),
|
||||||
},
|
},
|
||||||
Model: json.RawMessage(`{
|
Model: json.RawMessage(`{
|
||||||
"datasource": "__expr__",
|
"datasourceUid": "-100",
|
||||||
"type": "math",
|
"type": "math",
|
||||||
"expression": "2 + 3 > 1"
|
"expression": "2 + 3 > 1"
|
||||||
}`),
|
}`),
|
||||||
@ -180,7 +180,6 @@ func TestAlertRuleCRUD(t *testing.T) {
|
|||||||
"to":10800
|
"to":10800
|
||||||
},
|
},
|
||||||
"model":{
|
"model":{
|
||||||
"datasource":"__expr__",
|
|
||||||
"datasourceUid":"-100",
|
"datasourceUid":"-100",
|
||||||
"expression":"2 + 3 \u003e 1",
|
"expression":"2 + 3 \u003e 1",
|
||||||
"intervalMs":1000,
|
"intervalMs":1000,
|
||||||
@ -216,7 +215,6 @@ func TestAlertRuleCRUD(t *testing.T) {
|
|||||||
"to":10800
|
"to":10800
|
||||||
},
|
},
|
||||||
"model":{
|
"model":{
|
||||||
"datasource":"__expr__",
|
|
||||||
"datasourceUid":"-100",
|
"datasourceUid":"-100",
|
||||||
"expression":"2 + 3 \u003e 1",
|
"expression":"2 + 3 \u003e 1",
|
||||||
"intervalMs":1000,
|
"intervalMs":1000,
|
||||||
|
Loading…
Reference in New Issue
Block a user