michelin / snowflake-grafana-datasource

Snowflake Grafana datasource plugin enables the visual representation of Snowflake data within Grafana dashboards and manages alerts.
Apache License 2.0
67 stars 33 forks source link

timeseries grafana maxdatapoints limit problem #48

Closed kranthikirang closed 1 year ago

kranthikirang commented 1 year ago

Grafana version: 9.4.7 Plugin Version: 1.4.1

currently we are limiting query size if the query is time series and maxDataPoints is set

https://github.com/michelin/snowflake-grafana-datasource/blob/master/pkg/query.go#LL218C5-L218C34

Below is the problem with an example data:

Given a table with three columns with time series data, the following behavior has been observed with Grafana 9.4.7 with michelin-snowflake-connector 1.4.1 +-----------------------+------------------+--------------------+ | Timestamp | Node | Measurement | +-----------------------+------------------+--------------------+ | 2023-05-17 00:00:00 | node A | 234 | +-----------------------+------------------+--------------------+ | 2023-05-17 00:00:00 | node B | 263 | +-----------------------+------------------+--------------------+ | 2023-05-17 00:00:00 | node C | 213 | +-----------------------+------------------+--------------------+ | 2023-05-17 00:05:00 | node A | 212 | +-----------------------+------------------+--------------------+ | 2023-05-17 00:05:00 | node B | 297 | +-----------------------+------------------+--------------------+ | 2023-05-17 00:05:00 | node C | 243 | +-----------------------+------------------+--------------------+

This results in 2 rows after the grafana timeseries transform: +-----------------------+------------------+-------------------+---------------+ | Timestamp | node A | node B | node C | +-----------------------+------------------+-------------------+---------------+ | 2023-05-17 00:00:00 | 234 | 263 | 213 | +-----------------------+------------------+-------------------+---------------+ | 2023-05-17 00:05:00 | 212 | 297 | 243 | +-----------------------+------------------+-------------------+---------------+

We are expecting 6 rows, but for the sake of example, if MaxDataPoints were set explicity to 4 (or implictly by panel width and timerange) the plugin adds “LIMIT 4” to the query and only fetches 4 rows, which results in missing samples:

+-----------------------+------------------+-------------------+---------------+ | Timestamp | node A | node B | node C | +-----------------------+------------------+-------------------+---------------+ | 2023-05-17 00:00:00 | 234 | 263 | 213 | +-----------------------+------------------+-------------------+---------------+ | 2023-05-17 00:05:00 | 212 | | | +-----------------------+------------------+-------------------+---------------+

kranthikirang commented 1 year ago

Could you please check https://github.com/michelin/snowflake-grafana-datasource/pull/50