How Do I Insert A Bash Variable Into A Value on InfluxDB?

191 views Asked by At

I am trying to do the following:

influx -database 'polls' -execute 'insert nodeMemory,NodeID=1,server=server01 values="$nodemem1"']

I get the following errors:

ERR: {"error":"unable to parse 'nodeMemory,NodeID=1,server=server01 values=`$nodemem1`': invalid boolean"}

How do I enter a variable as a value?

I expected it to enter the variable

1

There are 1 answers

8
richyen On

You have the query wrapped in single quotes ' instead of double quotes. Try double-quoting, and escape the inner double quotes:

... -execute "insert nodeMemory,NodeID=1,server=server01 values=\"$nodemem1\""

Depending on what influxdb expects, you might even be able to do away with the inner double quotes altogether:

... -execute "insert nodeMemory,NodeID=1,server=server01 values=$nodemem1"