Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow templated legend via attribute keys and values from query results #57

Merged
merged 4 commits into from
Sep 4, 2024

Conversation

heidmotron
Copy link
Contributor

@heidmotron heidmotron commented Aug 29, 2024

What does this PR do?

Adds a legend formatter so folks can add custom labels that are derived from the data source.

How does this impact users?

If a user doesn't use a query name, than there is no change.
If a user adds a query name with a label name reference from the query results, like{{service}}, then the legend for the that value is interpolated with the label value.

image

What needed to change in the code and why?

A few changes were made to the Time Series Value fields:

  • Labels are appended to the field it self. This will use default formatting and removes the need for our createFieldName function.
  • Name is changed to use the TIME_SERIES_VALUE_FIELD which has logic to remove the name if there is no displayNameFromDS set and use default label formatting.
  • Query Name allows for variable names in simple mustache like syntax {{var1}} which is similar to the Prometheus / Loki datasource
  • If an attribute value doesn't exist in the results set, then the value will be set to <undefined>

How did you test this?

New unit tests and manually.

@heidmotron heidmotron changed the title Add legend formatter that is similar Prometheus and Loki data sources Allow templated legend via attribute keys and values from query results Aug 29, 2024
@heidmotron heidmotron marked this pull request as ready for review August 29, 2024 03:08
Copy link

@MisterSquishy MisterSquishy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont have a ton of context here, so worth waiting for @DHedgecock if you need a thorough review. but this all looks great to me!

Copy link
Member

@DHedgecock DHedgecock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Let's go

@heidmotron heidmotron merged commit d6b5ede into main Sep 4, 2024
1 check passed
@heidmotron heidmotron deleted the legend branch September 4, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants