Changing Grafana Query Options (Max Data Points) based on a dashboard variable

Hi there!

One of the issues we are facing while working with OH+Grafana is the download time for large periods (>3 hours of data). One of the ways to facilitate this search is to decrease the “Max data points” in query options in Grafana “Data source” fields.

What I’m looking for is to allow the user to decide if he/she want low or high resolution data. For large data navigation the “low resolution” would be selected (let’s say 300 points) and for the “high definition” that it would be the largest possible (“auto”). To do this I need to add a $var in this field but Grafana doesn’t allow me to do that. Is there another method to do so using the OH plugin features?


Try the interval function: Interval Grafana Functions

This is for down-sampling. If the interval value is zero, the data is at full resolution.

You can use a variable with this for the value.

1 Like

Great! It works precisely as expected.

The use of OH interval() function works indeed but its performance is not like the same as manipulating Grafana’s query option (huge speed difference!). Is there a way to manipulate the “Max data points” as a var in Grafana? Sorry to come back at this point. Thanks

We use the interval parameter provided by Grafana, which is based on time range, to estimate the down-sampling resolution.

Currently, only the Interval function can be used to control down-sampling, but as you note, this is not the same as the resolution filter, which is very fast.

Let me think on some options here…


Right, indeed, the performance difference is significant enough to insist using Grafana “Mas data points” parameters directly. I have been searching in forums about this but I found more people asking about that rather than providing a clear answer. If interval() could mimic the same performance of grafana’s down-sampling would be great. Thanks for your effort here!

I put in an update to the openHistorian Grafana adapter which will allow you to manually override the interval setting value for more finite control over the native openHistorian intervaled data filtering:

Since there is only one query time range and hence one interval value for an entire dashboard, this will allow a per-query override as needed.

Once this gets merged and included in a new build of the openHistorian you can test this out to see if it improves your query performance for larger data windows.

Thanks Ritchie, looking forward to test it in the next OH plugin version. Is the one we might get next week?

I think next week is a reasonable time frame. Thanks!

1 Like