fr-ser / grafana-sqlite-datasource

Grafana Plugin to enable SQLite as a Datasource
Apache License 2.0
124 stars 17 forks source link

Allow filling gaps (with NULL) for time series data (in order to visualize gaps in charts) #39

Closed fr-ser closed 3 years ago

fr-ser commented 3 years ago

For time-series visualization it can be very important that windows of missing values are returned in the result even if they are not in the table itself. For Postgres (and other SQL) databases this is achieved with the $__timeGroup and $__unixEpochGroup macro. See here: https://grafana.com/docs/grafana/latest/datasources/postgres/#macros.

This macro does two things:

  1. It substitutes the time column with a suitable aggregation point see: https://github.com/grafana/grafana/blob/ce809de1ed98841b4414afeab27e2c8e736a9faa/pkg/tsdb/postgres/macros.go#L92
  2. After executing the query it fills missing values see: https://github.com/grafana/grafana/blob/6a97236b7abd4ca2e074b4ec2549ea417ed05b1c/pkg/tsdb/sqleng/sql_engine.go#L382

While the first feature of the macro is easy to replicate with SQL the second one is not. It would be cool to have the second one in the plugin.

The final goal is a chart like this: image

fr-ser commented 3 years ago

Should be done here: https://github.com/fr-ser/grafana-sqlite-datasource/releases/tag/v1.2.0