-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
fix: correct _extracted logic in detected fields #14064
fix: correct _extracted logic in detected fields #14064
Conversation
pkg/querier/querier.go
Outdated
} | ||
} | ||
func parseEntry(entry push.Entry, lbls *logql_log.LabelsBuilder) (map[string][]string, []string) { | ||
logFmtParser := logql_log.NewLogfmtParser(false, false) |
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 was part of the problem, we had strict turned on previously
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.
Does it make sense to only initialise the parser (call logFmtParser := logql_log.NewLogfmtParser(false, false)
) when we need it? I.e. move it somewhere here https://github.com/grafana/loki/pull/14064/files#diff-a0b881d1b7b99f439716f189b50eef90ccdaea00845b087c0dbce0e148aa2c0eR1339
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.
yes, can do... missed that when I change the order to try json first
@@ -1403,12 +1420,28 @@ func streamsForFieldDetection(i iter.EntryIterator, size uint32) (logqlmodel.Str | |||
// If lastEntry.Unix < 0 this is the first pass through the loop and we should output the line. | |||
// Then check to see if the entry is equal to, or past a forward step | |||
if lastEntry.Unix() < 0 || shouldOutput { | |||
stream, ok := streams[streamLabels] | |||
allLbls, err := syntax.ParseLabels(streamLabels) |
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.
the logic added here is to extract the stream labels from the additional labels via parsing and structured metadata. this likely needs a test
need this now that logfmt isn't strict
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.
Nice, LGTM!
This PR must be merged before a backport PR will be created. |
2 similar comments
This PR must be merged before a backport PR will be created. |
This PR must be merged before a backport PR will be created. |
Co-authored-by: Sven Grossmann <[email protected]> (cherry picked from commit 1b3ba53)
What this PR does / why we need it:
Explore logs passes multiple parsers in the query to
detected_fields
, which has resulted in a whole bunch of unknown edge cases. This fixes:_extracted
is correctly applied when the incoming stream labels already have extracted fields because of the formatters included in the queryParsed
values on the entry being parsed if not additional parsed values are foundlogfmt
andjson
parsers to already parsed fieldsWhich issue(s) this PR fixes:
Fixes #14063
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PRdeprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR