Grafana SQLite Datasource
This is a Grafana backend plugin to allow using a SQLite database as a data source.
Development and Contributing
Any contribution is welcome. Some information regarding the local setup can be found in the DEVELOPMENT.md file.
The most up to date (but also most generic) information can always be found here: Grafana Website - Plugin Installation
Installing the Plugin on an Existing Grafana With the CLI
Grafana comes with a command line tool that can be used to install plugins.
- Run this command:
grafana-cli plugins install frser-sqlite-datasource
- Restart the Grafana server.
- Login in with a user that has admin rights. This is needed to create datasources.
- To make sure the plugin was installed, check the list of installed datasources. Click the Plugins item in the main menu. Both core datasources and installed datasources will appear.
Installing the Plugin Manually on an Existing Grafana (Most up to Date)
If you need a version that is not released (yet) on the Grafana homepage or if the server where Grafana is installed has no access to the Grafana.com server, then the plugin can be downloaded and manually copied to the server.
Get the zip file from Latest release on Github
Extract the zip file into the data/plugins subdirectory for Grafana:
unzip <the_download_zip_file> -d <plugin_dir>/
Finding the plugin directory can sometimes be a challenge as this is platform and settings dependent. A common location for this on Linux devices is
Restart the Grafana server
To make sure the plugin was installed, check the list of installed datasources. Click the Plugins item in the main menu. Both core datasources and installed datasources will appear.
ARM6 / RaspberryPi Zero W Support
This plugins supports ARM6 (the version running on RaspberryPi Zero W). There is a problem, though,
with Grafana supporting ARM7 (newer Raspberries) and ARM6 at the same time. Grafana chooses
the correct plugin by file name. But both ARM6 and ARM7 are named
Currently the ARM7 build is named like this by default, which is why the "official" plugin distribution does not support ARM6 devices.
A plugin version specifically built for ARM6 devices can be found on the Github release page (see manual installation above).
Configuring the Datasource in Grafana
The only required configuration is the path to the SQLite database (local path on the Grafana Server)
- Add an SQLite datasource.
- Set the path to the database (the grafana process needs to find the SQLite database under this path).
- Save the datasource and use it.
Support for Time Formatted Columns
SQLite has no native "time" format. It actually relies on strings and numbers. Since especially for time series Grafana expects an actual time type, however, the plugin provides a way to infer a real timestamp. This can be set in the query editor by providing the name of the column, which should be reformatted to a timestamp.
The plugin supports two different inputs that can be converted to a "time" depending on the type of the value in the column, that should be formatted as "time":
A number input: It is assumed to be a unix timestamp / unix epoch and will be converted to an integer before converting it to a timestamp.
A string input: The value is expected to be formatted in accordance with RFC3339, e.g.
"2006-01-02T15:04:05Z07:00". Edge cases might occur and the parsing library used is the source of truth here: https://golang.org/pkg/time/#pkg-constants.
Timestamps stored as unix epoch should work out of the box, but the string formatting might require adjusting your current format. The below example shows how to convert a "date" column to a parsable timestamp:
WITH converted AS ( -- a row looks like this (value, date): 1.45, '2020-12-12' SELECT value, date || 'T00:00:00Z' AS datetime FROM raw_table ) SELECT datetime, value FROM converted ORDER BY datetime ASC
This plugins supports plugins inspired by the built-in Grafana datasources (e.g. https://grafana.com/docs/grafana/latest/datasources/postgres/#macros).
However, as each macro needs to be re-implemented from scratch only the following macros are supported. Other macros (that you might expect from other SQL databases) do not work
Will be replaced by an expression usable in GROUP BY clause. For example:
cast(("time" / 10) as int) * 10
$__unixEpochGroupSeconds(unixEpochColumnName, intervalInSeconds, NULL)
$__unixEpochGroupSeconds(timestamp, 10, NULL)
Same as above but with a fill parameter so missing points in that series will be added by grafana
NULL will be used as value.
In case multiple time columns are provided the first one is chosen as the column to determine the gap filling. "First" in this context means first in the SELECT statement. This column to have no NULL values and must be ordered ascending.
Installing SQLite on Grafana Cloud:
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
For more information, visit the docs on plugin installation.
Installing on a local Grafana:
For local instances, plugins are installed and updated via a simple CLI command. Plugins are not updated automatically, however you will be notified when updates are available right within your Grafana.
1. Install the Data Source
Use the grafana-cli tool to install SQLite from the commandline:
grafana-cli plugins install
The plugin will be installed into your grafana plugins directory; the default is /var/lib/grafana/plugins. More information on the cli tool.
Alternatively, you can manually download the .zip file for your architecture below and unpack it into your grafana plugins directory.
Alternatively, you can manually download the .zip file and unpack it into your grafana plugins directory.
2. Configure the Data Source
Accessed from the Grafana main menu, newly installed data sources can be added immediately within the Data Sources section.
Next, click the Add data source button in the upper right. The data source will be available for selection in the Type select box.
To see a list of installed data sources, click the Plugins item in the main menu. Both core data sources and installed data sources will appear.
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog
- The response of the plugin includes the final query as metadata and can be checked in the inspector now
- replace time columns with an expression to group by
- Allow filling up missing values with
- return additional time formatted column for time-series formats as normal values (previously they were skipped)
- Experimental support for MacOS (no static linking)
- Showing better error messages for certain fail conditions of the plugin health check (e.g. permission error)
- Fixed bug preventing using query variables when SQLite is the default datasource (<= Grafana 7.4)
- Enabled the
alertingfeature for the plugin (no code change)
No breaking change was introduced but due to code stability the first major version is released.
- variables like
$__interval_msare supported now
Changing plugin name to SQLite
added category to plugin.json for better grouping on the Grafana homepage
updated Readme after first official release of plugin on Grafana homepage
- Documentation about the time conversion in the README and in the query editor help text.
- Correct handling of "NUMERIC" columns with mixed data (e.g. float and integer)
Added option to explicitly convert backend data frame to time series:
This requires the initial data frame to be in a Long Format
The resulting time series consists of one data frame per metric
- Releasing arm6 (RaspberryPi Zero) as separate distribution (Github only)
- Renamed the arm7 executable to arm (newer Raspberry Models should run fine now)
- Different content of zip file published with Github release according to new Grafana v7.3 standards
- Query variables are now supported
- The plugin is now signed
- For Signing grafana-toolkit 7.3.3 was necessary. The grafana version to test against was bumped to version 7.3.3
- Fixed: Handling of NULL values in queries is now correct
First "working" version
- Fixed: Plugin files in the zip file are now executable
Visualize Humio logs alongside your other data sources in Grafana Cloud with the new plugin for Grafana
Blog post 5 min
Monitor your production line with the new Grafana Enterprise data source plugin for SAP HANA®
Blog post 5 min
What’s new in Grafana Enterprise Metrics 1.3, our scalable, self-hosted Prometheus service
Blog post 5 min
Introducing the new Open Distro for Elasticsearch plugin for Grafana, also available in Amazon Managed Service for Grafana
Blog post 3 min
Want to visualize software development insights with Grafana? With our new Jira Enterprise plugin, you can!
Blog post 5 min
A closer look at the admin API and plugin for centralized tenant adminstration and control in Grafana Enterprise Logs
Blog post 4 min
The new Splunk Infrastructure Monitoring plugin brings the SaaS formerly known as SignalFx to your Grafana dashboards
Blog post 5 min
The Splunk plugin for Grafana now supports data links for jumping directly from logs to traces
Blog post 5 min
With the new AWS IoT SiteWise plugin, you can visualize and monitor your equipment data in Grafana dashboards
Blog post 2 min