From bf6cbb762c37c30a088efb370dd8351c30a6945b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 26 Jul 2019 22:07:29 +0300 Subject: [PATCH] app/vminsert: improve error messages for Influx, OpenTSDB and Graphite parsing Include in the error message the line which failed to parse. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/127 --- app/vminsert/graphite/parser.go | 2 ++ app/vminsert/influx/parser.go | 2 ++ app/vminsert/opentsdb/parser.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/app/vminsert/graphite/parser.go b/app/vminsert/graphite/parser.go index 77bad97c52..a33ac2fa4e 100644 --- a/app/vminsert/graphite/parser.go +++ b/app/vminsert/graphite/parser.go @@ -114,6 +114,7 @@ func unmarshalRows(dst []Row, s string, tagsPool []Tag) ([]Row, []Tag, error) { var err error tagsPool, err = r.unmarshal(s, tagsPool) if err != nil { + err = fmt.Errorf("cannot unmarshal Graphite line %q: %s", s, err) return dst, tagsPool, err } return dst, tagsPool, nil @@ -121,6 +122,7 @@ func unmarshalRows(dst []Row, s string, tagsPool []Tag) ([]Row, []Tag, error) { var err error tagsPool, err = r.unmarshal(s[:n], tagsPool) if err != nil { + err = fmt.Errorf("cannot unmarshal Graphite line %q: %s", s[:n], err) return dst, tagsPool, err } s = s[n+1:] diff --git a/app/vminsert/influx/parser.go b/app/vminsert/influx/parser.go index 890bf5b81e..a8568726cb 100644 --- a/app/vminsert/influx/parser.go +++ b/app/vminsert/influx/parser.go @@ -196,6 +196,7 @@ func unmarshalRows(dst []Row, s string, tagsPool []Tag, fieldsPool []Field) ([]R var err error tagsPool, fieldsPool, err = r.unmarshal(s, tagsPool, fieldsPool) if err != nil { + err = fmt.Errorf("cannot unmarshal Influx line %q: %s", s, err) return dst, tagsPool, fieldsPool, err } return dst, tagsPool, fieldsPool, nil @@ -203,6 +204,7 @@ func unmarshalRows(dst []Row, s string, tagsPool []Tag, fieldsPool []Field) ([]R var err error tagsPool, fieldsPool, err = r.unmarshal(s[:n], tagsPool, fieldsPool) if err != nil { + err = fmt.Errorf("cannot unmarshal Influx line %q: %s", s[:n], err) return dst, tagsPool, fieldsPool, err } s = s[n+1:] diff --git a/app/vminsert/opentsdb/parser.go b/app/vminsert/opentsdb/parser.go index 31d2b172df..e68b908174 100644 --- a/app/vminsert/opentsdb/parser.go +++ b/app/vminsert/opentsdb/parser.go @@ -111,6 +111,7 @@ func unmarshalRows(dst []Row, s string, tagsPool []Tag) ([]Row, []Tag, error) { var err error tagsPool, err = r.unmarshal(s, tagsPool) if err != nil { + err = fmt.Errorf("cannot unmarshal OpenTSDB line %q: %s", s, err) return dst, tagsPool, err } return dst, tagsPool, nil @@ -118,6 +119,7 @@ func unmarshalRows(dst []Row, s string, tagsPool []Tag) ([]Row, []Tag, error) { var err error tagsPool, err = r.unmarshal(s[:n], tagsPool) if err != nil { + err = fmt.Errorf("cannot unmarshal OpenTSDB line %q: %s", s[:n], err) return dst, tagsPool, err } s = s[n+1:]