Simple querying with the node.js module

I would like to use the node.js module for querying my telegraf data in influxdb. However I just can’t figure out how to do it, and don’t see any relevant documentation.

How does one write a query for influx.query( ... ) that would do something like

curl "http://my.influxdb.instance:8086/query?db=telegraf" --data-urlencode 'q=SELECT * FROM "cpu" WHERE "host"=$machine AND "cpu"=$cpu' --data-urlencode 'params={"machine":"${NAME}","cpu":"cpu-total"}'

This specific query returns data in my bash shell.

My guess is something like

        select * from cpu
        where host = ${name}
        and cpu = cpu-total

but this returns no data.

How do you pass in the param values, since you have ${name}? Also, cpu-total is not wrapped in quotes.

So, is this the actual code you’re using?

Let’s say name is a javascript variable defined in the scope of the call to influx.query. It isn’t the exact variable name, but I could just define it that way.

Which quotes? Single? Double? I love influxDB, but find the quote syntax extraordinarily confusing. (I typically have to try every permutation to find what works.)

After a bunch of trial-and-error, I seem to have this working:

`select * from cpu
where host = '${name}'
and cpu = 'cpu-total'
limit 10 `

I sure wish I understood how this is different than some other options though.