-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
@@ -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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR doesn't make sense after a6a599c. |
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.