Query Time Range with MySQL using Grafana Variables

Hi all,

I am working with Grafana v7.5. I have a MySQL Datasource and I want Grafana to only request the data that are in a certain time window which is selected by the Time Filter available on every Dashboard.

This means when I want to look at the last 6 months, the query should request exactly the last 6 months of the from the MySQL Data Source.

I am using the BigQuery Plugin which is connected to the Google Cloud. My data are analytics events generated by firebase.

I tried to use the internal Grafana Variables like this in the where clause which lead to the errors below :

$__timeFilter(event_timestamp) [1]
[1]: No matching signature for Operator BETWEEN for argument types INT64, TIMESTAMP, TIMESTAMP. Supported Signature: (ANY) BETWEEN (ANY) AND (ANY)

event_timestamp > $__timeFrom() AND event_timestamp < $__timeTo() [2] i
[2]: Invalid Query: Syntax Error: Illegal inout character “$”

Especially the Error in [2] is really confusing to me because it is not appearing for the approach [1].

Could you please share your thoughts on that issue if you have any?
Really looking forward to your help, thanks in advance :slight_smile:

Any ideas on how to properly use the Macros in SQL?

This topic was automatically closed after 365 days. New replies are no longer allowed.