(c) 2025 Hurricane Island Center for Science and Leadership
This repository contains the source code for a Grafana backend data source that will integrate with an API that requires hash-based message authentication (HMAC). The project was scaffolded using Grafana plugin tools, and derived from the backend datasource example.
Source code and documentation is provided under the Apache 2 open source license without guarantee or implied warrantee.
The backend is written in Go, and uses the Grafana Backend SDK. Go dependencies are managed in go.mod, and source code can be found in the pkg directory.
You can update the SDK to the latest version with Go commands:
go get -u github.com/grafana/grafana-plugin-sdk-go
go mod tidyFollowing the Grafana template, we use Mage to build the binaries. The build process is controlled by Magefile.go.
For local Docker-based development we generally need linux:ARM64. You can build for distribution with mage -v or for Docker-based development with mage -v linux:ARM64. Calling mage -l lists available build targets and other commands.
Plugins have a Save & Test button in the Grafana UI. The behavior is described by pkg/datasource_test.go.
-
Install dependencies
npm install
-
Build plugin in development mode and run in watch mode
npm run dev
-
Build plugin in production mode
npm run build
-
Run the tests (using Jest)
# Runs the tests and watches for changes, requires git init first npm run test # Exits after running all the tests npm run test:ci
-
Spin up a Grafana instance and run the plugin inside it (using Docker)
npm run server
-
Run the E2E tests (using Playwright)
# Spins up a Grafana instance first that we tests against npm run server # If you wish to start a certain Grafana version. If not specified will use latest by default GRAFANA_VERSION=11.3.0 npm run server # Starts the tests npm run e2e
-
Run the linter
npm run lint # or npm run lint:fix
The plugin must be signed so Grafana can verify its authenticity. This is done with the @grafana/sign-plugin package, which includes commands and workflows to distribute through the Grafana plugins catalog.
The terms and process are explained in plugin publishing and signing criteria, and the plugin signature levels documentation.
- Create a Grafana Cloud account.
- Make sure that the first part of the plugin ID matches the slug of your Grafana Cloud account.
- You can find the plugin ID in the
plugin.jsonfile inside your plugin directory. For example, if your account slug isacmecorp, you need to prefix the plugin ID withacmecorp-.
- You can find the plugin ID in the
- Create a Grafana Cloud API key with the
PluginPublisherrole. - Keep a record of this API key as it will be required for signing a plugin
If the plugin is using the github actions supplied with @grafana/create-plugin signing a plugin is included out of the box. The release workflow can prepare everything to make submitting your plugin to Grafana as easy as possible. Before being able to sign the plugin however a secret needs adding to the Github repository.
- Please navigate to "settings > secrets > actions" within your repo to create secrets.
- Click "New repository secret"
- Name the secret "GRAFANA_API_KEY"
- Paste your Grafana Cloud API key in the Secret field
- Click "Add secret"
To trigger the workflow we need to push a version tag to github. This can be achieved with the following steps:
- Run
npm version <major|minor|patch> - Run
git push origin main --follow-tags
Below you can find source code for existing app plugins and other related documentation.
Some of the code in this repository was created or edited using generative AI products including Github Copilot and Warp Terminal.