I have some cpu time measurements from the Telegraf cgroup plugin, which are given in number of nanoseconds of cpu time up to the measurement time. So to obtain a measure of percent cpu usage, I need to use the result of the difference() function divided by the result of elapsed(). In Influxql, I can do it like this:
select difference(cpuacct.usage)/elapsed(cpuacct.usage) * 100
from cgroup
where path = '/sys/fs/cgroup/cpu/some-cgroup-name'
order by time desc
limit 10
I’m trying to translate this query to Flux, but I don’t know the correct way to call the two transformation functions in a pipeline. I’m trying to use a join:
Is this the correct way to replicate the Influxql query? I’m multiplying by 100 and doing integer division because if I use the float() function, I get “Error: unknown server error: 500 Internal Server Error”.
So I guess I have two questions: Is this how the above Influxql query should be written in Flux, and how do I do the float conversion correctly?
Hello @andrenth,
Welcome! Thanks for your question. I believe you’re over complicating the query a little? Unless I’ve misunderstood you.
I think you want something like the following: