Getting time range from grafana

Ive been generating a dashboard using HTTP API. The dashboard by default uses a Prometheus datasource and will have some graph panel. Each graph panel has is based on a specific process’s metrics. However, over a large period a lot of metrics accumulate (for this panel it goes anywhere between 0-100, Ive had to make another panel which would hae even more).
Now we do keep a store of metadata on the time range in which each metric was alive. So instead of putting all queries as targets in the panel, I wanted to put only those queries that were alive in that time range.

Now I decided on doing some approaches. One of them was trying to find if I can poll the time range currently in the dashboard and update the dashboard if it is changed by the user. I haven’t found anything for this till now.

The other approach I tried was using React plugins. However I couldn’t find any tutorials on making react panels which would extend the graph panels.
All I want to do is make a query on available metrics when time range changes, then put those as the new metrics queries and then query to prometheus.

It would be great if you could help me with any one approach.
Thanks a lot for the help