VictoriaMetrics / victoriametrics-datasource

Grafana datasource for VictoriaMetrics
GNU Affero General Public License v3.0
111 stars 14 forks source link

Set the value of start and end parameters of a VictoriaMetrics Query in a Grafana Panel #200

Open TheMuppet opened 2 months ago

TheMuppet commented 2 months ago

I am trying to configure a Grafana panel to query data from VictoriaMetrics for a specific time range that is independent of the overall dashboard time range.

The use case is that various devices are assigned to a job for a certain amount of time (e.g. Job 1: 10:00 AM - 11:00 AM, Job 1: 11:00 AM - 12:00 AM). The aim is to select a Job via a Grafana variable and then retrieve the data for the runtime of the job. The start and end time of a Job are stored in Grafana Variables and retrieved from another Database. In other databases the start end time is defined in the query, so as a user I can edit them myself. As I know in VictoriaMetrics they are passed via the URL parameters start and end and are always set to the Dashboard time range?. Is there a way to edit these parameters to set it to a value of a Grafana Variable? It would be nice if I had the possibility to set the start/end values like the step value in a panel.

alekiv commented 2 months ago

This would be a very useful feature. Being able to set custom time ranges for individual panels, separate from the dashboard's time range, is essential for visualizing data for specific jobs with precise time frames. This limitation is a significant blocker for migrating from InfluxDB, where these time ranges can be easily defined in queries. It's frustrating that VictoriaMetrics doesn't support this yet, and adding this functionality would be a great improvement.

dg-nvm commented 2 months ago

Have you tried @ modifier? This will modify the date when query is executed to the pointed timestamp

TheMuppet commented 1 month ago

Yes, I tried the @ modifier. As I know, VictoriaMetrics range queries work by running an instant query at each step of the given time range. An @ in an instant query gives me the time at a given timestamp. This causes range queries with @ to always return the same value. There may be a way around this that I am not aware of.

image

csimmend commented 1 week ago

Indeed, retrieving time ranges from a separate database and using these timestamps for data retrieval appears as rather mandatory. If possible, I would appreciate a solution to this problem or at least some workaround. Thanks !