-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Converter Processor - Tag to string Field - chars escapes leads to invalid points #7406
Comments
We don't have a good way to dump the metrics that are rejected right now, but we could try sticking in some debug logging directly to the influxdb output. Maybe add this in as a starting point? diff --git a/plugins/outputs/influxdb/influxdb.go b/plugins/outputs/influxdb/influxdb.go
index 1c4af5bc..ac7713ea 100644
--- a/plugins/outputs/influxdb/influxdb.go
+++ b/plugins/outputs/influxdb/influxdb.go
@@ -6,6 +6,7 @@ import (
"fmt"
"math/rand"
"net/url"
+ "strings"
"time"
"github.com/influxdata/telegraf"
@@ -231,6 +232,22 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error {
}
i.Log.Errorf("When writing to [%s]: %v", client.URL(), err)
+
+ i.Log.Errorf("Begin Batch\n")
+ for _, m := range metrics {
+ var str strings.Builder
+
+ str.WriteString(fmt.Sprintf("Name(%q)", m.Name()))
+ for _, tag := range m.TagList() {
+ str.WriteString(fmt.Sprintf(" Tag(%q, %q)", tag.Key, tag.Value))
+ }
+ for _, field := range m.FieldList() {
+ str.WriteString(fmt.Sprintf(" Field(%q, %q)", field.Key, field.Value))
+ }
+ str.WriteString("\n")
+ i.Log.Error(str.String())
+ }
+ i.Log.Errorf("End Batch\n")
}
return errors.New("could not write any address") |
Today I've used the edited version of telegraf, here is an error I got.
For what I see, the only difference between that row of the text and the others is the last special char "\r" (carriage return), in all the other rows a new row is "\r\n" (carriage return+newline) I will keep debugging it tomorrow by manually writing data like those to influxdb (or in genre stings that end with escaped special chars). Does it make sense? some time ago I've found out that a string tag value cannot end with "" (backslash) even if it tests correctly escaped If you need something else to check this issue let me know. |
It looks like you are writing to the |
Yes, I'm using influxdb_listener as a gateway. (but I forgot to mention that). |
It looks like this is a mismatch between what values we allowed in the parser vs the serializer. Using |
Relevant telegraf.conf:
System info:
Steps to reproduce:
Probably it's not easy to reproduce this, in fact, I get 2-3 repèetitive errors every read, out of a total of hundreds of points, I think it's related to the string that gets converted from tag to field (the strings are the "statement_text" which might be very long.
Expected behavior:
The conversion from tag to field does not cause errors
Actual behavior:
Some of the converted points cause a parsing error
Additional info:
here I have a bunch of errors (all from the same SQL Server Instance), once the "statement_text" tag is converted to a field, it can become a multiline string.
As a tag, it's text is filled with "/t /s /n" (see issue #6976), but once converted to field those chars are decoded in their actual meaning.
Also note that converting this tag into a fieldis the proposed solution for issue #7037.
Case 1
The text which causes the error is part of the "statement_text", but the section reported in the error alone is valid (as a string field).
Case 2
This reguards the calculated field "statement_text_preview", which just takes the first 150 chars of the filed "statement_text".
As you can see below, there is something wrong with the escape in fact the line protocol should be structured in the following way
But instead I get the following (note that the whole "statement_text_preview" field is part of a bigger string
Case 3
this has been the easier to debug so far but is also the one that makes less sense to me.
here the log reports almost the whole point and not just a section of the string.
As you can see in the field set you get
Which just does not make sense, why is the double-quote that delimits the field value itself escaped?
Help Wanted:
I can provide more data and run additional tests, but I need some help.
So far I've tried to catch the broken points by:
how can I keep the broken points and save them somewhere else to have the full point structure?
Update
Since I've not found a way to intercept the broken points using telegraf, I've set up a parallel data collection in SQL Server (which replicates Telegraf's one), therefore I should be able to provide the source data soon.
The text was updated successfully, but these errors were encountered: