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-5761: Add support LogQL pattern line filters #200

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
}
},
"dependencies": {
"@grafana/lezer-logql": "^0.1.1",
"@grafana/lezer-logql": "^0.2.6",
"@patternfly/patternfly": "4.215.1",
"@patternfly/react-charts": "6.92.0",
"@patternfly/react-core": "4.239.0",
Expand Down
8 changes: 8 additions & 0 deletions web/src/__tests__/logql-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,14 @@ describe('LogQL query', () => {
expected:
'{ log_type=~".+" } | json | level="unknown" or level="" != "tekton" |= "TLS handshake error from 10." !~ "10.128" |~ "10.128"',
},
{
query: '{ app="foobar" } |> "I <_>" | json',
expected: '{ app="foobar" } |> "I <_>" | json',
},
{
query: '{ app="foobar" } !> "I <_>" | json',
expected: '{ app="foobar" } !> "I <_>" | json',
},
].forEach(({ query, expected }) => {
const logql = new LogQLQuery(query);
expect(logql.toString()).toEqual(expected);
Expand Down
6 changes: 5 additions & 1 deletion web/src/logql-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ const parseLineFilters = (
from: node.from,
to: node.to,
enter(selectorsNode) {
if (['PipeExact', 'PipeMatch', 'Eq', 'Neq', 'Re', 'Nre'].includes(selectorsNode.name)) {
if (
['PipeExact', 'PipeMatch', 'PipePattern', 'Npa', 'Eq', 'Neq', 'Re', 'Nre'].includes(
selectorsNode.name,
)
) {
operator = query.slice(selectorsNode.from, selectorsNode.to);

return false;
Expand Down