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

Unable to write point or record to InfluxDB 1.8 #143

Closed
mneverov opened this issue Jun 29, 2020 · 2 comments
Closed

Unable to write point or record to InfluxDB 1.8 #143

mneverov opened this issue Jun 29, 2020 · 2 comments

Comments

@mneverov
Copy link

hi,
The client states compatibility with the InfluxDB 1.8+. Unfortunately, I was not able to write data. I've build an example repo to show the problem:

# run influx first
docker-compose up -d
# run the insert
go run main.go

I use syntax to build a point described in the compatibility section:

influxdb2.NewPoint("stat",
		map[string]string{"unit": "mem"},
		map[string]interface{}{"num": 23, "max": uint(42), "avg_ns": 111111111},
		time.Now())

which produces the line: stat,unit=mem avg_ns=111111111i,max=42u,num=23i 1593456269331238808
It contains i, u. As I understand the u was added in InfluxDB 2.0 line protocol.
I expect if a syntax is described in compatibility section it should work for the InfluxDB 1.8+.

In the example I can successfully write a record with line that does not contains i or u, but if I change the line to be:

fmt.Sprintf("stat,unit=temperature avg=%f,max=%di", 23.5, 45)

note the i for max, it also fails to write. Which is also unexpected since as I understand from the doc this should be allowed in InfluxDB 1.8.

And lastly, the error, unfortunately, is not very helpful. It does not contain any info except the status 400. Is there a parameter for InfluxDB to return verbose errors?

@vlastahajek
Copy link
Contributor

@max-neverov, thanks for using this client.
This client is primarily intended for using InfluxDB 2. InfluxDB 1.8 added V2 compatibility API to smoothly migrate from InfluxDB V1 to V2. But it has a few limitations.
If your intention is to use this client only with InfluxDB 1, I would recommend using the official InfluxDB 1 client

The missing support for unsigned integers in the V2 compatibility API in InfluxDB 1.8 is already reported in the InfluxDB issue #17781. As you mentioned, the easy workaround is casting unsigned integer to signed integer, which works ok.
If you've successfully written the max field with a float type, the schema in the database is fixed for this field and you cannot write the same field with a different type, which is probably the error returned from the server.

Unfortunately, also V2 compatibility API also doesn't support the InfluxDB 2 error format. Luckily, there is already merged PR #138 in the master, which adds the possibility to read also V1 errors.

@mneverov
Copy link
Author

@vlastahajek thanks for the detailed explanation. I misunderstood the doc.

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

No branches or pull requests

2 participants