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

Log Rows: Added popover menu with filter options when a log line is selected #75306

Merged
merged 44 commits into from
Nov 16, 2023

Conversation

matyax
Copy link
Contributor

@matyax matyax commented Sep 22, 2023

Easier search and filter through the use of a popover menu.

It makes use of the preexisting Explore methods to add filters from Log Details, adding this function to the situation where the user highlights part of a log line.

Hghlights:

  • Supports:
    • Copy text
    • Add line contains filter
    • Add line does not contain filter
  • It is dismissed when:
    • An option is selected
    • The user clears the current selection
    • By pressing escape
  • Shows up when the user selected text in a log line; doesn't show up when multiple log lines are selected.
  • Hides the log row menu while selecting text in a log line.

Which issue(s) does this PR fix?:

Part of #76129

Related PRs:

Demos

Elasticsearch:

Elastic.demo.mov

Loki:

Loki.demo.mov

@github-actions
Copy link
Contributor

Backend code coverage report for PR #75306
No changes

@github-actions
Copy link
Contributor

github-actions bot commented Sep 22, 2023

Frontend code coverage report for PR #75306

Plugin Main PR Difference
explore 85.28% 85.24% -.04%
loki 86.28% 86.15% -.13%

@matyax matyax force-pushed the matyax/log-row-filtering-menu branch from 44cb409 to 0092ae4 Compare October 16, 2023 10:08
@matyax matyax changed the title [Experiment] Log Rows: Add popover menu displayed on-selection with filtering options Log Rows: Add popover menu displayed on-selection with filtering options Oct 16, 2023
@matyax matyax force-pushed the matyax/log-row-filtering-menu branch from 761c06d to 7dc0323 Compare October 17, 2023 14:27
@matyax
Copy link
Contributor Author

matyax commented Oct 17, 2023

Demo updated.

@matyax matyax force-pushed the matyax/log-row-filtering-menu branch from 8b17841 to 9a66d77 Compare October 18, 2023 09:41
@matyax matyax marked this pull request as ready for review November 2, 2023 13:01
@matyax matyax requested review from a team as code owners November 2, 2023 13:01
@matyax matyax force-pushed the matyax/log-row-filtering-menu branch from 9a66d77 to c73d9a9 Compare November 2, 2023 13:18
@gtk-grafana
Copy link
Contributor

This won't work in safari due to #74135

@matyax matyax added no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Nov 3, 2023
@matyax matyax modified the milestones: 10.2.x, 10.3.x Nov 3, 2023
@matyax matyax added add to changelog and removed no-changelog Skip including change in changelog/release notes labels Nov 3, 2023
@matyax matyax changed the title Log Rows: Add popover menu displayed on-selection with filtering options Log Rows: Added popover menu with filter options when a log line is selected Nov 3, 2023
@matyax
Copy link
Contributor Author

matyax commented Nov 3, 2023

@grafana/observability-logs This is ready for review ✨

close();
}}
/>
{onClickFilterValue && (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we may need a better API to check what types of filters the given data source supports. At the moment we have a single check in https://github.com/grafana/grafana/blob/main/public/app/features/explore/Logs/LogsContainer.tsx#L91 but a datasource may support only label/tag filter (ADD_FILTER / ADD_FILTER_OUT) but not line filters (ADD_LINE_FILTER / ADD_LINE_FILTER_OUT) which may lead to showing no-op items in the menu.

We did a very similar thing with Supplementary Queries. A data source implements getSupportedSupplementaryQueryTypes() providing list of supported types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think at some point we should deprecate checking for modifyQuery in favor of hasToggleableQueryFiltersSupport() which is the desired behavior (and API) for log details filters.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you making more changing around this in this PR? I think at the moment the popover will show for data sources that may not support ADD_LINE_FILTER but they support ADD_FILTER 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right @ifrost, thanks for the reminder! I'll take another look at this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will follow up this PR with a fix for this. Something similar to getSupportedSupplementaryQueryTypes() would make an interesting approach, as I don't think we need a new interface for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be addressed by #78322

@ifrost
Copy link
Contributor

ifrost commented Nov 6, 2023

Really cool feature 🙌 Have you considered extending popover menu with Grafana UI Extensions?

@matyax
Copy link
Contributor Author

matyax commented Nov 6, 2023

@ifrost thanks for the feedback!

Have you considered extending popover menu with Grafana UI Extensions?

I've no reference of Grafana UI Extensions. What is it?

@ifrost
Copy link
Contributor

ifrost commented Nov 6, 2023

@ifrost thanks for the feedback!

Have you considered extending popover menu with Grafana UI Extensions?

I've no reference of Grafana UI Extensions. What is it?

Check docs at https://grafana.com/developers/plugin-tools/ui-extensions/. We have one extension point in Explore https://github.com/grafana/grafana/blob/v10.2.0/packages/grafana-data/src/types/pluginExtensions.ts#L119-L123 - it allows plugins and other parts of Grafana to hook into "Add +" button in Explore toolbar.

I was thinking that if there was an extension point we could use it to allow creating correlations with defined regex transformation 🤯 Anyway, just wanted to mention it. Extenstion UI is not needed for this PR, just something to think about in the future.

@matyax
Copy link
Contributor Author

matyax commented Nov 6, 2023

Gotcha! It's definitely a great idea to "explore" 😉

@matyax matyax force-pushed the matyax/log-row-filtering-menu branch from f2889a9 to 8c69abf Compare November 14, 2023 11:01
* Loki modifyQuery: add line does not contain query modification

* Elastic modifyQuery: implement line filters

* Modify query: change action name to not be loki specific

* Prettier

* Prettier

* Elastic: escape filter values
@matyax
Copy link
Contributor Author

matyax commented Nov 14, 2023

@svennergr FYI I merged all the sub-PRs into this one.

Copy link
Contributor

@svennergr svennergr left a comment

Choose a reason for hiding this comment

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

LGTM, just one nit: sometimes the menu does not disappear after left-clicks on the selected text.

Screen.Recording.2023-11-15.at.15.49.24.mov

@matyax matyax removed the type/docs label Nov 16, 2023
@matyax matyax enabled auto-merge (squash) November 16, 2023 09:37
@matyax
Copy link
Contributor Author

matyax commented Nov 16, 2023

Had to cheery-pick the commits from the feature flag and tracking because they were missing in the other PR, probably due to a bad rebase.

Will follow up with a PR to address:

@matyax matyax merged commit 9cb303c into main Nov 16, 2023
25 checks passed
@matyax matyax deleted the matyax/log-row-filtering-menu branch November 16, 2023 09:48
@aangelisc aangelisc modified the milestones: 10.3.x, 10.2.3 Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants