{"id":15178887,"url":"https://github.com/fr-ser/grafana-sqlite-datasource","last_synced_at":"2026-02-15T21:06:08.277Z","repository":{"id":37975016,"uuid":"289470143","full_name":"fr-ser/grafana-sqlite-datasource","owner":"fr-ser","description":"Grafana Plugin to enable SQLite as a Datasource","archived":false,"fork":false,"pushed_at":"2025-03-25T19:56:32.000Z","size":78407,"stargazers_count":138,"open_issues_count":6,"forks_count":16,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T04:06:21.186Z","etag":null,"topics":["grafana","grafana-plugin","hacktoberfest","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fr-ser.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["fr-ser"]}},"created_at":"2020-08-22T10:51:41.000Z","updated_at":"2025-03-25T19:56:35.000Z","dependencies_parsed_at":"2024-06-18T22:45:36.640Z","dependency_job_id":"5c7c5723-9c7c-4cd7-abfc-99783cf0e237","html_url":"https://github.com/fr-ser/grafana-sqlite-datasource","commit_stats":{"total_commits":132,"total_committers":3,"mean_commits":44.0,"dds":"0.030303030303030276","last_synced_commit":"10fe041eec82904f6a9725bcfb4579f07b8c3601"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fr-ser%2Fgrafana-sqlite-datasource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fr-ser%2Fgrafana-sqlite-datasource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fr-ser%2Fgrafana-sqlite-datasource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fr-ser%2Fgrafana-sqlite-datasource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fr-ser","download_url":"https://codeload.github.com/fr-ser/grafana-sqlite-datasource/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289428,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grafana","grafana-plugin","hacktoberfest","sqlite3"],"created_at":"2024-09-27T15:41:09.993Z","updated_at":"2026-02-15T21:06:08.270Z","avatar_url":"https://github.com/fr-ser.png","language":"Go","funding_links":["https://github.com/sponsors/fr-ser"],"categories":[],"sub_categories":[],"readme":"# Grafana SQLite Datasource\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)\n[![branches](https://github.com/fr-ser/grafana-sqlite-datasource/actions/workflows/branches.yml/badge.svg)](https://github.com/fr-ser/grafana-sqlite-datasource/actions/workflows/branches.yml)\n[![tags](https://github.com/fr-ser/grafana-sqlite-datasource/actions/workflows/tags.yml/badge.svg)](https://github.com/fr-ser/grafana-sqlite-datasource/actions/workflows/tags.yml)\n\nThis is a Grafana backend plugin to allow using an SQLite database as a data source.\nThe SQLite database needs to be accessible to the filesystem of the device where Grafana itself\nis running.\n\nTable of contents:\n\n- [Plugin Installation](#plugin-installation)\n- [Security Considerations](#security-considerations)\n- [Support for Time Formatted Columns](#support-for-time-formatted-columns)\n- [Macros](#macros)\n- [Alerting](#alerting)\n- [Configuration](#configuration)\n- [Common Problems - FAQ](#common-problems---faq)\n- [Development and Contributing](#development-and-contributing)\n- [Supporting the Project](#supporting-the-project)\n- [Further Documentation and Links](#further-documentation-and-links)\n\n## Plugin Installation\n\nThe recommended way to install the plugin for most users is to use the grafana CLI:\n\n1. Run this command: `grafana-cli plugins install frser-sqlite-datasource`\n2. Restart the Grafana server.\n3. To make sure the plugin was installed, check the list of installed data sources. Click the\n   Plugins item in the main menu. Both core data sources and installed data sources will appear.\n\nFor other installation options (e.g. to install versions not yet released in the Grafana registry but in Github) see\n[./docs/installation.md](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/docs/installation.md).\n\n## Security considerations\n\n### Using the \"Attach\" Feature of SQLite to Connect to Private Database\n\nA data source of the SQLite plugin specifies a specific SQLite location.\nBut by using the [attach feature](https://www.sqlite.org/lang_attach.html) this restriction can be circumvented.\n\nA **user with read only permissions** on the database can use the attach feature in a query to connect to any database that the Grafana user has access to on the system.\n\nTo prevent such behavior the attach limit is set to 0 by default and can only be increased when setting the `unsafe_allow_attach_limit_above_zero` ([see below for more information](#configuration)) at plugin level.\n\n### Access to The Grafana Internal SQLite Database\n\nGrafana itself can run with an SQLite database as a data storage.\nUsing this plugin the internal Grafana database file can be accessed.\n\nThere are no built-in restrictions preventing a **user with permissions to edit the data source configuration** from attaching to the SQLite database and accessing its contents.\n\nThis means that sensitive data, including secrets stored within the database, could potentially be exposed if appropriate access controls are not enforced at the Grafana level.\n\nRecommendations to mitigate risks:\n\n- By default any file with the name `grafana.db` cannot be opened. This can be disabled via setting `unsafe_disable_grafana_internal_blocklist` ([see below for more information](#configuration)).\n- Use the \"block_list\" option in the grafana.ini ([see below for more information](#configuration)) to block access if the file has another name.\n- Limit Data Source Editing Permissions: Restrict the ability to modify the data source configuration to only trusted administrators.\n- Do not use SQLite as the data storage for Grafana but a database with more access controls (like Postgres).\n\n## Support for Time Formatted Columns\n\nSQLite has no native \"time\" format. It relies on strings and numbers for time and dates. Since\nespecially for time series Grafana expects an actual time type, however, the plugin provides a way\nto infer a real timestamp. This can be set in the query editor by providing the name of the column,\nwhich should be reformatted to a timestamp.\n\nThe plugin supports two different inputs that can be converted to a \"time\" depending on the type\nof the value in the column, that should be formatted as \"time\":\n\n1. **A number input**: It is assumed to be a unix timestamp / unix epoch. This represents time in\n   the number of **seconds** (make sure your timestamp is not in milliseconds). More information is\n   here: \u003chttps://en.wikipedia.org/wiki/Unix_time\u003e\n\n2. **A string input**: The value is expected to be formatted in accordance with **RFC3339**,\n   e.g. `\"2006-01-02T15:04:05Z07:00\"`. Edge cases might occur and the parsing library used is the\n   source of truth here: \u003chttps://golang.org/pkg/time/#pkg-constants\u003e.\n\nTimestamps stored as unix epoch should work out of the box, but the string formatting might require\nadjusting your current format. The below example shows how to convert a \"date\" column to a parsable\ntimestamp:\n\n```SQL\nWITH converted AS (\n   -- a row looks like this (value, date): 1.45, '2020-12-12'\n   SELECT value,  date || 'T00:00:00Z' AS datetime FROM raw_table\n)\nSELECT datetime, value FROM converted ORDER BY datetime ASC\n```\n\n## Macros\n\nThis plugins supports macros inspired by the built-in Grafana data sources (e.g.\n\u003chttps://grafana.com/docs/grafana/latest/datasources/postgres/#macros\u003e).\n\nHowever, as each macro needs to be re-implemented from scratch, only the following macros are\nsupported. Other macros (that you might expect from other SQL databases) are not supported by the\nplugin (yet).\n\n### $\\_\\_unixEpochGroupSeconds(unixEpochColumnName, intervalInSeconds)\n\nExample: `$__unixEpochGroupSeconds(\"time\", 10)`\n\nWill be replaced by an expression usable in GROUP BY clause. For example:\n`cast((\"time\" / 10) as int) * 10`\n\n### $\\_\\_unixEpochGroupSeconds(unixEpochColumnName, intervalInSeconds, NULL)\n\nExample: `$__unixEpochGroupSeconds(timestamp, 10, NULL)`\n\nThis is the same as the above example but with a fill parameter so missing points in that series\nwill be added for Grafana and `NULL` will be used as value.\n\nIn case multiple time columns are provided the first one is chosen as the column to determine the\ngap filling. \"First\" in this context means first in the SELECT statement. This column needs to have\nno NULL values and must be sorted in ascending order.\n\n## Alerting\n\nThe plugins supports the Grafana alerting feature. Similar to the built in data sources alerting\ndoes not support variables as they are normally replaced in the frontend, which is not involved\nfor the alerts. In order to allow time filtering this plugin supports the variables `$__from` and\n`$__to`. For more information about those variables see here:\n\u003chttps://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/#__from-and-__to\u003e.\nFormatting of those variables (e.g. `${__from:date:iso}`) is not supported for alerts, however.\n\n## Configuration\n\nMost of the plugin configuration happens when adding a datasource via the Grafana frontend.\nAll such configuration can also be provisioned ([see the FAQ for more details](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/docs/faq.md#can-i-use-provisioning-with-this-plugin)).\n\nAside from that, the plugin supports the following configuration via the `grafana.ini` file.\nThe following block shows the default values and gives an explanation of each field.\n\n```ini\n[plugin.frser-sqlite-datasource]\n   ; this settings allows setting attach limits above 0.\n   ; this enables any users with access to the plugin to attach any database that the Grafana users has access to\n   ; this is also not controlled via the block_list.\n   ; enabling this setting is not recommended for security reasons\n   unsafe_allow_attach_limit_above_zero = false\n   ; this is a comma separated list of strings that any part of the path of the SQLite database cannot contain.\n   ; use this to prevent access (even for Grafana admin users) from certain files or paths\n   ; the path check is case insensitive\n   ; block_list = \"grafana.db,private_folder,other.db\"\n   block_list = \"\"\n   ; this setting prevents blocking security related path elements that are blocked by default\n   ; the path check is case insensitive\n   ; the blocked path elements are: .aws, .config/gcloud, .azure, .kube/config, .docker/config, .ssh, .gnupg, .pki, /etc/shadow, /etc/passwd, /etc/gshadow, /proc/, /sys/, .env, credentials, .git/config, .netrc, .npmrc, .pypirc, id_rsa, id_dsa, id_ecdsa, id_ed25519\n   ; enabling this setting is not recommended for security reasons\n   unsafe_disable_security_blocklist = false\n   ; this setting prevents blocking grafana internal related path elements that are blocked by default\n   ; the path check is case insensitive\n   ; the blocked path elements are: grafana.db\n   ; enabling this setting is not recommended for security reasons\n   unsafe_disable_grafana_internal_blocklist = false\n   ; by default the plugin adds \"_pragma=query_only(1)\" to the path options if no _pragma=query_only is already specified\n   ; this setting prevents setting this default value.\n   ; enabling this setting is not recommended for security reasons\n   unsafe_disable_query_only_path_option = false\n```\n\n## Common Problems - FAQ\n\nThis is a list of common questions or problems. For the answers and more details see\n[./docs/faq.md](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/docs/faq.md).\n\n- [I have a \"file not found\" error for my database](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/docs/faq.md#i-have-a-file-not-found-error-for-my-database)\n- [I have a \"permission denied\" error for my database](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/docs/faq.md#i-have-a-permission-denied-error-for-my-database)\n- ...\n\n## Query examples\n\nSome examples to help getting started with SQL and SQLite can be found in\n[./docs/examples.md](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/docs/examples.md).\n\nThese examples include things like:\n\n- filtering by the time specified in the Grafana UI\n- creating a time series mindful of gaps\n- converting dates to timestamps\n- ...\n\n## Development and Contributing\n\nAny contribution is welcome. Some information regarding the local setup can be found in the\n[DEVELOPMENT.md file](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/DEVELOPMENT.md).\n\n## Supporting the Project\n\nThis project was developed for free as an open source project. And it will stay that way.\n\nIf you like using this plugin, however, and would like to support the development go check out\nthe [Github sponsorship page](https://github.com/sponsors/fr-ser). This allows sponsoring the\nproject with monthly or one-time contributions.\n\n## Further Documentation and Links\n\n- A changelog of the plugin can be found in the [CHANGELOG.md](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/CHANGELOG.md).\n- More documentation about the plugin can be found under [the docs section in Github](https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/docs).\n- The plugin can be found in the [Grafana plugin registry](https://grafana.com/grafana/plugins/frser-sqlite-datasource/).\n- Questions or bugs about the plugin can be found and reported [in Github](https://github.com/fr-ser/grafana-sqlite-datasource/issues?q=) or in the [Grafana community](https://community.grafana.com/search?q=sqlite%20order%3Alatest).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffr-ser%2Fgrafana-sqlite-datasource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffr-ser%2Fgrafana-sqlite-datasource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffr-ser%2Fgrafana-sqlite-datasource/lists"}