elastic: backend: handle naming bucket_scripts (#60460)

This commit is contained in:
Gábor Farkas 2023-01-04 15:26:57 +01:00 committed by GitHub
parent 72d257ed4f
commit 12c4098bcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 14 deletions

View File

@ -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 != "" {

View File

@ -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)

View File

@ -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"