InfluxDB Line protocol special character escaping

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?

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).

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.)

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

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”

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

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)

3.2.7 is not a valid float value -

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.

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?

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.

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.

My apologies for missing your follow-on question. I hope you’ve figured it out already. It’s more an InfluxDB issue than Grafana.
Yes, when you write the data to InfluxDB the double quotes indicate that the value is a string; and it will not try to parse it as a floating point number because it started with a digit and had a period in it.
Since the tags (as opposed to the fields) are always strings, you don’t use the double quotes there. So I write metrics like

cpu,user=ROB user=10.5,system=5.0,prio="low"

I find that most often the strings end up as tags because that’s how you slice and aggregate data. Filtering on fields is frowned upon.