[v10.3.x] Elasticsearch: Fix creating of legend so it is backward compatible with frontend produced frames #81786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport f2936d6 from #81708
During backend migration, we focused on making sure that legends generated on frontend and backend are the same. We were able to achieve this trough #66039, but unfortunately, this solution does not hold when it comes to using transformations - related to https://github.com/grafana/support-escalations/issues/8787. When transformations that rename fields are used, the renaming does not work because
DisplayNameFromDS
overwrites it.So I was checking if there are other options and I was able to achieve the same frames naming using
frame.Name
and deletinglabels
fordata.FrameTypeTimeSeriesMulti
.Here are comparisons on frame created in frontend (left) and backend (right) - both have the same name and no labels:
How to test:
Go to http://localhost:3000/d/es_complex_template/datasource-tests-elasticsearch-complex-with-template-variables?orgId=1 and make sure that legends on frontend running queries and backend running queries are same (see the recording bellow).
For now, ignore Multiple metrics and aggregations section which was skipped also in Elasticsearch: Fix legend generated on backend #66039 and it is not related to this change - it is related to label named
metric
. I will address this in separate PR.esnamingfix.mp4