diff --git a/app/vminsert/influx/parser.go b/app/vminsert/influx/parser.go index a2379e8ddc..890bf5b81e 100644 --- a/app/vminsert/influx/parser.go +++ b/app/vminsert/influx/parser.go @@ -293,8 +293,10 @@ func parseFieldValue(s string, hasQuotedFields bool) (float64, error) { if len(s) < 2 || s[len(s)-1] != '"' { return 0, fmt.Errorf("missing closing quote for quoted field value %s", s) } - // Quoted string is translated to empty value. - return 0, nil + // Try converting quoted string to number, since sometimes Influx agents + // send numbers as strings. + s = s[1 : len(s)-1] + return fastfloat.ParseBestEffort(s), nil } ch := s[len(s)-1] if ch == 'i' { diff --git a/app/vminsert/influx/parser_test.go b/app/vminsert/influx/parser_test.go index 1f0c0d5b19..3668fd70f7 100644 --- a/app/vminsert/influx/parser_test.go +++ b/app/vminsert/influx/parser_test.go @@ -241,17 +241,27 @@ func TestRowsUnmarshalSuccess(t *testing.T) { }) // Line with multiple tags, multiple fields and timestamp - f(`system,host=ip-172-16-10-144 uptime_format="3 days, 21:01" 1557761040000000000`, &Rows{ + f(`system,host=ip-172-16-10-144 uptime_format="3 days, 21:01",quoted_float="-1.23",quoted_int="123" 1557761040000000000`, &Rows{ Rows: []Row{{ Measurement: "system", Tags: []Tag{{ Key: "host", Value: "ip-172-16-10-144", }}, - Fields: []Field{{ - Key: "uptime_format", - Value: 0, - }}, + Fields: []Field{ + { + Key: "uptime_format", + Value: 0, + }, + { + Key: "quoted_float", + Value: -1.23, + }, + { + Key: "quoted_int", + Value: 123, + }, + }, Timestamp: 1557761040000000000, }}, })