- What Grafana version and what operating system are you using?
Grafana v11.6.1 (ae23ead4d9) via docker container and influxdb v1
What are you trying to achieve?
- Extract a distinct value from a measurement based on day and time. Specifically, the value from pge_hourly_elec_rate_per_kwh from the day before yesterday at 10AM, 3PM, and 6PM. A bonus would be if I could identify weekend vs weekday easily as I see them implementing different rates based on day of week in the future.
How are you trying to achieve it?
-
I have a script that runs once per day to scrape my utility’s website for my rates. The rates are from two days ago as there is a slight lag in the data availability. So, a script that runs on 5/10 populates the utility rates for 24 individual values from 2025-05-08 00:00:00 to 2025-05-08 23:00:00.
-
Using the
Day before yesterday
timeinterval on the explore view I am able to view a day’s worth of rates.
What happened?
- I can’t figure out the correct syntax to reference the specific three time slots of data.
What did you expect to happen?
- Have 3 queries that result in the three distinct values for the three different times as relative time.
- Bonus if there is a way to split this into six values for weekend vs weekday.
Can you copy/paste the configuration(s) that you are having problems with?
- In Grafana:
SELECT distinct("value") FROM "Utility Rate $/kWh" WHERE ("entity_id"::tag = 'pge_hourly_elec_rate_per_kwh') AND now-2d/d GROUP BY time($__interval) fill(null)
- In Influx:
SELECT distinct("value") FROM "Utility Rate $/kWh" WHERE ("entity_id"::tag = 'pge_hourly_elec_rate_per_kwh') AND time >= 1746687600000ms GROUP BY time(1h)