I'm using the new InfluxDB2 and the flux query language to retrieve docker stats from my bucket. I want to display the uptime of a container in a single stat widget.
For this I use the following query:
from(bucket: "docker")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "docker_container_status")
|> filter(fn: (r) => r._field == "uptime_ns")
|> filter(fn: (r) => r.container_name == "some_container")
|> window(period: v.windowPeriod)
|> last()
Unfortunately, the container wasn't online in the past time range, therefore I get a "No results" displayed. Instead I would like to display a 0 value or a text like "Not online".
How can I achieve this?