fix(prometheus): remove timerange from context
This commit is contained in:
@@ -34,8 +34,8 @@ type AlertQuery struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
||||||
context.TimeRange = tsdb.NewTimerange(c.Query.From, c.Query.To)
|
timerange := tsdb.NewTimerange(c.Query.From, c.Query.To)
|
||||||
seriesList, err := c.executeQuery(context)
|
seriesList, err := c.executeQuery(context, timerange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
context.Error = err
|
context.Error = err
|
||||||
return
|
return
|
||||||
@@ -69,7 +69,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
|||||||
context.Firing = len(context.EvalMatches) > 0
|
context.Firing = len(context.EvalMatches) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QueryCondition) executeQuery(context *alerting.EvalContext) (tsdb.TimeSeriesSlice, error) {
|
func (c *QueryCondition) executeQuery(context *alerting.EvalContext, timerange tsdb.TimeRange) (tsdb.TimeSeriesSlice, error) {
|
||||||
getDsInfo := &m.GetDataSourceByIdQuery{
|
getDsInfo := &m.GetDataSourceByIdQuery{
|
||||||
Id: c.Query.DatasourceId,
|
Id: c.Query.DatasourceId,
|
||||||
OrgId: context.Rule.OrgId,
|
OrgId: context.Rule.OrgId,
|
||||||
@@ -79,7 +79,7 @@ func (c *QueryCondition) executeQuery(context *alerting.EvalContext) (tsdb.TimeS
|
|||||||
return nil, fmt.Errorf("Could not find datasource")
|
return nil, fmt.Errorf("Could not find datasource")
|
||||||
}
|
}
|
||||||
|
|
||||||
req := c.getRequestForAlertRule(getDsInfo.Result, context.TimeRange)
|
req := c.getRequestForAlertRule(getDsInfo.Result, timerange)
|
||||||
result := make(tsdb.TimeSeriesSlice, 0)
|
result := make(tsdb.TimeSeriesSlice, 0)
|
||||||
|
|
||||||
resp, err := c.HandleRequest(req)
|
resp, err := c.HandleRequest(req)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/log"
|
"github.com/grafana/grafana/pkg/log"
|
||||||
m "github.com/grafana/grafana/pkg/models"
|
m "github.com/grafana/grafana/pkg/models"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/tsdb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type EvalContext struct {
|
type EvalContext struct {
|
||||||
@@ -29,7 +28,6 @@ type EvalContext struct {
|
|||||||
ImageOnDiskPath string
|
ImageOnDiskPath string
|
||||||
NoDataFound bool
|
NoDataFound bool
|
||||||
RetryCount int
|
RetryCount int
|
||||||
TimeRange tsdb.TimeRange
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type StateDescription struct {
|
type StateDescription struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user