@E-J-D It looks like you’re using InfluxQL, which lacks to capability to run a query that returns data on specific days of the month. What version of InfluxDB are you using? If you’re using InfluxDB OSS 2.x or InfluxDB Cloud (TSM), Flux does support this type of query. If you’re using InfluxDB Cloud Serverless, you should be able to do this with SQL.
@scott Thanks for your answer. I am running InfluxDB OSS v2.7.3 locally in my homelab. Do you have any detailed information where to find examples or further details how to realize my idea?
@E-J-D You first need to create a new Flux-based InfluxDB data source in Grafana. Based on the screenshot of your InfluxQL query builder (Note: I don’t know the actual name of the bucket you’re querying), the Flux query would look something like this:
(There is no value for the 1st of July because the bucket I used doesn’t have that value)
Do you have any idea how to divide the value in the table with 1000? The meter tracks the values like this … [total_consumption: 23229908.4] but the real value is 23230.
@E-J-D In raw Flux, there are two ways you can to this that both involve the map() function. You can perform the division in your existing map() call like this:
Note: This examples casts the value to a float to preserve the fraction in the result. If left as an integer, the result truncates at the decimal point. If you don’t care about preserving the fraction, you can just do _value: r._value / 1000.
The other options is to perform the division at the end of your current query:
// ... the rest of your query
|> map(fn: (r) => ({ r with
1st: float(v: r["1st"]) / 1000.0,
15th: float(v: r["15th"]) / 1000.0,
}))
Both should give you the same result. I’d generally lean towards the first approach to avoid multiple map() calls.