mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/protoparser/graphite: properly parse Graphite line with whitespace after the timestamp
See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1865
This commit is contained in:
parent
ca9827fecc
commit
37a2bea072
3 changed files with 37 additions and 2 deletions
|
@ -27,6 +27,7 @@ sort: 15
|
||||||
* BUGFIX: [vmrestore](https://docs.victoriametrics.com/vmrestore.html): properly resume downloading for partially downloaded big files. Previously such files were re-downloaded from the beginning after the interrupt. Now only the remaining parts of the file are downloaded. This allows saving network bandwidth. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/487).
|
* BUGFIX: [vmrestore](https://docs.victoriametrics.com/vmrestore.html): properly resume downloading for partially downloaded big files. Previously such files were re-downloaded from the beginning after the interrupt. Now only the remaining parts of the file are downloaded. This allows saving network bandwidth. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/487).
|
||||||
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): do not store the last query across vmui page reloads. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1694).
|
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): do not store the last query across vmui page reloads. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1694).
|
||||||
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix `Cannot read properties of undefined` error at table view. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1797).
|
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix `Cannot read properties of undefined` error at table view. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1797).
|
||||||
|
* BUGFIX: properly parse Graphite plaintext lines with whitespace after the timestamp. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1865).
|
||||||
|
|
||||||
|
|
||||||
## [v1.69.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.69.0)
|
## [v1.69.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.69.0)
|
||||||
|
|
|
@ -114,15 +114,32 @@ func (r *Row) unmarshal(s string, tagsPool []Tag) ([]Tag, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return tagsPool, fmt.Errorf("cannot unmarshal value from %q: %w", tail[:n], err)
|
return tagsPool, fmt.Errorf("cannot unmarshal value from %q: %w", tail[:n], err)
|
||||||
}
|
}
|
||||||
ts, err := fastfloat.Parse(tail[n+1:])
|
tail = stripTailSpace(tail[n+1:])
|
||||||
|
ts, err := fastfloat.Parse(tail)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return tagsPool, fmt.Errorf("cannot unmarshal timestamp from %q: %w", tail[n+1:], err)
|
return tagsPool, fmt.Errorf("cannot unmarshal timestamp from %q: %w", tail, err)
|
||||||
}
|
}
|
||||||
r.Value = v
|
r.Value = v
|
||||||
r.Timestamp = int64(ts)
|
r.Timestamp = int64(ts)
|
||||||
return tagsPool, nil
|
return tagsPool, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stripTailSpace(s string) string {
|
||||||
|
n := len(s)
|
||||||
|
for {
|
||||||
|
n--
|
||||||
|
if n < 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
ch := s[n]
|
||||||
|
// graphite text line protocol may use white space or tab as separator
|
||||||
|
// See https://github.com/grobian/carbon-c-relay/commit/f3ffe6cc2b52b07d14acbda649ad3fd6babdd528
|
||||||
|
if ch != ' ' && ch != '\t' {
|
||||||
|
return s[:n+1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func unmarshalRows(dst []Row, s string, tagsPool []Tag) ([]Row, []Tag) {
|
func unmarshalRows(dst []Row, s string, tagsPool []Tag) ([]Row, []Tag) {
|
||||||
for len(s) > 0 {
|
for len(s) > 0 {
|
||||||
n := strings.IndexByte(s, '\n')
|
n := strings.IndexByte(s, '\n')
|
||||||
|
|
|
@ -288,6 +288,23 @@ func TestRowsUnmarshalSuccess(t *testing.T) {
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Whitespace after the timestamp
|
||||||
|
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1865
|
||||||
|
f("foo.baz 125 1789 \na 1.34 567\t ", &Rows{
|
||||||
|
Rows: []Row{
|
||||||
|
{
|
||||||
|
Metric: "foo.baz",
|
||||||
|
Value: 125,
|
||||||
|
Timestamp: 1789,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Metric: "a",
|
||||||
|
Value: 1.34,
|
||||||
|
Timestamp: 567,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_streamContext_Read(t *testing.T) {
|
func Test_streamContext_Read(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue