feat(log-query): add jq:
filter syntax to improve JSON log readability (JMESPath to follow)
#840
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
To improve the readability of JSON logs, this PR adds a
jq:<expr>
filter syntax to the log query input form. This allows extracting specific fields and restructuring output inline in the query.JMESPath will be added in a subsequent PR (
jmespath:<expr>
).Background
As noted in the issue, raw JSON logs can be verbose and make it hard to quickly reach the needed information during operations. Allowing a filter expression directly in the query enables on-the-fly transformation into a more readable view.
Scope (this PR)
New syntax:
jq:<expr>
<expr>
and render the result.Works alongside existing query terms such as
log:
/!log:
,pod:
,container:
.Help: add
jq:
documentation and examples to the query help.Documentation: update README with jq filter usage and examples.
Usage examples
Compatibility
jq:
is specified.Tests
jq:
tokenization, quoting/escaping, rule when multiplejq:
are provided (last one wins).jq:
entry appears correctly in help dialog.Added 16 comprehensive tests covering parser, compilation, and log rendering scenarios.
Future work (separate PRs)
jmespath:<expr>
support.