Displaying Dashboard Variable Values Relative to Time Range in Grafana

Hi,

I have been using Grafana along with Promtail and Loki to send logs from various dynamically generated files, represented by unique IDs. To simplify the process of analyzing the logs, I have created a Query-type variable relating to the ‘filename’ label automatically generated by Promtail which allows me to analyze the content of that file in the dashboard. However, I am facing a challenge in filtering the files based on the time range set in the dashboard.

When I select a specific time range, such as ‘last 5 minutes,’ I would like the variable to show only the file names generated within that time frame. This way, I won’t have to manually search through hundreds of entries to find the relevant file.

I have explored various options in Grafana, but I couldn’t find a straightforward solution for this particular scenario.

I would greatly appreciate any guidance or suggestions on how to achieve this functionality. Has anyone encountered a similar use case or found a workaround?

Thank you in advance.