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

Table Panel: Filter column values with operators or expressions #79853

Merged

Conversation

ahuarte47
Copy link
Contributor

@ahuarte47 ahuarte47 commented Dec 25, 2023

What is this feature?

This MR adds the capability of showing column values in a Table panel using comparison operators or evaluating a bool expression.

User can choose from several operators to display column values:

  • contains operator matches a regex pattern (operator by default)
  • The typical comparison operators (=, !=, <, <=, >, >=)
  • expression operator evaluates a bool expression, char $ represents the column value in the expression (e.g. "$ >= 10 && $ <= 50").

This MR provides extra capabilities to work with #79290

Why do we need this feature?

When using big tables there is often a need to filter by values to select many entries. There is no possibility to select them using a precise criteria (e.g. a range of values, "value >= 10.0 && value <= 50").

image

Who is this feature for?

Users filtetring large list of values in tables.

Which issue(s) does this PR fix?:

Fixes #79800

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@ahuarte47 ahuarte47 requested a review from a team December 25, 2023 22:01
@ahuarte47 ahuarte47 requested review from codeincarnate and oscarkilhed and removed request for a team December 25, 2023 22:01
@ahuarte47 ahuarte47 changed the title Main table select with operators2 Main table select with operators or expressions Dec 25, 2023
@grafana-pr-automation grafana-pr-automation bot added type/docs area/frontend pr/external This PR is from external contributor labels Dec 25, 2023
@ahuarte47 ahuarte47 changed the title Main table select with operators or expressions Select column values in Table with operators or expressions Dec 25, 2023
@ahuarte47 ahuarte47 changed the title Select column values in Table with operators or expressions Flter column values in Table with operators or expressions Dec 25, 2023
@ahuarte47 ahuarte47 changed the title Flter column values in Table with operators or expressions Filter column values in Table with operators or expressions Dec 25, 2023
@ahuarte47 ahuarte47 changed the title Filter column values in Table with operators or expressions Filter column values in Table panel with operators or expressions Dec 25, 2023
Copy link
Collaborator

@imatwawana imatwawana left a comment

Choose a reason for hiding this comment

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

I think "contains" and "expression" in the UI should have the first letter capitalized to align with the rest of the UI. Also are the typical comparison operators just all separate options in the drop-down list?

@ahuarte47
Copy link
Contributor Author

Yes, there are a list of typical comparison operators:
image

image
image
image
image
image
image
image
image

@leeoniya
Copy link
Contributor

leeoniya commented Jan 3, 2024

@ahuarte47 funny coincidence, i recently made something similar, that supports complex expressions on multiple fields. was hoping to integrate it in the future for similar purposes of matching/filtering data :)

https://github.com/leeoniya/uExpr

Copy link
Collaborator

@imatwawana imatwawana left a comment

Choose a reason for hiding this comment

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

I'm approving the docs element of this, but of course this still has to go through technical review.

@ahuarte47
Copy link
Contributor Author

Hi @oscarkilhed @imatwawana @codeincarnate please, are there any plan to review this MR?

@imatwawana
Copy link
Collaborator

Hi @oscarkilhed @imatwawana @codeincarnate please, are there any plan to review this MR?

Hey, @ahuarte47, I've already approved this for the docs updates, but the other reviewers will need confirm that they approve this as well.

@imatwawana imatwawana added this to the 10.4.x milestone Feb 8, 2024
@nmarrs nmarrs changed the title Filter column values in Table panel with operators or expressions Table: Filter column values with operators or expressions Feb 8, 2024
@nmarrs nmarrs requested a review from a team February 8, 2024 21:35
@nmarrs nmarrs requested review from drew08t and baldm0mma and removed request for a team February 8, 2024 21:35
@nmarrs nmarrs added add to changelog no-backport Skip backport of PR labels Feb 8, 2024
Copy link
Collaborator

@codeincarnate codeincarnate left a comment

Choose a reason for hiding this comment

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

First off, thanks so much for the contribution! This looks pretty good, that being said please see my comments on changes.

Other than that, I think that the control should be moved below "Select All Values" with a heading label of "Filter Available Values" or similar. Currently it's a little unclear what the control will do until you start using it and I think that should help. Nonetheless overall I think this is definitely useful.

We also may need to dig in a bit more to determine what we should do for cases with changing values as that may end up being a bit unintuitive.

@ahuarte47 ahuarte47 requested a review from a team as a code owner February 9, 2024 17:46
@codeincarnate
Copy link
Collaborator

Thanks so much for the change @ahuarte47. I'll be taking another look today.

Copy link
Collaborator

@codeincarnate codeincarnate left a comment

Choose a reason for hiding this comment

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

Took another look, very much appreciate the updates and I think this looks good! Definitely makes this more useful overall 🥳

Copy link
Contributor

@nmarrs nmarrs left a comment

Choose a reason for hiding this comment

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

This looks great @ahuarte47!

One note I had while testing this out locally is that the filter state seems to be cleared (i.e. in this case the > 20 condition, while the selected values stay in place as expected)

Screen.Recording.2024-02-13.at.12.10.38.AM.mov

If not too much of a lift I think persisting the filter state would be useful and provide a better overall UX - happy for us to address this as a follow-up PR - cc @codeincarnate interested in your thoughts here 😬

@ahuarte47
Copy link
Contributor Author

Hi @nmarrs, thank you very much!

About...

One note I had while testing this out locally is that the filter state seems to be cleared (i.e. in this case the > 20 condition, while the selected values stay in place as expected)

If not too much of a lift I think persisting the filter state would be useful and provide a better overall UX - happy for us to address this as a follow-up PR

You are right, it would be great to persist the filter state, I should study how to do this, maybe looking at other similar controls. Anyway, any help is welcome, of course!

@codeincarnate
Copy link
Collaborator

@nmarrs I'd be fine addressing that in a follow-up PR. It's potentially a little annoying but it doesn't seem like a deal breaker 😄

@codeincarnate codeincarnate changed the title Table: Filter column values with operators or expressions Table Panel: Filter column values with operators or expressions Feb 14, 2024
@codeincarnate codeincarnate merged commit 06b5875 into grafana:main Feb 14, 2024
17 of 18 checks passed
@ahuarte47
Copy link
Contributor Author

Hi, thank you very much to everybody for your reviews and advices!

@ahuarte47 ahuarte47 deleted the main_table-select-with-operators2 branch February 14, 2024 18:12
@aangelisc aangelisc modified the milestones: 10.4.x, 10.4.0 Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FeatureRequest] Add support in Table column filter to select values with operators or expressions
6 participants