grafana / google-bigquery-datasource

Google BigQuery Datasource Plugin for Grafana.
Apache License 2.0
26 stars 13 forks source link

Annotations with Bigquery Plugin not rendering properly on panels #238

Closed mazad01 closed 5 months ago

mazad01 commented 8 months ago

Background info: -Grafana 9.2.5 OSS -Bigquery Plugin version: 1.2.2

Issue: We are creating a dashboard annotation to dynamically generate panel annotations and seeing a visual inconsistency with the annotation range. From the picture, you'll see the annotation carrot all the way on the left with the correct date (2/7/24) in the metadata. But it's not showing in the 2/7 area in the y axis. The graph time range is also filtered appropriately, but it just seems that the carrot is stuck on the left. Any idea?

image

zoltanbedi commented 8 months ago

Hey @mazad01,

Can you please provide a dashboard or a way for us to reproduce this?

mazad01 commented 8 months ago

I can provide you with some steps for reproducibility:

Create some fake data in BQ:

For grafana config

  1. create a new datasource using BQ plugin using the GCP project that the fake dataset is in. Then create a new dashboard.

  2. In the new dashboard, create a new timeseries panel. Datasource should be the newly created BQ data source. Query should be something like SELECT CAST(date as STRING) as date, data from <some gcp project>.test_dataset.fake_data a. Add a Convert field type transform with options Field='date', as=Time, Input format=YYYYMMDD

  3. Open dashboard settings and go to Annotations

  4. Click on New Query

  5. Annotation query config: a. Set name to annotation b. Set datasource to BQ. c. Set query to SELECT CAST(date as STRING) as date, tag from <some gcp project>.test_dataset.test_table d. Ensure Enabled is checked. e. Run the query and ensure the event fields are set like so: image

  6. Now if you go back to the dashboard and set the time range to roughly 2023-12-01 > 2024-01-31 you should see this: image

gabor commented 5 months ago

hi @mazad01 thank you for the test-data.. i tested this, and i could not even see the annotations anywhere. in my case what fixed the problem is making the annotation-timestamps "real" bigquery timestamps. i modified your query:

and it suddenly started to work.

could you try the same?

(in the meantime i will look into why the string-based timestamps do not work correctly in annotations)

gabor commented 5 months ago

(created a separate github-issue for the annotation-string-dates-problem: https://github.com/grafana/grafana/issues/88135)

gabor commented 5 months ago

as we got no feedback here, we'll close the issue. if you think the issue is not fixed yet, just reply and we can reopen the issue. thanks!