Commit c6bcf13d by Torkel Ödegaard Committed by GitHub

Devenv testdata dashboards (#12615)

* devenv: working on dev env setup & dashboards

* devenv: refactored testdata app to a built in datasource instead, and moved dashboards to a devenv provisioned dashboards
parent a13b4f2b
...@@ -14,6 +14,9 @@ datasources: ...@@ -14,6 +14,9 @@ datasources:
isDefault: true isDefault: true
url: http://localhost:9090 url: http://localhost:9090
- name: gdev-testdata
type: testdata
- name: gdev-influxdb - name: gdev-influxdb
type: influxdb type: influxdb
access: proxy access: proxy
......
{ {
"revision": 2, "revision": 2,
"title": "TestData - Alerts", "title": "Alerting with TestData",
"tags": [ "tags": [
"grafana-test" "grafana-test"
], ],
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
}, },
"aliasColors": {}, "aliasColors": {},
"bars": false, "bars": false,
"datasource": "Grafana TestData", "datasource": "gdev-testdata",
"editable": true, "editable": true,
"error": false, "error": false,
"fill": 1, "fill": 1,
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
}, },
"aliasColors": {}, "aliasColors": {},
"bars": false, "bars": false,
"datasource": "Grafana TestData", "datasource": "gdev-testdata",
"editable": true, "editable": true,
"error": false, "error": false,
"fill": 1, "fill": 1,
......
#/bin/bash #!/bin/bash
bulkDashboard() { bulkDashboard() {
...@@ -22,31 +22,37 @@ requiresJsonnet() { ...@@ -22,31 +22,37 @@ requiresJsonnet() {
fi fi
} }
defaultDashboards() { devDashboards() {
echo -e "\xE2\x9C\x94 Setting up all dev dashboards using provisioning"
ln -s -f ../../../devenv/dashboards.yaml ../conf/provisioning/dashboards/dev.yaml ln -s -f ../../../devenv/dashboards.yaml ../conf/provisioning/dashboards/dev.yaml
} }
defaultDatasources() { devDatasources() {
echo "setting up all default datasources using provisioning" echo -e "\xE2\x9C\x94 Setting up all dev datasources using provisioning"
ln -s -f ../../../devenv/datasources.yaml ../conf/provisioning/datasources/dev.yaml ln -s -f ../../../devenv/datasources.yaml ../conf/provisioning/datasources/dev.yaml
} }
usage() { usage() {
echo -e "install.sh\n\tThis script setups dev provision for datasources and dashboards" echo -e "\n"
echo "Usage:" echo "Usage:"
echo " bulk-dashboards - create and provisioning 400 dashboards" echo " bulk-dashboards - create and provisioning 400 dashboards"
echo " no args - provisiong core datasources and dev dashboards" echo " no args - provisiong core datasources and dev dashboards"
} }
main() { main() {
echo -e "------------------------------------------------------------------"
echo -e "This script setups provisioning for dev datasources and dashboards"
echo -e "------------------------------------------------------------------"
echo -e "\n"
local cmd=$1 local cmd=$1
if [[ $cmd == "bulk-dashboards" ]]; then if [[ $cmd == "bulk-dashboards" ]]; then
bulkDashboard bulkDashboard
else else
defaultDashboards devDashboards
defaultDatasources devDatasources
fi fi
if [[ -z "$cmd" ]]; then if [[ -z "$cmd" ]]; then
......
...@@ -21,7 +21,7 @@ func NewTestDataExecutor(dsInfo *models.DataSource) (tsdb.TsdbQueryEndpoint, err ...@@ -21,7 +21,7 @@ func NewTestDataExecutor(dsInfo *models.DataSource) (tsdb.TsdbQueryEndpoint, err
} }
func init() { func init() {
tsdb.RegisterTsdbQueryEndpoint("grafana-testdata-datasource", NewTestDataExecutor) tsdb.RegisterTsdbQueryEndpoint("testdata", NewTestDataExecutor)
} }
func (e *TestDataExecutor) Query(ctx context.Context, dsInfo *models.DataSource, tsdbQuery *tsdb.TsdbQuery) (*tsdb.Response, error) { func (e *TestDataExecutor) Query(ctx context.Context, dsInfo *models.DataSource, tsdbQuery *tsdb.TsdbQuery) (*tsdb.Response, error) {
......
...@@ -9,6 +9,7 @@ import * as mysqlPlugin from 'app/plugins/datasource/mysql/module'; ...@@ -9,6 +9,7 @@ import * as mysqlPlugin from 'app/plugins/datasource/mysql/module';
import * as postgresPlugin from 'app/plugins/datasource/postgres/module'; import * as postgresPlugin from 'app/plugins/datasource/postgres/module';
import * as prometheusPlugin from 'app/plugins/datasource/prometheus/module'; import * as prometheusPlugin from 'app/plugins/datasource/prometheus/module';
import * as mssqlPlugin from 'app/plugins/datasource/mssql/module'; import * as mssqlPlugin from 'app/plugins/datasource/mssql/module';
import * as testDataDSPlugin from 'app/plugins/datasource/testdata/module';
import * as textPanel from 'app/plugins/panel/text/module'; import * as textPanel from 'app/plugins/panel/text/module';
import * as graphPanel from 'app/plugins/panel/graph/module'; import * as graphPanel from 'app/plugins/panel/graph/module';
...@@ -20,9 +21,6 @@ import * as tablePanel from 'app/plugins/panel/table/module'; ...@@ -20,9 +21,6 @@ import * as tablePanel from 'app/plugins/panel/table/module';
import * as singlestatPanel from 'app/plugins/panel/singlestat/module'; import * as singlestatPanel from 'app/plugins/panel/singlestat/module';
import * as gettingStartedPanel from 'app/plugins/panel/gettingstarted/module'; import * as gettingStartedPanel from 'app/plugins/panel/gettingstarted/module';
import * as testDataAppPlugin from 'app/plugins/app/testdata/module';
import * as testDataDSPlugin from 'app/plugins/app/testdata/datasource/module';
const builtInPlugins = { const builtInPlugins = {
'app/plugins/datasource/graphite/module': graphitePlugin, 'app/plugins/datasource/graphite/module': graphitePlugin,
'app/plugins/datasource/cloudwatch/module': cloudwatchPlugin, 'app/plugins/datasource/cloudwatch/module': cloudwatchPlugin,
...@@ -35,8 +33,7 @@ const builtInPlugins = { ...@@ -35,8 +33,7 @@ const builtInPlugins = {
'app/plugins/datasource/postgres/module': postgresPlugin, 'app/plugins/datasource/postgres/module': postgresPlugin,
'app/plugins/datasource/mssql/module': mssqlPlugin, 'app/plugins/datasource/mssql/module': mssqlPlugin,
'app/plugins/datasource/prometheus/module': prometheusPlugin, 'app/plugins/datasource/prometheus/module': prometheusPlugin,
'app/plugins/app/testdata/module': testDataAppPlugin, 'app/plugins/datasource/testdata/module': testDataDSPlugin,
'app/plugins/app/testdata/datasource/module': testDataDSPlugin,
'app/plugins/panel/text/module': textPanel, 'app/plugins/panel/text/module': textPanel,
'app/plugins/panel/graph/module': graphPanel, 'app/plugins/panel/graph/module': graphPanel,
......
export class ConfigCtrl {
static template = '';
appEditCtrl: any;
/** @ngInject **/
constructor(private backendSrv) {
this.appEditCtrl.setPreUpdateHook(this.initDatasource.bind(this));
}
initDatasource() {
return this.backendSrv.get('/api/datasources').then(res => {
var found = false;
for (let ds of res) {
if (ds.type === 'grafana-testdata-datasource') {
found = true;
}
}
if (!found) {
var dsInstance = {
name: 'Grafana TestData',
type: 'grafana-testdata-datasource',
access: 'direct',
jsonData: {},
};
return this.backendSrv.post('/api/datasources', dsInstance);
}
return Promise.resolve();
});
}
}
{
"type": "app",
"name": "Grafana TestData",
"id": "testdata",
"info": {
"description": "Grafana test data app",
"author": {
"name": "Grafana Project",
"url": "https://grafana.com"
},
"version": "1.0.17",
"updated": "2016-09-26"
},
"includes": [
{
"type": "dashboard",
"name": "TestData - Graph Last 1h",
"path": "dashboards/graph_last_1h.json"
},
{
"type": "dashboard",
"name": "TestData - Alerts",
"path": "dashboards/alerts.json"
}
],
"dependencies": {
"grafanaVersion": "4.x.x"
}
}
...@@ -37,4 +37,3 @@ ...@@ -37,4 +37,3 @@
</div> </div>
</div> </div>
</query-editor-row> </query-editor-row>
{ {
"type": "datasource", "type": "datasource",
"name": "Grafana TestDataDB", "name": "TestData DB",
"id": "grafana-testdata-datasource", "id": "testdata",
"metrics": true, "metrics": true,
"alerting": true, "alerting": true,
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"url": "https://grafana.com" "url": "https://grafana.com"
}, },
"logos": { "logos": {
"small": "", "small": "../../../../img/grafana_icon.svg",
"large": "" "large": "../../../../img/grafana_icon.svg"
} }
} }
} }
...@@ -56,10 +56,10 @@ ...@@ -56,10 +56,10 @@
<h5 class="section-heading">Coloring</h5> <h5 class="section-heading">Coloring</h5>
<div class="gf-form-inline"> <div class="gf-form-inline">
<gf-form-switch class="gf-form" label-class="width-8" label="Background" checked="ctrl.panel.colorBackground" on-change="ctrl.render()"></gf-form-switch> <gf-form-switch class="gf-form" label-class="width-8" label="Background" checked="ctrl.panel.colorBackground" on-change="ctrl.render()"></gf-form-switch>
<gf-form-switch class="gf-form" label-class="width-4" label="Value" checked="ctrl.panel.colorValue" on-change="ctrl.render()"></gf-form-switch> <gf-form-switch class="gf-form" label-class="width-6" label="Value" checked="ctrl.panel.colorValue" on-change="ctrl.render()"></gf-form-switch>
</div> </div>
<div class="gf-form-inline"> <div class="gf-form-inline">
<gf-form-switch class="gf-form" label-class="width-6" label="Prefix" checked="ctrl.panel.colorPrefix" on-change="ctrl.render()" ng-disabled="!ctrl.canModifyText()"></gf-form-switch> <gf-form-switch class="gf-form" label-class="width-8" label="Prefix" checked="ctrl.panel.colorPrefix" on-change="ctrl.render()" ng-disabled="!ctrl.canModifyText()"></gf-form-switch>
<gf-form-switch class="gf-form" label-class="width-6" label="Postfix" checked="ctrl.panel.colorPostfix" on-change="ctrl.render()" ng-disabled="!ctrl.canModifyText()"></gf-form-switch> <gf-form-switch class="gf-form" label-class="width-6" label="Postfix" checked="ctrl.panel.colorPostfix" on-change="ctrl.render()" ng-disabled="!ctrl.canModifyText()"></gf-form-switch>
</div> </div>
<div class="gf-form-inline"> <div class="gf-form-inline">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment