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
Loki: Always display log context toggle #66379
Conversation
Backend code coverage report for PR #66379 |
Frontend code coverage report for PR #66379
|
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 that to fix #66132, we should consider always showing log context. And the more I am thinking about it, the more I think it make sense to always show log context toggle.
The reason for this is that log context is created from all labels defining the stream for the selected log line. And it has basically nothing to do with filter being present/not being present. I think that showing log context only when filter is present is actually more confusing as it makes log context associated with line filters, when it should be associated with log line labels/streams.
So before moving with this PR that introduces negative searchWords (that still acts in Highlight component like normal searchWords because -
has no effect on showing/not showing highlighted text), I would consider just showing context all the time.
What do you think @grafana/observability-logs?
Makes sense to me. Should we do it before G10? |
Thank you @ivanahuckova. Always showing the context button makes sense to me as well 👍 I can do that in this PR if we all agree. |
👍 |
f972ef8
to
d875b25
Compare
@svennergr One thing I noticed after this is that it seems to be ignoring the log line immediately above the one I'm expanding: |
I guess that logline has different labels than the others. You can set the |
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.
I am wondering if we should mark showContextToggle
here https://github.com/grafana/grafana/blob/0457291ac2cfc987985c805e0f03282861c695e9/packages/grafana-data/src/types/logs.ts deprecated and remove that functionality at one point completely.
I think we should, @svennergr , as every |
* Loki search words: process negative expressions as negative search words * Revert "Loki search words: process negative expressions as negative search words" This reverts commit d875b25. * Logs Context: always display
The changes in this PR are to always offer Logs Context, independent of the current query.
The reason for this is that log context is created from all labels defining the stream for the selected log line. And it has basically nothing to do with filter being present/not being present. I think that showing log context only when filter is present is actually more confusing as it makes log context associated with line filters, when it should be associated with log line labels/streams.
This PR adds support for offering logs context for logs lines generated using negative filters.Since deciding to show or not show the logs context toggle depends on the presence of search words https://github.com/grafana/grafana/blob/main/public/app/plugins/datasource/loki/datasource.ts#L821 ; and search words were based on the presence ofPipeExact
orPipeMatch
nodes, the code has been changed to also look forNeq
andNre
nodes. When these are present, the search words are prepended with-
. For example,!= word
is processed as-word
.The other alternative was adding a new function to look forNeq
andNre
in the query, and add a newcustom
property returned from thebackendResultTransformer
as, for example,custom.hasNegativeExpressions
https://github.com/grafana/grafana/blob/main/public/app/plugins/datasource/loki/backendResultTransformer.ts#L4 ; and then updatinglogsSeriesToLogsModels
and theLogsModel
type, to pick up this property and return it for every row. https://github.com/grafana/grafana/blob/main/public/app/core/logsModel.ts#L426I decided for the alternative I sent in this PR because it was simpler and didn't require more parsing, new properties, or type updates.Which issue(s) does this PR fix?:
Fixes #66132
Special notes for your reviewer:
Returning negative expressions as negative search words didn't seem to have any visible harmful effect, and allowed us to offer logs context for these queries. Nothing should be broken after these changes.To test, write any query with negative expressions and see the logs context toggle for each row:Now we will always display the button for logs.