diff --git a/app/vminsert/influx/parser.go b/app/vminsert/influx/parser.go index 6e5066bcb1..ba4a0a4383 100644 --- a/app/vminsert/influx/parser.go +++ b/app/vminsert/influx/parser.go @@ -182,6 +182,15 @@ func unmarshalRows(dst []Row, s string, tagsPool []Tag, fieldsPool []Field) ([]R s = s[1:] continue } + if s[0] == '#' { + // Skip comment + if n > 0 { + s = s[n+1:] + } else { + s = s[len(s):] + } + continue + } if cap(dst) > len(dst) { dst = dst[:len(dst)+1] } else { diff --git a/app/vminsert/influx/parser_test.go b/app/vminsert/influx/parser_test.go index cffdba4720..cbabe488be 100644 --- a/app/vminsert/influx/parser_test.go +++ b/app/vminsert/influx/parser_test.go @@ -147,6 +147,11 @@ func TestRowsUnmarshalSuccess(t *testing.T) { f("", &Rows{}) f("\n\n", &Rows{}) + // Comment + f("\n# foobar\n", &Rows{}) + f("#foobar baz", &Rows{}) + f("#foobar baz\n#sss", &Rows{}) + // Minimal line without tags and timestamp f("foo bar=123", &Rows{ Rows: []Row{{ @@ -157,6 +162,15 @@ func TestRowsUnmarshalSuccess(t *testing.T) { }}, }}, }) + f("# comment\nfoo bar=123\n#comment2 sdsf dsf", &Rows{ + Rows: []Row{{ + Measurement: "foo", + Fields: []Field{{ + Key: "bar", + Value: 123, + }}, + }}, + }) f("foo bar=123\n", &Rows{ Rows: []Row{{ Measurement: "foo",