InfluxDB Line protocol special character escaping


#1

Firstly - Sorry if this isn’t a relevant topic on the grafana forums!

Secondly, it’s quick a quick one to someone who knows…

I’m currently sending a string of text to influxdb that i remove the fullstops from. Eg,

1.14 -> “114”

Is InfluxDB capable of storing 1.14 or do the fullstops need to be removed and if it is doable… How do i escape them?


#2

Use field type float and then you will be able to store “1.14” as a float (don’t use text type to store numeric value).


#3

Hi there. Thanks for this… It looks like influxdb defauts to “Float” when dealing with numbers though so i should be using float…

I have a bit of powershell that basically does this (the variable is created dynamically in the script but for ease of reading i’ve just statically written it out.)

$zabbixversion="3.2.7"
Write-Host zabbixagent version=$zabbixversion

It creates the output:

zabbixagent version=3.2.7

This gets sent to influxdb but wont display… Should i be forcing the data type “float” at some point in the output? the documentation simply gave this example:

Floats - by default, InfluxDB assumes all numerical field values are floats.
Store the field value 82 as a float:

weather,location=us-midwest temperature=82 1465839830100400200


#4

Just looked at how influxdb is storing it and it seems to be stored as a float so whats going wrong? Does it have anything to do with there being multiple decimal points? eg. “3.2.7”


#5

Does anyone have any ideas? I’m at a loss…


#6

The problem i see is that there are multiple decimal points… should this be treated as STRING data type and should the decimals be escaped to pass them into influxdb?

As a float:

3.27 (works)
3.2.7 (dosn’t work)


#7

3.2.7 is not a valid float value - https://www.techopedia.com/definition/23980/float:

Float is a term is used in various programming languages to define a variable with a fractional value. Numbers created using a float variable declaration will have digits on both sides of a decimal point. This is in contrast to the integer data type, which houses an integer or whole number.


#8

Yup - Thanks for the clarification.

So what data type would i use to proceed to store the value: 3.2.7

Text with special characters?


#9

I’m using quoted strings (like “3.2.7”) for non-numeric tag values. If needed, the " character itself is escaped by \ character (and double the \ for a backslash itself).
The key fields don’t get the " because they are strings anyway. A space or comma in a key value can be escaped with \ again.


#10

Thanks for this! So you send it as a quoted string as oposed to float/text in influxdb? Do you have to define the datatype specifically as a quoted string or do the presence of the speech marks around the key value dictate that? Can you confirm whether you have received any key value’s that have double fullstops in them? (like 3.2.7) The reason i ask is that if i send a key value with 1 full stop it shows as a float with no need to escape anything and will display fine. However 2 full stops in the key value breaks it no matter what i try… I’ll try posting it to influx with speech marks and see what happens.