graphql-datasource icon indicating copy to clipboard operation
graphql-datasource copied to clipboard

Query Option "Relative time" and "Time shift" not working

Open PhilippSchultze opened this issue 2 years ago • 2 comments

Describe the bug I want to show data from yesterday in a stats panel. If I use "relative time" or "time shift" option, both are ignored. It doesn't matter what I try to insert in the two fields

Expected behavior The options have an impact on the GraphQL query.

Screenshots image

PhilippSchultze avatar Mar 25 '22 15:03 PhilippSchultze

Apparently this is a feature/limitation of the $__from and $__to variables, they are globally scoped to the dashboard (see https://github.com/grafana/grafana/issues/38954). There are still the older datasource-specific $timeFrom and $timeTo variables that we deprecated, which should still work and may include the panel adjustments, but they are epoch timestamps only (see #10, which was closed with the recommendation to use the global variables).

So we'll need to look again at providing a datasource-specific macro for configurable timestamps.

retzkek avatar Mar 28 '22 16:03 retzkek

Thank you for your answer. In addition, I have tested the behavior with the PostgreSQL data source. The PostgreSQL plugin uses a time filter macro in the where part of the query: image

The dashboard uses the global time scope, but you can add a time shift to a single panel to show an other time. With this feature, you can for example show the data from today (selected with the global dashboard range) in addition with a panel in the dashboard, that shows the data from yesterday.

I would really appreciate this feature for the GraphQL data source plugin.

PhilippSchultze avatar Mar 29 '22 07:03 PhilippSchultze