Add newline to influx line-protocol if not present

closes #2297
This commit is contained in:
Cameron Sparr
2017-01-23 13:50:52 -08:00
parent a852e8106e
commit 4d72cd7c9f
4 changed files with 22 additions and 8 deletions

View File

@@ -16,6 +16,9 @@ type InfluxParser struct {
}
func (p *InfluxParser) ParseWithDefaultTime(buf []byte, t time.Time) ([]telegraf.Metric, error) {
if !bytes.HasSuffix(buf, []byte("\n")) {
buf = append(buf, '\n')
}
// parse even if the buffer begins with a newline
buf = bytes.TrimPrefix(buf, []byte("\n"))
metrics, err := metric.ParseWithDefaultTime(buf, t)