Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Influx parser fails to parse but returns no error #2297

Closed
phemmer opened this issue Jan 21, 2017 · 3 comments · Fixed by #2310
Closed

Influx parser fails to parse but returns no error #2297

phemmer opened this issue Jan 21, 2017 · 3 comments · Fixed by #2310
Milestone

Comments

@phemmer
Copy link
Contributor

phemmer commented Jan 21, 2017

Bug report

package main

import (
	"fmt"

	"github.com/influxdata/telegraf/plugins/parsers"
)

func main() {
	p, _ := parsers.NewInfluxParser()
	m, err := p.Parse([]byte("test,foo=bar v=1i 123456789"))
	fmt.Printf("err=%v\n", err)
	fmt.Printf("m=%#v\n", m)
}

Expected behavior:

err=<nil>
m=[]telegraf.Metric{(*metric.metric)(0xc42009a480)}

Actual behavior:

err=<nil>
m=[]telegraf.Metric{}

Additional info:

It parses fine only if there is a trailing newline.

This is a regression. I noticed this while trying to update PR #2094. Code that was previously working is now failing. While I would argue that a trailing newline should not be required to parse, at the very least if it does not parse, it should return an error.

@sparrc
Copy link
Contributor

sparrc commented Jan 21, 2017

Can you confirm that InfluxDB accepts metrics without newlines (besides via the HTTP service, which in telegraf is also still adding a newline)

@phemmer
Copy link
Contributor Author

phemmer commented Jan 21, 2017

Not sure what you mean by "besides via the HTTP service". Why wouldn't that be a valid case of InfluxDB not needing a newline?

But in the case of UDP, yes, it accepts points without newlines:

# echo -n 'test,foo=bar v=1i 123456789' | socat - udp-send:localhost:8089

# influx -database telegraf -execute 'select * from test'
name: test
----------
time		foo	v
123456789	bar	1

@sparrc
Copy link
Contributor

sparrc commented Jan 21, 2017

well, the problem really is that we haven't ever defined out line-protocol data format very well. A newline is supposed to be required but apparently we don't enforce that very consistently.

I'll try to get a fix in for that and cherry-pick it into 1.2

@sparrc sparrc added this to the 1.2.0 milestone Jan 21, 2017
sparrc added a commit that referenced this issue Jan 23, 2017
sparrc added a commit that referenced this issue Jan 23, 2017
sparrc added a commit that referenced this issue Jan 23, 2017
njwhite pushed a commit to njwhite/telegraf that referenced this issue Jan 31, 2017
maxunt pushed a commit that referenced this issue Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants