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.)
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:
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”
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?
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.
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.