mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudMonitoring: Ignore min and max aggregation in MQL queries (#41302)
* ignore min and max aggregations in mql queries * refine comment * moving continuation check to the top of the loop * remove empty line * lint issue
This commit is contained in:
@@ -59,8 +59,6 @@ func (timeSeriesQuery cloudMonitoringTimeSeriesQuery) run(ctx context.Context, r
|
||||
span.SetTag("query", timeSeriesQuery.Query)
|
||||
span.SetTag("from", req.Queries[0].TimeRange.From)
|
||||
span.SetTag("until", req.Queries[0].TimeRange.To)
|
||||
span.SetTag("datasource_id", dsInfo.id)
|
||||
span.SetTag("org_id", req.PluginContext.OrgID)
|
||||
|
||||
defer span.Finish()
|
||||
|
||||
@@ -125,6 +123,14 @@ func (timeSeriesQuery cloudMonitoringTimeSeriesQuery) parseResponse(queryRes *ba
|
||||
}
|
||||
|
||||
for n, d := range response.TimeSeriesDescriptor.PointDescriptors {
|
||||
// If more than 1 pointdescriptor was returned, three aggregations are returned per time series - min, mean and max.
|
||||
// This is a because the period for the given table is less than half the duration which is used in the graph_period MQL function.
|
||||
// See https://cloud.google.com/monitoring/mql/reference#graph_period-tabop
|
||||
// When this is the case, we'll just ignore the min and max and use the mean value in the frame
|
||||
if len(response.TimeSeriesDescriptor.PointDescriptors) > 1 && !strings.HasSuffix(d.Key, ".mean") {
|
||||
continue
|
||||
}
|
||||
|
||||
if _, ok := labels["metric.name"]; !ok {
|
||||
labels["metric.name"] = map[string]bool{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user