influxdata / influxdb

Scalable datastore for metrics, events, and real-time analytics
https://influxdata.com
Apache License 2.0
28.59k stars 3.54k forks source link

POST 'api/v2/write' on InfluxDB2 writes all columns as strings #18970

Closed masonhuemmer closed 3 years ago

masonhuemmer commented 4 years ago

Steps to reproduce: List the minimal actions needed to reproduce the behavior.

  1. Posting to api/v2/write with two integers as Tags and a string field

Expected behavior: InfluxDB to recognize the columns that are integers and setting the data type as an integer.

Actual behavior: InfluxDB writes all tags / fields to the measurement and sets the data type field as strings.

image

image

image

I tried writing the payload as a byte literal, but unfortunately, I was not able to post. I received the following error.

image

I tried to switch to the python-client, but I had an issue where I would receive a 204 response, but the measurement was not getting updated with my input. I have a ticket open currently for the issue.

https://github.com/influxdata/influxdb-client-python/issues/133

I tried to mimick the payload that was from the debug log in the screenshot below using the Influx-Client-Python, but again, kept getting an error.

image

As a work around, I am using the float() function, to convert the string column to a double.

Environment info:

russorat commented 4 years ago

@masonhuemmer thanks for the issue. in line protocol, tag values are always strings: https://docs.influxdata.com/influxdb/v1.8/concepts/glossary/#tag-value

If you need to perform calculations on them, you will need to convert them at query time.

russorat commented 3 years ago

Closing this for now since line protocol treats all tags as strings.