AlertingNG: Split into several packages (#31719)
* AlertingNG: Split into several packages * Move AlertQuery to models
This commit is contained in:
@@ -1,288 +0,0 @@
|
||||
package eval
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
)
|
||||
|
||||
const defaultMaxDataPoints float64 = 100
|
||||
const defaultIntervalMS float64 = 1000
|
||||
|
||||
// Duration is a type used for marshalling durations.
|
||||
type Duration time.Duration
|
||||
|
||||
func (d Duration) String() string {
|
||||
return time.Duration(d).String()
|
||||
}
|
||||
|
||||
func (d Duration) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(time.Duration(d).Seconds())
|
||||
}
|
||||
|
||||
func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||
var v interface{}
|
||||
if err := json.Unmarshal(b, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
switch value := v.(type) {
|
||||
case float64:
|
||||
*d = Duration(time.Duration(value) * time.Second)
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("invalid duration %v", v)
|
||||
}
|
||||
}
|
||||
|
||||
// RelativeTimeRange is the per query start and end time
|
||||
// for requests.
|
||||
type RelativeTimeRange struct {
|
||||
From Duration `json:"from"`
|
||||
To Duration `json:"to"`
|
||||
}
|
||||
|
||||
// isValid checks that From duration is greater than To duration.
|
||||
func (rtr *RelativeTimeRange) isValid() bool {
|
||||
return rtr.From > rtr.To
|
||||
}
|
||||
|
||||
func (rtr *RelativeTimeRange) toTimeRange(now time.Time) backend.TimeRange {
|
||||
return backend.TimeRange{
|
||||
From: now.Add(-time.Duration(rtr.From)),
|
||||
To: now.Add(-time.Duration(rtr.To)),
|
||||
}
|
||||
}
|
||||
|
||||
// AlertQuery represents a single query associated with an alert definition.
|
||||
type AlertQuery struct {
|
||||
// RefID is the unique identifier of the query, set by the frontend call.
|
||||
RefID string `json:"refId"`
|
||||
|
||||
// QueryType is an optional identifier for the type of query.
|
||||
// It can be used to distinguish different types of queries.
|
||||
QueryType string `json:"queryType"`
|
||||
|
||||
// RelativeTimeRange is the relative Start and End of the query as sent by the frontend.
|
||||
RelativeTimeRange RelativeTimeRange `json:"relativeTimeRange"`
|
||||
|
||||
DatasourceUID string `json:"-"`
|
||||
|
||||
// JSON is the raw JSON query and includes the above properties as well as custom properties.
|
||||
Model json.RawMessage `json:"model"`
|
||||
|
||||
modelProps map[string]interface{}
|
||||
}
|
||||
|
||||
func (aq *AlertQuery) setModelProps() error {
|
||||
aq.modelProps = make(map[string]interface{})
|
||||
err := json.Unmarshal(aq.Model, &aq.modelProps)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal query model: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// setDatasource sets DatasourceID.
|
||||
// If it's an expression sets DefaultExprDatasourceID.
|
||||
func (aq *AlertQuery) setDatasource() error {
|
||||
if aq.modelProps == nil {
|
||||
err := aq.setModelProps()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
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"]
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to get datasourceUid from query model")
|
||||
}
|
||||
dsUID, ok := i.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to cast datasourceUid to string: %v", i)
|
||||
}
|
||||
aq.DatasourceUID = dsUID
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsExpression returns true if the alert query is an expression.
|
||||
func (aq *AlertQuery) IsExpression() (bool, error) {
|
||||
err := aq.setDatasource()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return aq.DatasourceUID == expr.DatasourceUID, nil
|
||||
}
|
||||
|
||||
// setMaxDatapoints sets the model maxDataPoints if it's missing or invalid
|
||||
func (aq *AlertQuery) setMaxDatapoints() error {
|
||||
if aq.modelProps == nil {
|
||||
err := aq.setModelProps()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
i, ok := aq.modelProps["maxDataPoints"] // GEL requires maxDataPoints inside the query JSON
|
||||
if !ok {
|
||||
aq.modelProps["maxDataPoints"] = defaultMaxDataPoints
|
||||
}
|
||||
maxDataPoints, ok := i.(float64)
|
||||
if !ok || maxDataPoints == 0 {
|
||||
aq.modelProps["maxDataPoints"] = defaultMaxDataPoints
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (aq *AlertQuery) getMaxDatapoints() (int64, error) {
|
||||
err := aq.setMaxDatapoints()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
maxDataPoints, ok := aq.modelProps["maxDataPoints"].(float64)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("failed to cast maxDataPoints to float64: %v", aq.modelProps["maxDataPoints"])
|
||||
}
|
||||
return int64(maxDataPoints), nil
|
||||
}
|
||||
|
||||
// setIntervalMS sets the model IntervalMs if it's missing or invalid
|
||||
func (aq *AlertQuery) setIntervalMS() error {
|
||||
if aq.modelProps == nil {
|
||||
err := aq.setModelProps()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
i, ok := aq.modelProps["intervalMs"] // GEL requires intervalMs inside the query JSON
|
||||
if !ok {
|
||||
aq.modelProps["intervalMs"] = defaultIntervalMS
|
||||
}
|
||||
intervalMs, ok := i.(float64)
|
||||
if !ok || intervalMs == 0 {
|
||||
aq.modelProps["intervalMs"] = defaultIntervalMS
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (aq *AlertQuery) getIntervalMS() (int64, error) {
|
||||
err := aq.setIntervalMS()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
intervalMs, ok := aq.modelProps["intervalMs"].(float64)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("failed to cast intervalMs to float64: %v", aq.modelProps["intervalMs"])
|
||||
}
|
||||
return int64(intervalMs), nil
|
||||
}
|
||||
|
||||
func (aq *AlertQuery) getIntervalDuration() (time.Duration, error) {
|
||||
err := aq.setIntervalMS()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
intervalMs, ok := aq.modelProps["intervalMs"].(float64)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("failed to cast intervalMs to float64: %v", aq.modelProps["intervalMs"])
|
||||
}
|
||||
return time.Duration(intervalMs) * time.Millisecond, nil
|
||||
}
|
||||
|
||||
// GetDatasource returns the query datasource identifier.
|
||||
func (aq *AlertQuery) GetDatasource() (string, error) {
|
||||
err := aq.setDatasource()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return aq.DatasourceUID, nil
|
||||
}
|
||||
|
||||
func (aq *AlertQuery) getModel() ([]byte, error) {
|
||||
err := aq.setDatasource()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = aq.setMaxDatapoints()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = aq.setIntervalMS()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
model, err := json.Marshal(aq.modelProps)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to marshal query model: %w", err)
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
func (aq *AlertQuery) setQueryType() error {
|
||||
if aq.modelProps == nil {
|
||||
err := aq.setModelProps()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
i, ok := aq.modelProps["queryType"]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
queryType, ok := i.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to get queryType from query model: %v", i)
|
||||
}
|
||||
|
||||
aq.QueryType = queryType
|
||||
return nil
|
||||
}
|
||||
|
||||
// PreSave sets query's properties.
|
||||
// It should be called before being saved.
|
||||
func (aq *AlertQuery) PreSave() error {
|
||||
if err := aq.setDatasource(); err != nil {
|
||||
return fmt.Errorf("failed to set datasource to query model: %w", err)
|
||||
}
|
||||
|
||||
if err := aq.setQueryType(); err != nil {
|
||||
return fmt.Errorf("failed to set query type to query model: %w", err)
|
||||
}
|
||||
|
||||
// override model
|
||||
model, err := aq.getModel()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
aq.Model = model
|
||||
|
||||
isExpression, err := aq.IsExpression()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ok := isExpression || aq.RelativeTimeRange.isValid(); !ok {
|
||||
return fmt.Errorf("invalid relative time range: %+v", aq.RelativeTimeRange)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,297 +0,0 @@
|
||||
package eval
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestAlertQuery(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
alertQuery AlertQuery
|
||||
expectedIsExpression bool
|
||||
expectedDatasource string
|
||||
expectedDatasourceUID string
|
||||
expectedMaxPoints int64
|
||||
expectedIntervalMS int64
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "given an expression query",
|
||||
alertQuery: AlertQuery{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage(`{
|
||||
"datasource": "__expr__",
|
||||
"queryType": "metricQuery",
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
},
|
||||
expectedIsExpression: true,
|
||||
expectedDatasource: expr.DatasourceName,
|
||||
expectedDatasourceUID: expr.DatasourceUID,
|
||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||
expectedIntervalMS: int64(defaultIntervalMS),
|
||||
},
|
||||
{
|
||||
desc: "given a query",
|
||||
alertQuery: AlertQuery{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage(`{
|
||||
"datasource": "my datasource",
|
||||
"datasourceUid": "000000001",
|
||||
"queryType": "metricQuery",
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
},
|
||||
expectedIsExpression: false,
|
||||
expectedDatasource: "my datasource",
|
||||
expectedDatasourceUID: "000000001",
|
||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||
expectedIntervalMS: int64(defaultIntervalMS),
|
||||
},
|
||||
{
|
||||
desc: "given a query with valid maxDataPoints",
|
||||
alertQuery: AlertQuery{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage(`{
|
||||
"datasource": "my datasource",
|
||||
"datasourceUid": "000000001",
|
||||
"queryType": "metricQuery",
|
||||
"maxDataPoints": 200,
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
},
|
||||
expectedIsExpression: false,
|
||||
expectedDatasource: "my datasource",
|
||||
expectedDatasourceUID: "000000001",
|
||||
expectedMaxPoints: 200,
|
||||
expectedIntervalMS: int64(defaultIntervalMS),
|
||||
},
|
||||
{
|
||||
desc: "given a query with invalid maxDataPoints",
|
||||
alertQuery: AlertQuery{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage(`{
|
||||
"datasource": "my datasource",
|
||||
"datasourceUid": "000000001",
|
||||
"queryType": "metricQuery",
|
||||
"maxDataPoints": "invalid",
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
},
|
||||
expectedIsExpression: false,
|
||||
expectedDatasource: "my datasource",
|
||||
expectedDatasourceUID: "000000001",
|
||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||
expectedIntervalMS: int64(defaultIntervalMS),
|
||||
},
|
||||
{
|
||||
desc: "given a query with zero maxDataPoints",
|
||||
alertQuery: AlertQuery{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage(`{
|
||||
"datasource": "my datasource",
|
||||
"datasourceUid": "000000001",
|
||||
"queryType": "metricQuery",
|
||||
"maxDataPoints": 0,
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
},
|
||||
expectedIsExpression: false,
|
||||
expectedDatasource: "my datasource",
|
||||
expectedDatasourceUID: "000000001",
|
||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||
expectedIntervalMS: int64(defaultIntervalMS),
|
||||
},
|
||||
{
|
||||
desc: "given a query with valid intervalMs",
|
||||
alertQuery: AlertQuery{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage(`{
|
||||
"datasource": "my datasource",
|
||||
"datasourceUid": "000000001",
|
||||
"queryType": "metricQuery",
|
||||
"intervalMs": 2000,
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
},
|
||||
expectedIsExpression: false,
|
||||
expectedDatasource: "my datasource",
|
||||
expectedDatasourceUID: "000000001",
|
||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||
expectedIntervalMS: 2000,
|
||||
},
|
||||
{
|
||||
desc: "given a query with invalid intervalMs",
|
||||
alertQuery: AlertQuery{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage(`{
|
||||
"datasource": "my datasource",
|
||||
"datasourceUid": "000000001",
|
||||
"queryType": "metricQuery",
|
||||
"intervalMs": "invalid",
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
},
|
||||
expectedIsExpression: false,
|
||||
expectedDatasource: "my datasource",
|
||||
expectedDatasourceUID: "000000001",
|
||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||
expectedIntervalMS: int64(defaultIntervalMS),
|
||||
},
|
||||
{
|
||||
desc: "given a query with invalid intervalMs",
|
||||
alertQuery: AlertQuery{
|
||||
RefID: "A",
|
||||
Model: json.RawMessage(`{
|
||||
"datasource": "my datasource",
|
||||
"datasourceUid": "000000001",
|
||||
"queryType": "metricQuery",
|
||||
"intervalMs": 0,
|
||||
"extraParam": "some text"
|
||||
}`),
|
||||
},
|
||||
expectedIsExpression: false,
|
||||
expectedDatasource: "my datasource",
|
||||
expectedDatasourceUID: "000000001",
|
||||
expectedMaxPoints: int64(defaultMaxDataPoints),
|
||||
expectedIntervalMS: int64(defaultIntervalMS),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
t.Run("can recognize if it's an expression", func(t *testing.T) {
|
||||
isExpression, err := tc.alertQuery.IsExpression()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tc.expectedIsExpression, isExpression)
|
||||
})
|
||||
|
||||
t.Run("can set datasource for expression", func(t *testing.T) {
|
||||
err := tc.alertQuery.setDatasource()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.expectedDatasourceUID, tc.alertQuery.DatasourceUID)
|
||||
})
|
||||
|
||||
t.Run("can set queryType for expression", func(t *testing.T) {
|
||||
err := tc.alertQuery.setQueryType()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "metricQuery", tc.alertQuery.QueryType)
|
||||
})
|
||||
|
||||
t.Run("can update model maxDataPoints (if missing)", func(t *testing.T) {
|
||||
maxDataPoints, err := tc.alertQuery.getMaxDatapoints()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.expectedMaxPoints, maxDataPoints)
|
||||
})
|
||||
|
||||
t.Run("can update model intervalMs (if missing)", func(t *testing.T) {
|
||||
intervalMS, err := tc.alertQuery.getIntervalMS()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, intervalMS, tc.expectedIntervalMS)
|
||||
})
|
||||
|
||||
t.Run("can get the updated model with the default properties (if missing)", func(t *testing.T) {
|
||||
blob, err := tc.alertQuery.getModel()
|
||||
require.NoError(t, err)
|
||||
model := make(map[string]interface{})
|
||||
err = json.Unmarshal(blob, &model)
|
||||
require.NoError(t, err)
|
||||
|
||||
i, ok := model["datasource"]
|
||||
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)
|
||||
datasourceUID, ok := i.(string)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, tc.expectedDatasourceUID, datasourceUID)
|
||||
|
||||
i, ok = model["maxDataPoints"]
|
||||
require.True(t, ok)
|
||||
maxDataPoints, ok := i.(float64)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, tc.expectedMaxPoints, int64(maxDataPoints))
|
||||
|
||||
i, ok = model["intervalMs"]
|
||||
require.True(t, ok)
|
||||
intervalMs, ok := i.(float64)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, tc.expectedIntervalMS, int64(intervalMs))
|
||||
|
||||
i, ok = model["extraParam"]
|
||||
require.True(t, ok)
|
||||
extraParam, ok := i.(string)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, "some text", extraParam)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAlertQueryMarshalling(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
blob string
|
||||
err error
|
||||
expectedFrom Duration
|
||||
expectedTo Duration
|
||||
}{
|
||||
{
|
||||
desc: "unmarshalling successfully when input is correct",
|
||||
blob: `{
|
||||
"refId": "B",
|
||||
"relativeTimeRange": {
|
||||
"from": 18000,
|
||||
"to": 10800
|
||||
},
|
||||
"model": {}
|
||||
}`,
|
||||
expectedFrom: Duration(5 * time.Hour),
|
||||
expectedTo: Duration(3 * time.Hour),
|
||||
},
|
||||
{
|
||||
desc: "failing unmarshalling gracefully when from is incorrect",
|
||||
blob: `{
|
||||
"refId": "B",
|
||||
"relativeTimeRange": {
|
||||
"from": "5h10m",
|
||||
"to": 18000
|
||||
},
|
||||
"model": {}
|
||||
}`,
|
||||
err: fmt.Errorf("invalid duration 5h10m"),
|
||||
},
|
||||
{
|
||||
desc: "failing unmarshalling gracefully when to is incorrect",
|
||||
blob: `{
|
||||
"refId": "B",
|
||||
"relativeTimeRange": {
|
||||
"from": 18000,
|
||||
"to": "5h10m"
|
||||
},
|
||||
"model": {}
|
||||
}`,
|
||||
err: fmt.Errorf("invalid duration 5h10m"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
var aq AlertQuery
|
||||
err := json.Unmarshal([]byte(tc.blob), &aq)
|
||||
require.Equal(t, tc.err, err)
|
||||
if tc.err == nil {
|
||||
assert.Equal(t, tc.expectedFrom, aq.RelativeTimeRange.From)
|
||||
assert.Equal(t, tc.expectedTo, aq.RelativeTimeRange.To)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb"
|
||||
|
||||
@@ -46,7 +48,7 @@ type Condition struct {
|
||||
RefID string `json:"refId"`
|
||||
OrgID int64 `json:"-"`
|
||||
|
||||
QueriesAndExpressions []AlertQuery `json:"queriesAndExpressions"`
|
||||
QueriesAndExpressions []models.AlertQuery `json:"queriesAndExpressions"`
|
||||
}
|
||||
|
||||
// ExecutionResults contains the unevaluated results from executing
|
||||
@@ -117,16 +119,16 @@ func (c *Condition) execute(ctx AlertExecCtx, now time.Time, dataService *tsdb.S
|
||||
|
||||
for i := range c.QueriesAndExpressions {
|
||||
q := c.QueriesAndExpressions[i]
|
||||
model, err := q.getModel()
|
||||
model, err := q.GetModel()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get query model: %w", err)
|
||||
}
|
||||
interval, err := q.getIntervalDuration()
|
||||
interval, err := q.GetIntervalDuration()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve intervalMs from the model: %w", err)
|
||||
}
|
||||
|
||||
maxDatapoints, err := q.getMaxDatapoints()
|
||||
maxDatapoints, err := q.GetMaxDatapoints()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve maxDatapoints from the model: %w", err)
|
||||
}
|
||||
@@ -137,7 +139,7 @@ func (c *Condition) execute(ctx AlertExecCtx, now time.Time, dataService *tsdb.S
|
||||
RefID: q.RefID,
|
||||
MaxDataPoints: maxDatapoints,
|
||||
QueryType: q.QueryType,
|
||||
TimeRange: q.RelativeTimeRange.toTimeRange(now),
|
||||
TimeRange: q.RelativeTimeRange.ToTimeRange(now),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user