-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dengbo
committed
Aug 2, 2024
1 parent
0268541
commit a23728a
Showing
3 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
version: '3.0' | ||
|
||
services: | ||
datalayers: | ||
container_name: datalayers-for-plugin | ||
image: datalayers/datalayers:latest | ||
ports: | ||
- 8360:8360 | ||
- 8361:8361 | ||
environment: | ||
- DATALAYERS_SERVER__AUTH__USERNAME=admin | ||
- DATALAYERS_SERVER__AUTH__PASSWORD=public | ||
|
||
grafana: | ||
container_name: 'grafana-datasource-datalayers' | ||
build: | ||
context: ./.config | ||
args: | ||
grafana_version: ${GRAFANA_VERSION:-9.4.7} | ||
grafana_version: ${GRAFANA_VERSION:-11.1.1} | ||
ports: | ||
- 3000:3000/tcp | ||
volumes: | ||
- ./dist:/var/lib/grafana/plugins/grafana-datasource-datalayers | ||
- ./provisioning/datasources/datalayers.yml:/etc/grafana/provisioning/datasources/datalayers.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Introduction for grafana provisioning | ||
|
||
|
||
## Config Datasource | ||
|
||
1. First of all, build the plugin(frontend & backend). | ||
|
||
2. Run `yarn server` for testing. | ||
|
||
3. Visite the `http://localhost:3000`, login to home page. | ||
|
||
4. Entry the `Home - Connections - Data sources` page, Click the `Datalayers` plugin. | ||
|
||
5. Update the `Host:Port` field, replace the `your_host_ip` to real IP address, Click the `Save & test` button to testing connections. We will operate through port `8360` using the FlightSQL protocol to execute queries. | ||
|
||
|
||
|
||
## Mock datas for Datalayers | ||
|
||
We will operate through port `8361` using the HTTP protocol. | ||
|
||
1. Create database `demo` | ||
|
||
``` bash | ||
curl -u"admin:public" -X POST \ | ||
http://127.0.0.1:8361/api/v1/sql \ | ||
-H 'Content-Type: application/binary' \ | ||
-d 'create database demo' | ||
``` | ||
|
||
2. Create table `demo.sensor_info` | ||
|
||
``` bash | ||
curl -u"admin:public" -X POST \ | ||
http://127.0.0.1:8361/api/v1/sql?db=demo \ | ||
-H 'Content-Type: application/binary' \ | ||
-d 'CREATE TABLE sensor_info ( | ||
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
sn INT32 NOT NULL, | ||
speed int, | ||
longitude float, | ||
latitude float, | ||
timestamp KEY (ts)) PARTITION BY HASH(sn) PARTITIONS 2 ENGINE=TimeSeries;' | ||
``` | ||
|
||
3. Write some data | ||
|
||
``` bash | ||
curl -u"admin:public" -X POST \ | ||
http://127.0.0.1:8361/api/v1/sql?db=demo \ | ||
-H 'Content-Type: application/binary' \ | ||
-d 'INSERT INTO sensor_info(sn, speed, longitude, latitude) VALUES(1, 120, 104.07, 30.59),(2, 120, 104.07, 30.59)' | ||
``` | ||
|
||
## Query data by plugin | ||
|
||
Enter the `Home - Explore` page and then start using the plugin to query the data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: 1 | ||
datasources: | ||
- name: Datalayers | ||
type: grafana-datalayers-datasource | ||
orgId: 1 | ||
uid: 'grafana-datalayers-datasource' | ||
jsonData: | ||
host: 'your_host_ip:8360' | ||
selectedAuthType: 'username/password' | ||
username: 'admin' | ||
metadata: | ||
- database: 'demo' | ||
secureJsonData: | ||
password: 'public' | ||
version: 1 | ||
editable: true | ||
isDefault: true |