Skip to content

Grafana Datasource Plugin for querying data from Neo4j with cypher

License

Notifications You must be signed in to change notification settings

denniskniep/grafana-datasource-plugin-neo4j

Repository files navigation

CI GitHub release (latest SemVer)

Neo4j DataSource for Grafana

Allows Neo4j to be used as a DataSource for Grafana

Showcase/Quickstart

Starts preprovisioned Grafana and Neo4j

sudo docker-compose up

Screenshots and Plugin Manual

Plugin Manual

Changelog

Installation

Development - Getting started

Frontend

Grafana Ui - Component library

Optional: Use Docker for building with yarn

sudo docker run --rm -w /app -it -v $(pwd):/app node:18.17.0-alpine ash

Change into plugin directory

cd neo4j-datasource-plugin

Install dependencies

npm install

Build Plugin in development mode (incl. auto build on change)

npm run dev

Build plugin in production mode

yanpm run build

Execute Prettier

yarn prettier --write .

Backend

NOTE: Depending on your version of go you might need go get -u instead of go install.

Optional: Use Docker for building with go

sudo docker run --rm -w /app -it -v $(pwd):/app golang:1.20 bash
cd neo4j-datasource-plugin
go install github.com/magefile/mage
  1. Update Grafana plugin SDK for Go dependency to the latest minor version:

    go get -u github.com/grafana/grafana-plugin-sdk-go
    go mod tidy
  2. Build backend plugin binaries for Linux, Windows and Darwin:

    export GOFLAGS=-buildvcs=false
    mage -v
  3. List all available Mage targets for additional commands:

    mage -l
  4. Build with go:

    export GOFLAGS=-buildvcs=false
    
    go install  ./...
    go build  ./...
  5. Run all tests & coverage:

    Important: Start Docker-Compose environment first!

    sudo docker-compose -f docker-compose.dev.yaml up
    mage coverage
  6. Run tests which are independet of Docker-Compose environment

    mage coverageShort

Test with Grafana

Starts preprovisioned Grafana and Neo4J for development

sudo docker-compose -f docker-compose.dev.yaml up

Grafana: http://localhost:3000

Neo4J: http://localhost:7474

Grafana is started by docker-compose in development mode therefore no restart of grafana is required when frontend source code changed.

Run example queries

Nodes

Match(m:Movie) return m

Tabledata

Match(m:Movie) return m.title, m.tagline

Timeseriesdata

return datetime() - duration({minutes: 1})  as Time, 99 as Test
UNION ALL
return datetime() - duration({minutes: 2})  as Time, 85 as Test
UNION ALL
return datetime() - duration({minutes: 3})  as Time, 86 as Test
UNION ALL
return datetime() - duration({minutes: 4})  as Time, 100 as Test
UNION ALL
return datetime() - duration({minutes: 5})  as Time, 32 as Test

Signing

Docs

Sign plugin as private

cd neo4j-datasource-plugin
export GRAFANA_API_KEY=<GRAFANA_API_KEY>
npx @grafana/sign-plugin@latest --rootUrls http://localhost:3000/

Sign plugin as community

cd neo4j-datasource-plugin
export GRAFANA_API_KEY=<GRAFANA_API_KEY>
npx @grafana/sign-plugin@latest

Learn more