Create "dummy" measurement in Influxdb which always returns a fixed row/value, regardless of timespec?

I am monitoring my electricity usage using a set of Wifi plugs with Tasmota wired to ioBroker which all gets stored in an InfluxDB database.
I also have several devices in my house of which I know the current consumption so I cannot justify purchasing a measurement device just to retrieve a value I already know.

To make my data analysis easier, I would like to create “dummy” measurements in InfluxDB which always return this value, regardless of timespec. I could of course create and fill these using a cronjob, and I’m already doing this for daily summaries, but I hesitate doing this for series which may be queried every ten seconds.

Is there a way to create fake measurements in InfluxDB which don’t really exist on disk, so don’t occupy any space, but simply return a constant value (or row with constant fields) whenever queried?

Hello @Jens,
What version of Influx are you using?
If you’re using 2.x and Flux you could use array.from()

This works, almost.
I can generate a dataset, but I cannot stack it on top of an already existing query result (in Grafana).
Granted, this may also be a Grafana question, but just in case: can I merge those queries?
Thank you!

Hello @Jens,
yes you can use:

depending on your needs :slight_smile:

Thank you!

I tried union(), but this wasn’t actually the problem.
The problem is I need to get my timestamps from another table to generate this table.

So I have an InfluxDB Flux query that retrieves data, and I want to use array.from() to generated fixed-value dummy data at the same timestamps of the real data. “fill()” doesnt help here because I don’t even have null values to fill.

Currently I have this:

value = 45
realdata = from(bucket: "home") |> range(...) |> filter(...) 
dummydata = /* a table with _time column from realdata + constant value of 45 for every timestamp */

I played with array.from() and generate() but couldn’t get anything to work.
Do you have an idea?

I got a little closer. Still not perfect (since the timestamps are hardcoded and not taken from the real data) but closer.

import "array"
import "interpolate"

    rows: [
        { _time: v.timeRangeStart, _value: 45.0 },
        { _time: v.timeRangeStop, _value: 45.0 },
|> interpolate.linear(every: 10s)
|> rename(columns: { _value: "my_column_name" })

This at least displays correctly in Grafana - but only because I know the real data is recorded every 10 seconds.
How about irregularly occuring timestamps?

Got it. It seems I need to use

 |> interpolate.linear(every: v.windowPeriod)

This automatically creates enough interpolation points for drawing a graph in Grafana.