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

Loki: Filter by labels based on the type of label (structured, indexed, parsed) #78595

Merged
merged 20 commits into from
Nov 27, 2023

Conversation

svennergr
Copy link
Contributor

@svennergr svennergr commented Nov 23, 2023

What is this feature?

This feature improves the filter actions in the LogDetails for Loki. When the dataframe contains a definition about the label type, indexed labels will always be added to the stream selector. Parsed labels and keys from structured metadata will be added as LabelFilter expressions.

Screen.Recording.2023-11-23.at.14.33.16.mov

How to test

  1. Without the lokiStructuredMetadata feature toggle nothing should change.
  2. With lokiStructuredMetadata set, labels should be added accordingly.

Copy link
Contributor

github-actions bot commented Nov 24, 2023

⚠️   Possible breaking changes

(Open the links below in a new tab to go to the correct steps)

grafana-data has possible breaking changes (more info)

Console output
Read our guideline

@github-actions github-actions bot added the levitate breaking change A label indicating a breaking change and assigned by Levitate. label Nov 24, 2023
@svennergr svennergr marked this pull request as ready for review November 24, 2023 09:57
@svennergr svennergr requested review from a team as code owners November 24, 2023 09:57
@svennergr svennergr requested review from Clarity-89, ashharrison90 and leventebalogh and removed request for a team November 24, 2023 09:57
@academo
Copy link
Member

academo commented Nov 24, 2023

I took a look at the levitate breaking changes and they are fine. We are working on improving these cases where comments or optional new attributes create these false positives.

@svennergr svennergr removed the levitate breaking change A label indicating a breaking change and assigned by Levitate. label Nov 24, 2023
Copy link
Member

@ivanahuckova ivanahuckova left a comment

Choose a reason for hiding this comment

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

Left some comments/questions bellow. But overall really great job. The test coverage is :chefs-kiss:

@@ -264,6 +264,7 @@ export interface QueryFilterOptions extends KeyValue<string> {}
export interface ToggleFilterAction {
type: 'FILTER_FOR' | 'FILTER_OUT';
Copy link
Member

Choose a reason for hiding this comment

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

Not related to this PR but just a note - would be nice if we could type type: 'FILTER_FOR' | 'FILTER_OUT'; using QueryFixType somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, not sure about a cleaner way here. @matyax maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe for 11 we can clean up all these types, and even rename some to reflect, for example, if you're adding a "field" (or label) filter or a string filter.

packages/grafana-data/src/types/datasource.ts Show resolved Hide resolved
public/app/features/logs/logsModel.ts Outdated Show resolved Hide resolved
public/app/features/logs/logsModel.ts Outdated Show resolved Hide resolved
public/app/plugins/datasource/loki/modifyQuery.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@matyax matyax left a comment

Choose a reason for hiding this comment

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

Looks really good! Left some questions and comments.

packages/grafana-data/src/types/datasource.ts Show resolved Hide resolved
public/app/features/explore/Explore.tsx Outdated Show resolved Hide resolved
public/app/features/logs/logsModel.ts Show resolved Hide resolved
public/app/plugins/datasource/loki/datasource.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot added the levitate breaking change A label indicating a breaking change and assigned by Levitate. label Nov 24, 2023
@svennergr svennergr changed the title Loki: Filter by labels based on labeltype Loki: Filter by labels based on the type of label (structured, indexed, parsed) Nov 24, 2023
Copy link
Member

@ivanahuckova ivanahuckova left a comment

Choose a reason for hiding this comment

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

LGTM! I added a suggestion to make it more clear why is the logic to add filter when labelType is not set much more complex than when it is - because at that point, the query might be metric and we need to add label to each expression. Cause it took me a second to realize that.

public/app/plugins/datasource/loki/modifyQuery.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/explore area/frontend datasource/Loki levitate breaking change A label indicating a breaking change and assigned by Levitate. no-backport Skip backport of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants