Add legend name to dataframes config (#32356)

This commit is contained in:
Dimitris Sotirakis 2021-03-26 16:20:46 +02:00 committed by GitHub
parent 9f2fa7c20c
commit 2a5279911f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -216,7 +216,7 @@ func parseResponse(value model.Value, query *PrometheusQuery) (plugins.DataQuery
}
frames = append(frames, data.NewFrame(name,
data.NewField("time", nil, timeVector),
data.NewField("value", tags, values)))
data.NewField("value", tags, values).SetConfig(&data.FieldConfig{DisplayNameFromDS: name})))
}
queryRes.Dataframes = plugins.NewDecodedDataFrames(frames)

View File

@ -182,6 +182,7 @@ func TestParseResponse(t *testing.T) {
require.Len(t, decoded[0].Fields[1].Labels, 2)
require.Equal(t, decoded[0].Fields[1].Labels.String(), "app=Application, tag2=tag2")
require.Equal(t, decoded[0].Fields[1].Name, "value")
require.Equal(t, decoded[0].Fields[1].Config.DisplayNameFromDS, "legend Application")
// Ensure the timestamps are UTC zoned
testValue := decoded[0].Fields[0].At(0)