diff --git a/src/app/features/all.js b/src/app/features/all.js index 5adb048d879..2a22f0c5dd3 100644 --- a/src/app/features/all.js +++ b/src/app/features/all.js @@ -9,4 +9,5 @@ define([ './dashboard/all', './admin/accountCtrl', './admin/datasourcesCtrl', + './grafanaDatasource/datasource', ], function () {}); diff --git a/src/app/services/grafanaDatasource.js b/src/app/features/grafanaDatasource/datasource.js similarity index 76% rename from src/app/services/grafanaDatasource.js rename to src/app/features/grafanaDatasource/datasource.js index d20a221b416..6f168545b80 100644 --- a/src/app/services/grafanaDatasource.js +++ b/src/app/features/grafanaDatasource/datasource.js @@ -1,8 +1,9 @@ define([ 'angular', 'lodash', + 'kbn', ], -function (angular, _) { +function (angular, _, kbn) { 'use strict'; var module = angular.module('grafana.services'); @@ -12,6 +13,9 @@ function (angular, _) { function GrafanaDatasource() { this.type = 'grafana'; this.grafanaDB = true; + this.name = "grafana"; + this.supportMetrics = true; + this.editorSrc = 'app/features/grafanaDatasource/partials/query.editor.html'; } GrafanaDatasource.prototype.getDashboard = function(id, isTemp) { @@ -31,6 +35,14 @@ function (angular, _) { }); }; + GrafanaDatasource.prototype.query = function(options) { + // get from & to in seconds + var from = kbn.parseDate(options.range.from).getTime(); + var to = kbn.parseDate(options.range.to).getTime(); + + return backendSrv.get('/api/metrics/test', { from: from, to: to, maxDataPoints: options.maxDataPoints }); + }; + GrafanaDatasource.prototype.saveDashboard = function(dashboard) { // remove id if title has changed if (dashboard.title !== dashboard.originalTitle) { diff --git a/src/app/features/grafanaDatasource/partials/query.editor.html b/src/app/features/grafanaDatasource/partials/query.editor.html new file mode 100644 index 00000000000..032fa49e602 --- /dev/null +++ b/src/app/features/grafanaDatasource/partials/query.editor.html @@ -0,0 +1,17 @@ + +
+ This is just a test data source that generates random walk series. If this is your only data source + open the left side menu and goto data sources admin screen and add your data sources. You can change + data source using the button to the left of the Add query button. +
+