Skip to content

Commit 734637d

Browse files
docs: Adds a better readme
1 parent 87de672 commit 734637d

File tree

3 files changed

+226
-174
lines changed

3 files changed

+226
-174
lines changed

DEV.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

DEVELOPMENT_GUIDE.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Development Guide
2+
3+
## Environment
4+
To get a development environment up and running, first ensure the following are installed:
5+
6+
1. go
7+
2. mage
8+
3. yarn
9+
4. docker
10+
5. [Haxall](https://haxall.io/doc/docHaxall/Setup)
11+
12+
Then run the following in **different terminals**:
13+
14+
1. Build the front-end and listen for javascript changes:
15+
16+
```bash
17+
yarn dev
18+
```
19+
20+
2. Build the back-end and inject it into a docker image:
21+
22+
```bash
23+
mage -v && docker-compose up
24+
```
25+
26+
3. Run Haxall (the below command is an example):
27+
28+
```bash
29+
./bin/hx run ./proj/test
30+
```
31+
32+
## Usage
33+
34+
Create a new data source, select "Haystack", and provide it the details for the Haxall server
35+
that was started. In order to reference your host machine's network, use the url
36+
`http://host.docker.internal:8080/api/`. Click "Save and Test" and make sure that it is
37+
reported as working.
38+
39+
Create a new dashboard and panel, and use this axon query to test the connection:
40+
41+
```
42+
[{ts: now()-1hr, v0: 0}, {ts: now(), v0: 10}].toGrid
43+
```
44+
45+
Note that if your grid's first column is a date-time you can use it with the timeseries chart.
46+
Alternatively, nearly every Axon query can be visualized using the table view.
47+
48+
# Release
49+
50+
To trigger a new release of the plugin, we need to push a version tag to github. This can be
51+
achieved with the following steps:
52+
53+
1. Run `npm version <major|minor|patch>`
54+
2. Run `git push origin main --follow-tags`
55+
56+
57+
# TODO
58+
59+
* [ ] Add support for non-eval queries (read, hisRead, etc)
60+
* [ ] Improve login/logout and add auth/retry logic
61+
62+
---
63+
64+
Below is the original readme generated by Grafana
65+
66+
# Grafana data source plugin template
67+
68+
This template is a starting point for building a Data Source Plugin for Grafana.
69+
70+
## What are Grafana data source plugins?
71+
72+
Grafana supports a wide range of data sources, including Prometheus, MySQL, and even Datadog. There’s a good chance you can already visualize metrics from the systems you have set up. In some cases, though, you already have an in-house metrics solution that you’d like to add to your Grafana dashboards. Grafana Data Source Plugins enables integrating such solutions with Grafana.
73+
74+
## Getting started
75+
76+
### Backend
77+
78+
1. Update [Grafana plugin SDK for Go](https://grafana.com/docs/grafana/latest/developers/plugins/backend/grafana-plugin-sdk-for-go/) dependency to the latest minor version:
79+
80+
```bash
81+
go get -u github.com/grafana/grafana-plugin-sdk-go
82+
go mod tidy
83+
```
84+
85+
2. Build backend plugin binaries for Linux, Windows and Darwin:
86+
87+
```bash
88+
mage -v
89+
```
90+
91+
3. List all available Mage targets for additional commands:
92+
93+
```bash
94+
mage -l
95+
```
96+
### Frontend
97+
98+
1. Install dependencies
99+
100+
```bash
101+
yarn install
102+
```
103+
104+
2. Build plugin in development mode and run in watch mode
105+
106+
```bash
107+
yarn dev
108+
```
109+
110+
3. Build plugin in production mode
111+
112+
```bash
113+
yarn build
114+
```
115+
116+
4. Run the tests (using Jest)
117+
118+
```bash
119+
# Runs the tests and watches for changes, requires git init first
120+
yarn test
121+
122+
# Exists after running all the tests
123+
yarn test:ci
124+
```
125+
126+
5. Spin up a Grafana instance and run the plugin inside it (using Docker)
127+
128+
```bash
129+
yarn server
130+
```
131+
132+
6. Run the E2E tests (using Cypress)
133+
134+
```bash
135+
# Spin up a Grafana instance first that we tests against
136+
yarn server
137+
138+
# Start the tests
139+
yarn e2e
140+
```
141+
142+
7. Run the linter
143+
144+
```bash
145+
yarn lint
146+
147+
# or
148+
149+
yarn lint:fix
150+
```
151+
152+
153+
# Distributing your plugin
154+
155+
When distributing a Grafana plugin either within the community or privately the plugin must be signed so the Grafana application can verify its authenticity. This can be done with the `@grafana/sign-plugin` package.
156+
157+
_Note: It's not necessary to sign a plugin during development. The docker development environment that is scaffolded with `@grafana/create-plugin` caters for running the plugin without a signature._
158+
159+
## Initial steps
160+
161+
Before signing a plugin please read the Grafana [plugin publishing and signing criteria](https://grafana.com/docs/grafana/latest/developers/plugins/publishing-and-signing-criteria/) documentation carefully.
162+
163+
`@grafana/create-plugin` has added the necessary commands and workflows to make signing and distributing a plugin via the grafana plugins catalog as straightforward as possible.
164+
165+
Before signing a plugin for the first time please consult the Grafana [plugin signature levels](https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/#plugin-signature-levels) documentation to understand the differences between the types of signature level.
166+
167+
1. Create a [Grafana Cloud account](https://grafana.com/signup).
168+
2. Make sure that the first part of the plugin ID matches the slug of your Grafana Cloud account.
169+
- _You can find the plugin ID in the plugin.json file inside your plugin directory. For example, if your account slug is `acmecorp`, you need to prefix the plugin ID with `acmecorp-`._
170+
3. Create a Grafana Cloud API key with the `PluginPublisher` role.
171+
4. Keep a record of this API key as it will be required for signing a plugin
172+
173+
## Signing a plugin
174+
175+
### Using Github actions release workflow
176+
177+
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](./.github/workflows/release.yml) 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.
178+
179+
1. Please navigate to "settings > secrets > actions" within your repo to create secrets.
180+
2. Click "New repository secret"
181+
3. Name the secret "GRAFANA_API_KEY"
182+
4. Paste your Grafana Cloud API key in the Secret field
183+
5. Click "Add secret"
184+
185+
#### Push a version tag
186+
187+
To trigger the workflow we need to push a version tag to github. This can be achieved with the following steps:
188+
189+
1. Run `npm version <major|minor|patch>`
190+
2. Run `git push origin main --follow-tags`
191+
192+
193+
## Learn more
194+
195+
Below you can find source code for existing app plugins and other related documentation.
196+
197+
- [Basic data source plugin example](https://github.com/grafana/grafana-plugin-examples/tree/master/examples/datasource-basic#readme)
198+
- [Plugin.json documentation](https://grafana.com/docs/grafana/latest/developers/plugins/metadata/)
199+
- [How to sign a plugin?](https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/)

0 commit comments

Comments
 (0)