mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
app/vminsert/influx: skip comments starting with #
in influx line protocol
This commit is contained in:
parent
697de90893
commit
f1f8fce4f7
2 changed files with 23 additions and 0 deletions
|
@ -182,6 +182,15 @@ func unmarshalRows(dst []Row, s string, tagsPool []Tag, fieldsPool []Field) ([]R
|
||||||
s = s[1:]
|
s = s[1:]
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if s[0] == '#' {
|
||||||
|
// Skip comment
|
||||||
|
if n > 0 {
|
||||||
|
s = s[n+1:]
|
||||||
|
} else {
|
||||||
|
s = s[len(s):]
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
if cap(dst) > len(dst) {
|
if cap(dst) > len(dst) {
|
||||||
dst = dst[:len(dst)+1]
|
dst = dst[:len(dst)+1]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -147,6 +147,11 @@ func TestRowsUnmarshalSuccess(t *testing.T) {
|
||||||
f("", &Rows{})
|
f("", &Rows{})
|
||||||
f("\n\n", &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
|
// Minimal line without tags and timestamp
|
||||||
f("foo bar=123", &Rows{
|
f("foo bar=123", &Rows{
|
||||||
Rows: []Row{{
|
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{
|
f("foo bar=123\n", &Rows{
|
||||||
Rows: []Row{{
|
Rows: []Row{{
|
||||||
Measurement: "foo",
|
Measurement: "foo",
|
||||||
|
|
Loading…
Reference in a new issue