-
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
Drop stage with multiple sources results in config unmarshall error #10095
Comments
Any progress? The same error with Promtail (2.8.4) . |
The problem appears to be a type conversion error between the YAML configuration and the objects in code. |
…10848) **What this PR does / why we need it**: This PR fixes YAML parsing of the `source` field in the drop stage when said field is a list of strings. Because this list is not being recognized in the code as a list of strings, but rather as a list of generic `interface{}` elements, it fails a type check and throws an error. In order to fix this, an `interface{}` list is manually converted to a `string` list. The problem was already reproducible with existing tests, but the test YAML mistakenly referred to the field as `sources` rather than `source`. **Which issue(s) this PR fixes**: Fixes #10095 **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 - [ ] 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) --------- Co-authored-by: Michel Hollands <42814411+MichelHollands@users.noreply.github.com>
I can reproduce this bug on v2.9.2 (released on October 16th) while the patch was merged on Octobre 12th. |
I have the same problem in v2.9.3. Is there any update on this issue? |
It looks like the fix will be released as part of v2.9.5. In the meantime, I am using this workaround that might be useful for others: # Workaround for https://github.com/grafana/loki/issues/10095
# can be removed once we update to 2.9.5
- template:
source: merged_drop_string
template: "{{.uri}};{{.remote_user}};{{.remote_addr}}"
- drop:
source: merged_drop_string
expression: ... Just list the extracted values in a template block with your preferred separator instead of on the |
…rafana#10848) **What this PR does / why we need it**: This PR fixes YAML parsing of the `source` field in the drop stage when said field is a list of strings. Because this list is not being recognized in the code as a list of strings, but rather as a list of generic `interface{}` elements, it fails a type check and throws an error. In order to fix this, an `interface{}` list is manually converted to a `string` list. The problem was already reproducible with existing tests, but the test YAML mistakenly referred to the field as `sources` rather than `source`. **Which issue(s) this PR fixes**: Fixes grafana#10095 **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 - [ ] 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](grafana@d10549e) --------- Co-authored-by: Michel Hollands <42814411+MichelHollands@users.noreply.github.com>
Describe the bug
Config drop stage with list of sources
To Reproduce
Steps to reproduce the behavior:
Expected behavior
We followed the drop stage with multiple sources link here
https://grafana.com/docs/loki/v2.8.x/clients/promtail/stages/drop/
And got the config unmarshall error, we can see the test for drop with multiple sources is not covered here
https://github.com/grafana/loki/blob/main/clients/pkg/logentry/stages/drop_test.go#L19
A possible reason could be due to this
https://medium.com/@kosiriki/accepting-both-string-and-array-for-single-yaml-key-in-golang-2e3d7143de8d
Environment:
Screenshots, Promtail config, or terminal output
If applicable, add any output to help explain your problem.
This is the snippet of the config
And this is the error we got:
The text was updated successfully, but these errors were encountered: