-
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
Metadata to labels result and filtering support #9702
Metadata to labels result and filtering support #9702
Conversation
0fa7568
to
21df77b
Compare
accd132
to
2826cee
Compare
@@ -23,8 +23,8 @@ type StreamPipeline interface { | |||
BaseLabels() LabelsResult | |||
// Process processes a log line and returns the transformed line and the labels. | |||
// The buffer returned for the log line can be reused on subsequent calls to Process and therefore must be copied. | |||
Process(ts int64, line []byte) (resultLine []byte, resultLabels LabelsResult, matches bool) |
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 was wondering if the nonIndexedLabels
argument should be variadic. I decided to make it variadic so we didn't have to refactor all the tests calling Process without any non-indexed labels. I also think it makes sense to be variadic since non-indexed labels are optional. Happy to change my mind tho. Wdyt?
…tor order for entries in the same timestamp is different
aac6753
to
1e6f49b
Compare
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 changes look good to me. I think it would be good to add some tests with non-indexed labels to TestNewLineSampleExtractor
and Test_labelSampleExtractor_Extract
si.currTs = ts | ||
si.currLine = line | ||
si.currMetadataLabels = metaLabels | ||
si.currMetadataLabels = nonIndexedLabels |
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.
please rename currMetadataLabels
to currNonIndexedLabels
. maybe in a separate PR
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 have a separate PR in the oven renaming all those "metadata" references.
@@ -80,22 +80,25 @@ type streamLineSampleExtractor struct { | |||
builder *LabelsBuilder | |||
} | |||
|
|||
func (l *streamLineSampleExtractor) Process(ts int64, line []byte) (float64, LabelsResult, bool) { | |||
func (l *streamLineSampleExtractor) Process(ts int64, line []byte, metadataLabels ...labels.Label) (float64, LabelsResult, bool) { | |||
l.builder.Reset() |
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.
it changes the logic. previously if stage is NoopStage we return l.LineExtractor(line), l.builder.GroupedLabels(), true
that uses values from the builder, otherwise we rest it and continue processing
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.
If I read the code correctly, it should not cause any problems because Reset just clears any buffered changes done on top of base labels.
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.
Reset just clears any buffered changes done on top of base labels.
Correct, that's my understanding as well
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
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 have left just one nit. Good to merge it once it is addressed.
Co-authored-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>
**What this PR does / why we need it**: In #9700, we support encoding and decoding metadata for each entry into the chunks. This PR adds support for returning metadata labels for matching entries in a query to the returned LabelResults. It also supports filtering out logs by metadata labels. **Special notes for your reviewer**: **Checklist** - [x] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [ ] Documentation added - [x] Tests updated - [ ] `CHANGELOG.md` updated - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/upgrading/_index.md` - [ ] For Helm chart changes bump the Helm chart version in `production/helm/loki/Chart.yaml` and update `production/helm/loki/CHANGELOG.md` and `production/helm/loki/README.md`. [Example PR](d10549e) --------- Co-authored-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com> (cherry picked from commit 1d04cd5)
#10082) **What this PR does / why we need it**: In #9702 we added support for returning non-indexed labels in the labels results. The problem is that non-indexed labels may overwrite stream labels if both are named the same way. This PR fixes this by adding an `_extracted` suffix if the non-indexed label is already present in the stream labels. **Special notes for your reviewer**: **Checklist** - [ ] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [ ] Documentation added - [x] Tests updated - [ ] `CHANGELOG.md` updated - [ ] If the change is worth mentioning in the release notes, add `add-to-release-notes` label - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/setup/upgrade/_index.md` - [ ] For Helm chart changes bump the Helm chart version in `production/helm/loki/Chart.yaml` and update `production/helm/loki/CHANGELOG.md` and `production/helm/loki/README.md`. [Example PR](d10549e)
What this PR does / why we need it:
In #9700, we support encoding and decoding metadata for each entry into the chunks. This PR adds support for returning metadata labels for matching entries in a query to the returned LabelResults. It also supports filtering out logs by metadata labels.
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)CHANGELOG.md
updateddocs/sources/upgrading/_index.md
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PR