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

vmui/logs: add support for head|limit in expressions #6157

Closed
wants to merge 1 commit into from

Conversation

Loori-R
Copy link
Contributor

@Loori-R Loori-R commented Apr 19, 2024

Adds correct handling of head|limit in expressions.
For example, the query * | limit 10 will be transformed into _time:[some_interval] AND (*) | limit 10.

Related pull request: #6154.

@@ -13,13 +13,21 @@ export const useFetchLogs = (server: string, query: string, limit: number) => {

const url = useMemo(() => getLogsUrl(server), [server]);

const prepareQuery = (query: string) => {
const limitRegex = /\|\s*(limit|head)\s*:?[\s-]*\d+/gm;
Copy link
Collaborator

Choose a reason for hiding this comment

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

: is optional, you can have limit 10 or limit: 10

Copy link
Collaborator

Choose a reason for hiding this comment

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

and there will be more more things like that - so it worth to change logic of _time instead of add checks for limit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it works just like that, : is optional

Copy link
Contributor Author

@Loori-R Loori-R Apr 19, 2024

Choose a reason for hiding this comment

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

In any case, we need to wrap part of the expression in parentheses to ensure that the time range applies to all parts of the expression. Here is a more detailed explanation of why this is necessary: #5920.

At the moment, I don't understand what format such things will have, but perhaps we will be able to easily identify them and move them outside the brackets. If you have any ideas on how to change the logic, let me know.

As an alternative, it might be worth implementing support for query parameters for the time range to solve this problem on the server side.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we are going to add | fields * or | fields container_name, level as next function, just keep in mind

Copy link
Contributor

@dmitryk-dk dmitryk-dk left a comment

Choose a reason for hiding this comment

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

LGTM!

@hagen1778
Copy link
Collaborator

Hey @Loori-R! Does this PR makes sense after a6a599c ?

@Loori-R
Copy link
Contributor Author

Loori-R commented May 20, 2024

This PR doesn't make sense after a6a599c.

@Loori-R Loori-R closed this May 20, 2024
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.

None yet

4 participants