How to Disable Global Time Picker for Specific OpenSearch Queries in Grafana?

I’m using Grafana with OpenSearch as a data source. I have two queries targeting different indices:

  1. Query A: Filters data based on a date field (finaltime) and respects the global time picker.
  2. Query B: Targets a different index where the relevant field (lasttime) is a keyword. However, the global time picker still affects this query, even though lasttime is not a date.

Here’s what I’ve tried:

  • Setting lasttime as a keyword.
  • Using queries like * and lasttime:2023*.
  • Confirmed that the lasttime field exists and the index contains data (~2M records).

Despite this, Query B returns “No data” when the time picker is active. How can I configure Grafana to:

  1. Apply the global time picker only to Query A.
  2. Ignore the global time picker for Query B.

Welcome @zubaiir to the Grafana forum.

I have never used Opensearch or the associated query language, but can you specify timestamps directly, i.e. use the date formatting specific to OpenSearch in your query.
For example, WHERE timestamp BETWEEN '2024-12-10T00:00:00.000Z' AND '2024-12-12T00:00:00.000Z' will show data for December 10th and 11th, 2024, regardless of the Grafana time picker.

Also (and this is just a guess), but what happens if you use the @ symbol and write Query B as @lasttime ?

Another guess…you could potentially use a Grafana variable to achieve something similar.

  • Define a variable named lasttime in your Grafana dashboard.
  • Set the variable’s value to a relative time string (e.g., now-1h).
  • In your OpenSearch query, use the variable like this: WHERE timestamp > @$lasttime.

This approach allows you to change the time range dynamically by updating the variable value in the dashboard.

Thank you for the suggestions and for welcoming me to the Grafana forum! @grant2

1. Regarding specifying timestamps directly in the query:

  • I’ve tested queries with specific date ranges like lasttime:["2023-01-01T00:00:00" TO "2023-12-31T23:59:59"], and they work as expected in OpenSearch Dev Tools.
  • However, the issue arises when I want the query in Grafana to ignore the global time picker completely. Even with this kind of direct date range query, Grafana seems to still apply the global time picker, resulting in “No data” for Query B. My goal is for Query B to fetch all data regardless of the time picker, while Query A respects it.
  1. Regarding using the @ symbol for the field:
  • Unfortunately, OpenSearch queries don’t support using the @ symbol in this way. The field lasttime is mapped as a keyword, so it doesn’t support range queries or wildcard filters like 2023*. I need a solution that ensures this query fetches all data without interference from the time picker.
  1. Regarding using a Grafana variable:
  • Using a variable like $lasttime could work, but I want to completely decouple Query B from the time picker instead of relying on dashboard-level variable configurations. For example, Query B should retrieve all records from the index without any restrictions, while Query A follows the global time picker.
  1. Goal of Joining Queries:
  • The main aim is to join Query A (filtered by the time picker) with Query B. Both queries share a common id field, but their firsttime (Query A) and lasttime (Query B) fields are different.
  • For example, if I select “Last month” from the time picker, I expect Query A to show relevant data for that time range and, after the join, display corresponding Query B data based on the shared id field, regardless of the global time picker.