bergquist 9 лет назад
Родитель
Сommit
f609623abd
2 измененных файлов с 39 добавлено и 39 удалено
  1. 1 1
      pkg/services/alerting/conditions/evaluator.go
  2. 38 38
      pkg/tsdb/influxdb/influxdb.go

+ 1 - 1
pkg/services/alerting/conditions/evaluator.go

@@ -122,7 +122,7 @@ func NewAlertEvaluator(model *simplejson.Json) (AlertEvaluator, error) {
 		return &NoDataEvaluator{}, nil
 		return &NoDataEvaluator{}, nil
 	}
 	}
 
 
-	return nil, alerting.ValidationError{Reason: "Evaludator invalid evaluator type"}
+	return nil, alerting.ValidationError{Reason: "Evaludator invalid evaluator type: " + typ}
 }
 }
 
 
 func inSlice(a string, list []string) bool {
 func inSlice(a string, list []string) bool {

+ 38 - 38
pkg/tsdb/influxdb/influxdb.go

@@ -51,6 +51,44 @@ func init() {
 	}
 	}
 }
 }
 
 
+func (e *InfluxDBExecutor) Execute(ctx context.Context, queries tsdb.QuerySlice, context *tsdb.QueryContext) *tsdb.BatchResult {
+	result := &tsdb.BatchResult{}
+
+	query, err := e.getQuery(queries, context)
+	if err != nil {
+		return result.WithError(err)
+	}
+
+	glog.Debug("Influxdb query", "raw query", query)
+
+	req, err := e.createRequest(query)
+	if err != nil {
+		return result.WithError(err)
+	}
+
+	resp, err := ctxhttp.Do(ctx, HttpClient, req)
+	if err != nil {
+		return result.WithError(err)
+	}
+
+	if resp.StatusCode/100 != 2 {
+		return result.WithError(fmt.Errorf("Influxdb returned statuscode invalid status code: %v", resp.Status))
+	}
+
+	var response Response
+	dec := json.NewDecoder(resp.Body)
+	dec.UseNumber()
+	err = dec.Decode(&response)
+	if err != nil {
+		return result.WithError(err)
+	}
+
+	result.QueryResults = make(map[string]*tsdb.QueryResult)
+	result.QueryResults["A"] = e.ResponseParser.Parse(&response)
+
+	return result
+}
+
 func (e *InfluxDBExecutor) getQuery(queries tsdb.QuerySlice, context *tsdb.QueryContext) (string, error) {
 func (e *InfluxDBExecutor) getQuery(queries tsdb.QuerySlice, context *tsdb.QueryContext) (string, error) {
 	for _, v := range queries {
 	for _, v := range queries {
 		query, err := e.QueryParser.Parse(v.Model)
 		query, err := e.QueryParser.Parse(v.Model)
@@ -92,41 +130,3 @@ func (e *InfluxDBExecutor) createRequest(query string) (*http.Request, error) {
 	glog.Debug("influxdb request", "url", req.URL.String())
 	glog.Debug("influxdb request", "url", req.URL.String())
 	return req, nil
 	return req, nil
 }
 }
-
-func (e *InfluxDBExecutor) Execute(ctx context.Context, queries tsdb.QuerySlice, context *tsdb.QueryContext) *tsdb.BatchResult {
-	result := &tsdb.BatchResult{}
-
-	query, err := e.getQuery(queries, context)
-	if err != nil {
-		return result.WithError(err)
-	}
-
-	glog.Debug("Influxdb query", "raw query", query)
-
-	req, err := e.createRequest(query)
-	if err != nil {
-		return result.WithError(err)
-	}
-
-	resp, err := ctxhttp.Do(ctx, HttpClient, req)
-	if err != nil {
-		return result.WithError(err)
-	}
-
-	if resp.StatusCode/100 != 2 {
-		return result.WithError(fmt.Errorf("Influxdb returned statuscode invalid status code: %v", resp.Status))
-	}
-
-	var response Response
-	dec := json.NewDecoder(resp.Body)
-	dec.UseNumber()
-	err = dec.Decode(&response)
-	if err != nil {
-		return result.WithError(err)
-	}
-
-	result.QueryResults = make(map[string]*tsdb.QueryResult)
-	result.QueryResults["A"] = e.ResponseParser.Parse(&response)
-
-	return result
-}