Commit 73dc7bdd by Erik Sundell

stackdriver: use alignment that is passed from frontend in the query

parent 549b4fc0
...@@ -136,17 +136,28 @@ func (e *StackdriverExecutor) buildQueries(tsdbQuery *tsdb.TsdbQuery) ([]*Stackd ...@@ -136,17 +136,28 @@ func (e *StackdriverExecutor) buildQueries(tsdbQuery *tsdb.TsdbQuery) ([]*Stackd
func setAggParams(params *url.Values, query *tsdb.Query) { func setAggParams(params *url.Values, query *tsdb.Query) {
primaryAggregation := query.Model.Get("primaryAggregation").MustString() primaryAggregation := query.Model.Get("primaryAggregation").MustString()
secondaryAggregation := query.Model.Get("secondaryAggregation").MustString()
perSeriesAligner := query.Model.Get("perSeriesAligner").MustString()
if primaryAggregation == "" { if primaryAggregation == "" {
primaryAggregation = "REDUCE_NONE" primaryAggregation = "REDUCE_NONE"
} }
if primaryAggregation == "REDUCE_NONE" { if secondaryAggregation == "" {
params.Add("aggregation.perSeriesAligner", "ALIGN_NONE") secondaryAggregation = "REDUCE_NONE"
} else { }
if perSeriesAligner == "" {
perSeriesAligner = "ALIGN_MEAN"
}
if secondaryAggregation == "" {
secondaryAggregation = "REDUCE_NONE"
}
params.Add("aggregation.crossSeriesReducer", primaryAggregation) params.Add("aggregation.crossSeriesReducer", primaryAggregation)
params.Add("aggregation.perSeriesAligner", "ALIGN_MEAN") params.Add("aggregation.perSeriesAligner", perSeriesAligner)
params.Add("aggregation.alignmentPeriod", "+60s") params.Add("aggregation.alignmentPeriod", "+60s")
} // params.Add("aggregation.secondaryAggregation.crossSeriesReducer", secondaryAggregation)
groupBys := query.Model.Get("groupBys").MustArray() groupBys := query.Model.Get("groupBys").MustArray()
if len(groupBys) > 0 { if len(groupBys) > 0 {
...@@ -166,6 +177,7 @@ func (e *StackdriverExecutor) executeQuery(ctx context.Context, query *Stackdriv ...@@ -166,6 +177,7 @@ func (e *StackdriverExecutor) executeQuery(ctx context.Context, query *Stackdriv
} }
req.URL.RawQuery = query.Params.Encode() req.URL.RawQuery = query.Params.Encode()
fmt.Println("req.URL.RawQuery: ", req.URL.RawQuery)
queryResult.Meta.Set("rawQuery", req.URL.RawQuery) queryResult.Meta.Set("rawQuery", req.URL.RawQuery)
span, ctx := opentracing.StartSpanFromContext(ctx, "stackdriver query") span, ctx := opentracing.StartSpanFromContext(ctx, "stackdriver query")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment