-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Description
Describe the bug
If {app="foo"} |= ""
matches all log lines, and {app="foo"} |= "notfound"
matches none, I expect that:
{app="foo"} |= "notfound" or ""
should match all log lines.
Instead it matches no lines.
I believe this is caused by a mistake in the logic in newOrFilter
:
Lines 309 to 316 in cfd07c3
func newOrFilter(left MatcherFilterer, right MatcherFilterer) MatcherFilterer { | |
if left == nil || isTrueFilter(left) { | |
return right | |
} | |
if right == nil || isTrueFilter(right) { | |
return left | |
} |
Where if
left
or right
is trivially true, it also requires the other side to be true, treating it as an and
clause.It should instead treat the whole or clause as trivially true.
This also affects simplified regular expression matches, so {app="foo"} |~ "(notfound|)"
will match no lines, while {app="foo"} |~ ""
or {app="foo"} |~ "(|)"
matches all lines.
To Reproduce
Steps to reproduce the behavior:
Observe no results from
{cluster="eu-west-1"} |= "" or "notfound"
Expected behavior
{app="foo"} |= "notfound" or ""
should match all log lines, consistent with{app="foo"} |= ""
and{app="foo"} |= "" or ""
{app="foo"} |~ "(notfound|)"
should match all log lines, consistent with{app="foo"} |~ ""
and{app="foo"} |~ "(|)"
Environment:
N/A
Screenshots, Promtail config, or terminal output
N/A
Metadata
Metadata
Assignees
Labels
No labels