grafana / timestream-datasource

Amazon Timestream in Grafana
https://grafana.com/grafana/plugins/grafana-timestream-datasource
Apache License 2.0
24 stars 19 forks source link

Issues about when to quote database/tables #153

Closed bitbier closed 2 years ago

bitbier commented 2 years ago

What happened:

Ever since we upgraded to 1.5.0 from 1.4.x, we had to fix how we are sending in our default database name and table names. We have to explicitly wrap our values in "". Otherwise, when you go to explore Timestream datasource, the Database and Table Macro dropdowns are not prepopulated with our values.

What you expected to happen:

We expect that timestream plugin to be smart and handle the quoting for us, I.e. if defaultDatabase is my_test_db or "my_test_db" it should handle the correct quoting when being supplied to timestream APIs.

How to reproduce it (as minimally and precisely as possible):

  1. Using a docker container with timestream 1.5.0 plugin installed

  2. Using the following /etc/grafana/provisioning/datasources/timestream.yaml:

    apiVersion: 1
    
    datasources:
      - name: Timestream
        type: grafana-timestream-datasource
        jsonData:
          authType: default
    
          # Default timestream variables
          defaultDatabase: "${GF_TIMESTREAM_DEFAULT_DATABASE_NAME}"
          defaultTable: "${GF_TIMESTREAM_DEFAULT_TABLE_NAME}"
  3. Sending the following variables:

    • GF_TIMESTREAM_DEFAULT_DATABASE_NAME: "my_test_db"
    • GF_TIMESTREAM_DEFAULT_TABLE_NAME: "my_test_table"
  4. Go to Explore -> Select Timestream Datasource

  5. View the Macros table and see that it is empty

To fix the above issue, you need to explicitly wrap '"my_test_db"' and '"my_test_table"'. You could also maybe able to change the yaml to include the explicit quoting, but I haven't tried that.

Anything else we need to know?:

FYI, we have this fixed. It's more a UX issue for others. Just need to make sure that things are quoted in the correct places, which again could be done with the plugin.

Environment:

fridgepoet commented 2 years ago

Thanks for pointing out the issue, we've identified a breaking change in the macros while getting the tables. Before there were systematically quotes added all the time. But now when the DB name comes from provisioning (and as you pointed out doesn't have quotes), then the name is left as-is.

The workaround is as you've stated:

Thank you @andresmgot for the help in qualifying the issue