mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Fix processing of duplicated metric types and field (#66973)
* Elasticsearch: Fix processing of duplicated metric types and field * Fix lint * Fix linting
This commit is contained in:
@@ -1255,13 +1255,24 @@ func addOtherMetricsToFields(fields *[]*data.Field, bucket *simplejson.Json, met
|
||||
otherMetrics := make([]*MetricAgg, 0)
|
||||
|
||||
for _, m := range target.Metrics {
|
||||
if m.Type == metric.Type {
|
||||
// To other metrics we add metric of the same type that are not the current metric
|
||||
if m.ID != metric.ID && m.Type == metric.Type {
|
||||
otherMetrics = append(otherMetrics, m)
|
||||
}
|
||||
}
|
||||
|
||||
if len(otherMetrics) > 1 {
|
||||
if len(otherMetrics) > 0 {
|
||||
metricName += " " + metric.Field
|
||||
|
||||
// We check if we have metric with the same type and same field name
|
||||
// If so, append metric.ID to the metric name
|
||||
for _, m := range otherMetrics {
|
||||
if m.Field == metric.Field {
|
||||
metricName += " " + metric.ID
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if metric.Type == "bucket_script" {
|
||||
// Use the formula in the column name
|
||||
metricName = metric.Settings.Get("script").MustString("")
|
||||
|
||||
Reference in New Issue
Block a user