Why do you need to be so precise? Just go from midnight to midnight for your timestamps. You will still get all the values for the day.
And it is not clear why you need to loop through all the days. You want 30 charts? What do you want to do with these charts?
This seems way over complicated and I’m not sure I see what you are trying to do or why you just don’y browse the data in Grafana to get the information you are after.
The following posts might provide some help.
Assuming you are after a separate image per day, it seems to me you just need to get the first day of the month, let’s start at midnight, (now.withTimeAtStartOfDay.withDayOfMonth(1)) and the current day of the month (now.dayOfMonth) and then loop through that number of days to generate the time information you need to pass to Grafana (you’ll need to look at the grafana docs).
var day = now.dayOfMonth
while(day > 0){
// generate timestamps needed by grafana based on now.withTimeAtStartOfDay.minusDays(day)
// generate chart
day = day - 1
}
Persistence is not needed here. Keep it simple.