quickwit-oss / quickwit-datasource

Quickwit data source for Grafana
GNU Affero General Public License v3.0
41 stars 10 forks source link

Query variable sometimes shows 'None' #55

Closed maxnovawind closed 6 months ago

maxnovawind commented 7 months ago

Context:

It seems that variables are sometimes lost when refreshing (F5) a dashboard with predefined query variables.

This is my settings in grafana:

Screenshot 2024-02-02 at 02 37 32

By checking the browser inspector, it appears to be related to a call with _elastic/_msearch:

Screenshot 2024-02-02 at 02 17 37

{"size":0,"query":{"bool":{"filter":[{"range":{"":{"gte":"1706814729878","lte":"1706836329878"}}}]}},"aggs":{"1":{"terms":{"field":"attributes.environment","size":500,"order":{"_key":"asc"}}}}}

As we can see, the timestamp_nanos field is empty, causing a bad request when attempting to retrieve different possible values for this field.

Environment:

Grafana version: v10.1.2, v10.3.1

fmassot commented 7 months ago

thanks for the report @maxnovawind, we are going to investigate this issue.

ddelemeny commented 7 months ago

Thank you @maxnovawind, I could reproduce the issue.

There's a race condition between the async construction of a query builder aware of the timestamp field (fetched from index metadata) and the fetching of terms. On refresh, the terms query may be built before the timefield is set, leading to this error.

That's indeed a bug, it should happen only on refresh, you can work around it by navigating to another page.

@fmassot: this can be fixed with a small refactoring of how the datasource handles its querybuilder, PR on the way

fmassot commented 6 months ago

@maxnovawind I just published a 0.4.0 beta version.

maxnovawind commented 6 months ago

Thank you @fmassot @ddelemeny I will try the new version.