Skip to content

Commit

Permalink
Merge pull request #13 from taosdata/sign-by-grafana-toolkit
Browse files Browse the repository at this point in the history
Sign by grafana toolkit
  • Loading branch information
sangshuduo authored Dec 12, 2020
2 parents ec77d90 + 2677c6e commit 32e2c97
Show file tree
Hide file tree
Showing 6 changed files with 64,224 additions and 5,304 deletions.
82 changes: 43 additions & 39 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,99 @@ TDengine Datasource - build by Taosdata Inc. www.taosdata.com

TDengine backend server implement 2 urls:

* `/heartbeat` return 200 ok. Used for "Test connection" on the datasource config page.
* `/query` return data based on input sqls.
* `/heartbeat` return 200 ok. Used for "Test connection" on the datasource config page.
* `/query` return data based on input sqls.

## Installation

To install this plugin:
To install this plugin:
Copy the data source you want to /var/lib/grafana/plugins/. Then restart grafana-server. The new data source should now be available in the data source type dropdown in the Add Data Source View.

```
cp -r <tdengine-extrach-dir>/connector/grafana/tdengine /var/lib/grafana/plugins/
cp -r <grafanaplugin-dir> /var/lib/grafana/plugins/
# if you use TDengine repo's grafana plugin submodule, use "cp -r <tdengine-extrach-dir>/connector/grafana/tdengine /var/lib/grafana/plugins/" instead of above command.
sudo service grafana-server restart
```

### Query API

Example request
``` javascript

```javascript
[{
"refId": "A",
"alias": "taosd-memory",
"sql": "select avg(mem_taosd) from sys.dn where ts > now-5m and ts < now interval(500a)"
"refId": "A",
"alias": "taosd-memory",
"sql": "select avg(mem_taosd) from sys.dn where ts > now-5m and ts < now interval(500a)"
},
{
"refId": "B",
"alias": "system-memory",
"sql": "select avg(mem_system) from sys.dn where ts > now-5m and ts < now interval(500a)"
"refId": "B",
"alias": "system-memory",
"sql": "select avg(mem_system) from sys.dn where ts > now-5m and ts < now interval(500a)"
}]
```

Example response
``` javascript

```javascript
[{
"datapoints": [
[206.488281, 1538137825000],
[206.488281, 1538137855000],
[206.488281, 1538137885500],
[210.609375, 1538137915500],
[210.867188, 1538137945500]
],
"refId": "A",
"target": "taosd-memory"
"datapoints": [
[206.488281, 1538137825000],
[206.488281, 1538137855000],
[206.488281, 1538137885500],
[210.609375, 1538137915500],
[210.867188, 1538137945500]
],
"refId": "A",
"target": "taosd-memory"
},
{
"datapoints": [
[2910.218750, 1538137825000],
[2912.265625, 1538137855000],
[2912.437500, 1538137885500],
[2916.644531, 1538137915500],
[2917.066406, 1538137945500]
],
"refId": "B",
"target": "system-memory"
"datapoints": [
[2910.218750, 1538137825000],
[2912.265625, 1538137855000],
[2912.437500, 1538137885500],
[2916.644531, 1538137915500],
[2917.066406, 1538137945500]
],
"refId": "B",
"target": "system-memory"
}]
```

### Heartbeat API

Example request
``` javascript

```javascript
Get request /heartbeat
```

Example response
``` javascript

```javascript
{
"message": "Grafana server receive a quest from you!"
"message": "Grafana server receive a quest from you!"
}
```

### Dev setup

This plugin requires node 6.10.0

``` javascript
```javascript

npm install -g yarn
yarn install
npm run build

```

### Import Dashboard

after login `http://localhost:3000 `, then you can import the tdengine demo dashboard to monitor the system metrics.
after login `http://localhost:3000` , then you can import the tdengine demo dashboard to monitor the system metrics.

you can import the `dashboard/tdengine-grafana.json`:
you can import the `dashboard/tdengine-grafana.json`:

![import_dashboard](dashboard/import_dashboard.png)
![import_dashboard](https://raw.githubusercontent/taosdata/grafanaplugin/master/dashboard/import_dashboard.png)

after finished import:

![import_dashboard](dashboard/tdengine_dashboard.png)
![import_dashboard](https://raw.githubusercontent/taosdata/grafanaplugin/master/dashboard/tdengine_dashboard.png)
4 changes: 2 additions & 2 deletions dist/partials/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h3 class="page-heading">TDengine Connection</h3>
<div class="gf-form-group">
<div class="gf-form max-width-30">
<span class="gf-form-label width-7">Host</span>
<input type="text" class="gf-form-input" ng-model='ctrl.current.url' placeholder="http://localhost:6020" bs-typeahead="{{['http://localhost:6020']}}" required></input>
<input type="text" class="gf-form-input" ng-model='ctrl.current.url' placeholder="http://localhost:6041" bs-typeahead="{{['http://localhost:6041']}}" required></input>
</div>

<div class="gf-form-inline">
Expand All @@ -16,4 +16,4 @@ <h3 class="page-heading">TDengine Connection</h3>
<input type="password" class="gf-form-input" ng-model='ctrl.current.jsonData.password' placeholder="taosdata"></input>
</div>
</div>
</div>
</div>
Loading

0 comments on commit 32e2c97

Please sign in to comment.