I need a sanity check

I am new to Grafana and hope I’ve put this in the right category.

I am implementing Grafana to display data from a solar power system. It does a great job with all the time series data I collect but I have a few small problems.

Before using Grafana I displayed my system status and statistics in a small web page that showed min/max/current for many values. However it also displays a few calculated values.

The important calculation is to analyze net charge rate (positive or negative) and then predict the time it will take to fully charge the batteries or, if discharging, when the generator will start to maintain a minimum state of charge. This number is not a time series type of value, it is always a “current” value or two. I plan to enable a JSON datasource to provide the value.

A second, more time series type of calculation, is to display the most recent daybreak and nightfall time. This is calculated on the time of day when my solar battery charger wakes up because light is falling on the panels and and the time when it decides it’s dark again. These times are not the same as astronomy based sunrise and sunset. The database time series records includes the charger status value so this is derived from time data but gets complicated when the sun is still shining as nightfall is yesterdays value not today’s. Not impossible using a SQL query but very complex. A few lines of procedural code is simpler.

My question is:(are)
Is this the type of data that is consistent with the proper use of Grafana or am I trying to jam a square peg into a round hole?
Is the JSON data source the right tool.for the job?
Am I crazy to consider it?
Or is there another way to do it?

I care more about resolving the time prediction problem than the daybreak problem.

I’ve solved this problem. I discovered an Ajax panel plugin that does what I need. I’m adding a panel with the values I want to display.

1 Like

I wouldn’t think you’re crazy to use Grafana for visualizing this sort of data - as you found out, it’s certainly flexible enough to cater to your the use case you describe, especially with the variety of different panel options. We use Grafana to visualize data from renewable energy systems, and for the most part it works very well. Actually most limitations we encounter stem from the database/query language (InfluxDB in our case), rather than from Grafana itself. But as you suggest, a JSON datasource can pretty much always be set up as a workaround for that.

I’m curious as to why you opted for the Ajax panel, when it sounds like something like the singlestat panel would also have also allowed you to display the custom values you mentioned? Maybe you needed something more customizable.

Also worth checking out annotations as a way to overlay event data on your timeseries charts. Something else that may be of interest is regions though that sounds a bit less relevant for your use case.

Thanks for your feedback. I still at the implementation stage and I have some time before I NEED this implemented. I’m looking at the ajax panel plugin as it allows me to present several pieces of data in the same place. Singlestat, by its definition, is single stat only. But i’m not done yet. I’m getting some readability issues with my initial test of the Ajax panel and I may move on rather than improve my skills dealing with style (css) issues.
Your comment on annotations has me reading about that feature. Have not looked at regions - yet but I will.

Got you! Good luck, and keep us posted.

To follow up quickly, singlestat is indeed limited by, well, being a single stat. Though depending on your requirements - unless you need to display a reasonably large number of metrics - you may be able to size and arrange the panels in a way that still makes sense. Might be worth checking out https://play.grafana.org/d/000000003/big-dashboard?orgId=1 and some of the other demo dashboards for inspiration.

Of course if it’s easier to get what you want with Ajax/custom HTML/CSS that may be the right way forward - especially if you want to do calculations in the front-end (?) - and especially if you need something quite specific. Though in general I’ve found that with Grafana you get the most bang for your buck by using off-the-shelf functionality as much as possible.

Which also brings me to your question about whether it makes sense to use the custom JSON datasource for supplying calculated values. It’s certainly a legitimate approach. It probably depends on whether you’re happy to implement and maintain it as a (potentially) one-off bit of functionality. What we’ve mostly ended up doing in situations where we need calculated values, is to carry out the calculations continuously in our back-end (based on incoming data), and store the results in the database. Then all Grafana needs to do is pull the respective calculated values from the DB. I wouldn’t argue that’s necessarily a better way of doing it, but it does the job decently well in our case, and makes the dashboard building quite straightforward. It would probably depend on your actual data pipeline and database setup.

Thanks for your support and wise suggestions.
I am reappraising some of my data approaches. I have been following the dogma of only storing factual data in the database and to leave any calculated results for the time of display. This prevents any “Darn! I didn’t think of that” moments when trying to display data. It’s always harder to go back and recompute history.

I’ve read the section on annotations using query and, hopefully. I can add an events table in my database (used for annotations) to record change of state events such as nightfall, sunrise, generator start/stop and others. I’m not too concerned about leaving something out as I also log, in JSON, the raw data from my system so, if needed, I could rebuild the entire database to add or remove items.

I’ve got about 3 months before I need to commit to my system so I have time to experiment. :wink:

I’ve followed your advice.

I added state changes as events in a new table and used an annotation query to generate annotations on my graphs. State changes are events like daybreak, nightfall, generator start and stop as well as states of charge and battery condition. and adding new ones in the future should be easy.
Works great, thanks.