Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naturalcycles/grafana-lib
Exposes CommonDB as Grafana Json Datasource (express middleware)
https://github.com/naturalcycles/grafana-lib
commondb expressjs grafana
Last synced: 17 days ago
JSON representation
Exposes CommonDB as Grafana Json Datasource (express middleware)
- Host: GitHub
- URL: https://github.com/naturalcycles/grafana-lib
- Owner: NaturalCycles
- Created: 2020-05-31T22:34:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T18:05:21.000Z (about 2 years ago)
- Last Synced: 2024-10-09T11:53:09.468Z (3 months ago)
- Topics: commondb, expressjs, grafana
- Language: TypeScript
- Homepage:
- Size: 852 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
## @naturalcycles/grafana-lib
> Exposes CommonDB as [Grafana Json Datasource](https://github.com/simPod/grafana-json-datasource)
> (express middleware)[![npm](https://img.shields.io/npm/v/@naturalcycles/grafana-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/grafana-lib)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)# Example
```typescript
import { createDefaultApp, startServer } from '@naturalcycles/backend-lib'
import { FileDB } from '@naturalcycles/db-lib/dist/adapter/file'
import { GithubPersistencePlugin } from '@naturalcycles/github-db'
import { createGrafanaJsonDatasourceHandler } from '@naturalcycles/grafana-lib'
import { pHang } from '@naturalcycles/js-lib'
import { runScript } from '@naturalcycles/nodejs-lib/dist/script'runScript(async () => {
// 1. Have your CommonDB ready
export const githubDB = new FileDB({
plugin: new GithubPersistencePlugin({
repo: 'NaturalCycles/github-db',
forcePush: false,
}),
})// 2. Create grafanaHandler
const grafanaHandler = createGrafanaJsonDatasourceHandler({
db: githubDB,
})// 3. Run Express server with grafanaHandler on 'http://localhost:8400/'
await startServer({
port: 8400,
expressApp: createDefaultApp({
resources: [grafanaHandler],
}),
})await pHang()
})
```This simple Express server with Grafana middleware allows to connect to it via Grafana UI as "Json
Datasource".![Grafana Json Datasource](./media/grafana1.png)