diff --git a/lib/protoparser/graphite/parser.go b/lib/protoparser/graphite/parser.go index 1ba53b474..e679f9524 100644 --- a/lib/protoparser/graphite/parser.go +++ b/lib/protoparser/graphite/parser.go @@ -98,12 +98,12 @@ func (r *Row) unmarshal(s string, tagsPool []Tag) ([]Tag, error) { if err != nil { return tagsPool, fmt.Errorf("cannot unmarshal value from %q: %w", tail[:n], err) } - ts, err := fastfloat.ParseInt64(tail[n+1:]) + ts, err := fastfloat.Parse(tail[n+1:]) if err != nil { return tagsPool, fmt.Errorf("cannot unmarshal timestamp from %q: %w", tail[n+1:], err) } r.Value = v - r.Timestamp = ts + r.Timestamp = int64(ts) return tagsPool, nil } diff --git a/lib/protoparser/graphite/parser_test.go b/lib/protoparser/graphite/parser_test.go index 86510f213..6217adfc3 100644 --- a/lib/protoparser/graphite/parser_test.go +++ b/lib/protoparser/graphite/parser_test.go @@ -113,6 +113,16 @@ func TestRowsUnmarshalSuccess(t *testing.T) { }}, }) + // Floating-point timestamp + // See https://github.com/graphite-project/carbon/blob/b0ba62a62d40a37950fed47a8f6ae6d0f02e6af5/lib/carbon/protocols.py#L197 + f("aaa 1123 4294.943", &Rows{ + Rows: []Row{{ + Metric: "aaa", + Value: 1123, + Timestamp: 4294, + }}, + }) + // Tags f("foo;bar=baz 1 2", &Rows{ Rows: []Row{{