-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(logql): Support drop labels in logql pipeline #7975
Conversation
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 can already use | __error__=""
to ignore errors and | label_format x="{{.__error__}}"
to extract errors to new labels, but I'm definitely interested in a way to remove existing labels. It sounds like your label_format_rename_errors
is a nice syntactic sugar for a combination of these.
Would it make more sense to start with a | strip <label> <label>
operation which could remove labels from the results? I think this would result in cleaner code as well since we wouldn't have to have special cases for the __error__
label besides preventing it from being rewritten (current behavior).
With
I am totally ok with this. This would be a nice approach. However, I think we should still support renaming |
Good distinction there 👍 . I think we could achieve what you're suggesting with something like
This would be a little more verbose, but it won't have to treat the |
Yes, this would do. Should we say Also, should we support |
I'm inclined to use |
|
./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
@owen-d Not sure if we should support What do you suggest? |
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.
I'd like to support drop
with __error_details__
. Is there a reason you don't think so? For instance, | drop __error_details__=~"unexpected json:.*"
would be helpful.
- `=~`: regex matches | ||
- `!~`: regex does not match | ||
|
||
The `| drop` expression will drop the given labels in the pipeline. For example, for the query `{job="varlogs"}|json|drop level, method="GET"`, with below log line |
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.
Let's add a few other examples:
| drop level
| drop level="warn"
| drop app=~"api.*"
| drop foo="bar", bazz
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.
Have added one more example with regex match
. The examples shown in doc will cover the above examples. Let me know if we should add more.
./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
@owen-d Have added support for |
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.
This looks great. I'm approving now, but I think | drop __error__
should also remove __error_details__
so we can more ergonomically use | drop __error__
instead of needing to do | drop __error__ __error_details__
. Can we make that last change?
the result will be | ||
|
||
``` | ||
{} INFO GET / loki.net 200 |
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.
I think this is how it should work, but currently I expect it to keep __error_details__
when | drop __error__
is used. I think it should also remove __error_details__
like this doc suggests.
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.
@owen-d Yeah, that was the earlier behaviour I added but later removed that while adding support for __error__details__
. I will send a follow up PR for this change.
What should be the behaviour in this case |drop __error_details__
or |drop __error_details__="some error details"
? Should we remove __error__
with this?
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.
Personally I think |drop __error_details__
shouldn't remove __error__
, but |drop __error__
should also remove __error_details__
. To me, it feels like the __error_details__
are a child of __error__
./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
What this PR does / why we need it:
This PR introduces
drop
stage in logql pipeline.Which issue(s) this PR fixes:
Fixes #7870, Fixes #7368
Checklist
CONTRIBUTING.md
guideCHANGELOG.md
updateddocs/sources/logql/log_queries.md