I have a dashboard where I am viewing the last 24 Hours of data from my Ethereum mining equipment. I am storing: ETH Price and Miner Balance. I have the following code to bring out the data, but I am multiplying by a constant of 1925.25 currently instead of using the actual ETH price.
I want to be able to use the LAST VALUE from the ETH Price as a constant there instead of always typing something in. Here is the current query:
from(bucket: "Mining")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "Miner")
|> filter(fn: (r) => r["_field"] == "balance")
|> filter(fn: (r) => r["tag1"] == "ethermine")
|> map(fn: (r) => ({r with _value: (float(v: r._value) / 1000000000000000000.0) * 1925.25 }))
|> aggregateWindow(every: 1h, fn: last)
|> derivative(unit: 1h, nonNegative: true, columns: ["_value"])
|> cumulativeSum(columns: ["_value"])
The field "price" is the ETH Price. I would like to be able to use the last value instead of the constant 1925.25. I can't seem to find any good examples of this out there :(
EDIT: This is what I tried to figure out how to do and use:
eth_value = from(bucket: "Mining")
|> range(start: -1m)
|> filter(fn: (r) => r["_measurement"] == "Miner")
|> filter(fn: (r) => r["tag1"] == "flexpool")
|> filter(fn: (r) => r["_field"] == "price")
|> last()
It works without using eth_value = - to get the value I want. But I can't seem to set it to a variable for usage later.