mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
elastic: backend: handle naming bucket_scripts (#60460)
This commit is contained in:
parent
72d257ed4f
commit
12c4098bcd
@ -592,8 +592,8 @@ func getFieldName(dataField data.Field, target *Query, metricTypeCount int) stri
|
||||
return frameName
|
||||
}
|
||||
// todo, if field and pipelineAgg
|
||||
if field != "" && isPipelineAgg(metricType) {
|
||||
if isPipelineAggWithMultipleBucketPaths(metricType) {
|
||||
if isPipelineAgg(metricType) {
|
||||
if metricType != "" && isPipelineAggWithMultipleBucketPaths(metricType) {
|
||||
metricID := ""
|
||||
if v, ok := dataField.Labels["metricId"]; ok {
|
||||
metricID = v
|
||||
@ -612,15 +612,17 @@ func getFieldName(dataField data.Field, target *Query, metricTypeCount int) stri
|
||||
}
|
||||
}
|
||||
} else {
|
||||
found := false
|
||||
for _, metric := range target.Metrics {
|
||||
if metric.ID == field {
|
||||
metricName += " " + describeMetric(metric.Type, field)
|
||||
found = true
|
||||
if field != "" {
|
||||
found := false
|
||||
for _, metric := range target.Metrics {
|
||||
if metric.ID == field {
|
||||
metricName += " " + describeMetric(metric.Type, field)
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
metricName = "Unset"
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
metricName = "Unset"
|
||||
}
|
||||
}
|
||||
} else if field != "" {
|
||||
|
@ -1281,7 +1281,7 @@ func TestBucketScript(t *testing.T) {
|
||||
requireFrameLength(t, frames[0], 2)
|
||||
requireTimeSeriesName(t, "Sum @value", frames[0])
|
||||
requireTimeSeriesName(t, "Max @value", frames[1])
|
||||
// requireTimeSeriesName(t, "Sum @value * Max @value", frames[2]) // FIXME
|
||||
requireTimeSeriesName(t, "Sum @value * Max @value", frames[2])
|
||||
|
||||
requireNumberValue(t, 2, frames[0], 0)
|
||||
requireNumberValue(t, 3, frames[1], 0)
|
||||
|
@ -912,7 +912,6 @@ func TestResponseParser(t *testing.T) {
|
||||
{ "id": "3", "type": "max", "field": "@value" },
|
||||
{
|
||||
"id": "4",
|
||||
"field": "select field",
|
||||
"pipelineVariables": [{ "name": "var1", "pipelineAgg": "1" }, { "name": "var2", "pipelineAgg": "3" }],
|
||||
"settings": { "script": "params.var1 * params.var2" },
|
||||
"type": "bucket_script"
|
||||
@ -991,14 +990,12 @@ func TestResponseParser(t *testing.T) {
|
||||
{ "id": "3", "type": "max", "field": "@value" },
|
||||
{
|
||||
"id": "4",
|
||||
"field": "select field",
|
||||
"pipelineVariables": [{ "name": "var1", "pipelineAgg": "1" }, { "name": "var2", "pipelineAgg": "3" }],
|
||||
"settings": { "script": "params.var1 * params.var2" },
|
||||
"type": "bucket_script"
|
||||
},
|
||||
{
|
||||
"id": "5",
|
||||
"field": "select field",
|
||||
"pipelineVariables": [{ "name": "var1", "pipelineAgg": "1" }, { "name": "var2", "pipelineAgg": "3" }],
|
||||
"settings": { "script": "params.var1 * params.var2 * 2" },
|
||||
"type": "bucket_script"
|
||||
|
Loading…
Reference in New Issue
Block a user