-
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
Promtail: Add text encoding conversion to file targets #6395
Conversation
Signed-off-by: Jaromír Wysoglad <jwysogla@redhat.com>
./tools/diff_coverage.sh ../loki-main/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.3%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
./tools/diff_coverage.sh ../loki-main/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% |
./tools/diff_coverage.sh ../loki-main/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.5%
+ loki 0% |
func (t *tailer) convertToUTF8(text string) (string, error) { | ||
level.Debug(t.logger).Log("msg", "Converting log encoding", "from", t.encoding, "to", "UTF8") | ||
|
||
encoding, err := ianaindex.IANA.Encoding(t.encoding) |
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.
You should create this only once ?
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.
done. I tested with 2 tailers and checked the source code and looks like we won't have concurrency problems reusing the decoder or the IANAEncoding struct, but do you mind checking it too?
./tools/diff_coverage.sh ../loki-main/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% |
var text string | ||
if t.decoder != nil { | ||
var err error | ||
text, err = t.convertToUTF8(line.Text) |
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.
what's the value for text
when there is an error?
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 will be ""
(zero value string).
var err error | ||
text, err = t.convertToUTF8(line.Text) | ||
if err != nil { | ||
level.Error(t.logger).Log("msg", "failed to convert encoding", "error", err) |
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.
Since we now send the error message in the log line itself, and we have a metric when this happens, I think this should be debug level, it feels mostly just likely to be noise to me at error level.
./tools/diff_coverage.sh ../loki-main/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.3%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
Rephrase encoding error message. Co-authored-by: Ed Welch <ed@oqqer.com>
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
./tools/diff_coverage.sh ../loki-main/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.3%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
./tools/diff_coverage.sh ../loki-main/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% |
./tools/diff_coverage.sh ../loki-main/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% |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-6395-to-release-2.6.x origin/release-2.6.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x f17d3d768cb915b656af20a2ef7973efae335d51
# Push it to GitHub
git push --set-upstream origin backport-6395-to-release-2.6.x
git switch main
# Remove the local backport branch
git branch -D backport-6395-to-release-2.6.x Then, create a pull request where the |
Adds support for text encoding conversion for file targets. To use it, add `encoding: <encoding_name>` into the scrapeconfig. (cherry picked from commit f17d3d7)
…6395) (#6617) * Promtail: Add text encoding conversion to file targets (#6395) Adds support for text encoding conversion for file targets. To use it, add `encoding: <encoding_name>` into the scrapeconfig. (cherry picked from commit f17d3d7) * Cleanup vendor folder. * Update CHANGELOG.md Co-authored-by: Ed Welch <edward.welch@grafana.com>
Signed-off-by: Jaromír Wysoglad jwysogla@redhat.com
What this PR does / why we need it:
This PR adds support for text encoding conversion for file targets. To use this, just add encoding: <encoding_name> into the scrapeconfig like this:
The encoding name should be one of the names described by IANA here.
Which issue(s) this PR fixes:
Fixes #1119
Special notes for your reviewer:
This is a revival of PR 2604. The original author couldn't work on it and suggested we continue his work.
Checklist
CHANGELOG.md
.docs/sources/upgrading/_index.md