mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
began work on ES annotation datasource, #201
This commit is contained in:
parent
a1772d26b5
commit
4e47447dec
@ -12,8 +12,6 @@ function (angular, _, moment) {
|
|||||||
module.controller('dashLoader', function($scope, $rootScope, $http, alertSrv, $location, playlistSrv, elastic) {
|
module.controller('dashLoader', function($scope, $rootScope, $http, alertSrv, $location, playlistSrv, elastic) {
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
$scope.elasticsearch = $scope.elasticsearch || {};
|
|
||||||
|
|
||||||
$scope.onAppEvent('save-dashboard', function() {
|
$scope.onAppEvent('save-dashboard', function() {
|
||||||
$scope.saveDashboard();
|
$scope.saveDashboard();
|
||||||
});
|
});
|
||||||
@ -35,10 +33,10 @@ function (angular, _, moment) {
|
|||||||
|
|
||||||
var _l = $scope.dashboard.loader;
|
var _l = $scope.dashboard.loader;
|
||||||
if(type === 'load') {
|
if(type === 'load') {
|
||||||
return (_l.load_elasticsearch || _l.load_gist);
|
return (_l.load_elasticsearch);
|
||||||
}
|
}
|
||||||
if(type === 'save') {
|
if(type === 'save') {
|
||||||
return (_l.save_elasticsearch || _l.save_gist);
|
return (_l.save_elasticsearch);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -66,13 +66,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"loader": {
|
"loader": {
|
||||||
"save_gist": false,
|
|
||||||
"save_elasticsearch": true,
|
"save_elasticsearch": true,
|
||||||
"save_default": true,
|
"save_default": true,
|
||||||
"save_temp": true,
|
"save_temp": true,
|
||||||
"save_temp_ttl_enable": true,
|
"save_temp_ttl_enable": true,
|
||||||
"save_temp_ttl": "30d",
|
"save_temp_ttl": "30d",
|
||||||
"load_gist": false,
|
|
||||||
"load_elasticsearch": true,
|
"load_elasticsearch": true,
|
||||||
"load_elasticsearch_size": 20,
|
"load_elasticsearch_size": 20,
|
||||||
"hide": false
|
"hide": false
|
||||||
|
@ -167,7 +167,6 @@ function (angular, $, kbn, moment, _) {
|
|||||||
// if legend is to the right delay plot draw a few milliseconds
|
// if legend is to the right delay plot draw a few milliseconds
|
||||||
// so the legend width calculation can be done
|
// so the legend width calculation can be done
|
||||||
if (shouldDelayDraw(panel)) {
|
if (shouldDelayDraw(panel)) {
|
||||||
console.log('delay');
|
|
||||||
legendSideLastValue = panel.legend.rightSide;
|
legendSideLastValue = panel.legend.rightSide;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
plot = $.plot(elem, data, options);
|
plot = $.plot(elem, data, options);
|
||||||
|
@ -56,12 +56,7 @@ function (angular, app, _) {
|
|||||||
$scope.add = function() {
|
$scope.add = function() {
|
||||||
$scope.currentAnnotation.datasource = $scope.currentDatasource.name;
|
$scope.currentAnnotation.datasource = $scope.currentDatasource.name;
|
||||||
$scope.panel.annotations.push($scope.currentAnnotation);
|
$scope.panel.annotations.push($scope.currentAnnotation);
|
||||||
$scope.currentAnnnotation = angular.copy(annotationDefaults);
|
$scope.currentAnnotation = angular.copy(annotationDefaults);
|
||||||
};
|
|
||||||
|
|
||||||
$scope.hide = function (annotation) {
|
|
||||||
annotation.enable = !annotation.enable;
|
|
||||||
$rootScope.$broadcast('refresh');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
1
src/app/partials/elasticsearch/annotation_editor.html
Normal file
1
src/app/partials/elasticsearch/annotation_editor.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<h2>Elasticsearch</h2>
|
@ -5,13 +5,14 @@ define([
|
|||||||
'./graphite/graphiteDatasource',
|
'./graphite/graphiteDatasource',
|
||||||
'./influxdb/influxdbDatasource',
|
'./influxdb/influxdbDatasource',
|
||||||
'./opentsdb/opentsdbDatasource',
|
'./opentsdb/opentsdbDatasource',
|
||||||
|
'./elasticsearch/es-datasource',
|
||||||
],
|
],
|
||||||
function (angular, _, config) {
|
function (angular, _, config) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var module = angular.module('grafana.services');
|
var module = angular.module('grafana.services');
|
||||||
|
|
||||||
module.service('datasourceSrv', function($q, filterSrv, $http, GraphiteDatasource, InfluxDatasource, OpenTSDBDatasource) {
|
module.service('datasourceSrv', function($q, filterSrv, $http, $injector) {
|
||||||
var datasources = {};
|
var datasources = {};
|
||||||
|
|
||||||
this.init = function() {
|
this.init = function() {
|
||||||
@ -29,14 +30,22 @@ function (angular, _, config) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.datasourceFactory = function(ds) {
|
this.datasourceFactory = function(ds) {
|
||||||
|
var Datasource = null;
|
||||||
switch(ds.type) {
|
switch(ds.type) {
|
||||||
case 'graphite':
|
case 'graphite':
|
||||||
return new GraphiteDatasource(ds);
|
Datasource = $injector.get('GraphiteDatasource');
|
||||||
|
break;
|
||||||
case 'influxdb':
|
case 'influxdb':
|
||||||
return new InfluxDatasource(ds);
|
Datasource = $injector.get('InfluxDatasource');
|
||||||
|
break;
|
||||||
case 'opentsdb':
|
case 'opentsdb':
|
||||||
return new OpenTSDBDatasource(ds);
|
Datasource = $injector.get('OpenTSDBDatasource');
|
||||||
|
break;
|
||||||
|
case 'elasticsearch':
|
||||||
|
Datasource = $injector.get('ElasticDatasource');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return new Datasource(ds);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.get = function(name) {
|
this.get = function(name) {
|
||||||
|
32
src/app/services/elasticsearch/es-datasource.js
Normal file
32
src/app/services/elasticsearch/es-datasource.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
define([
|
||||||
|
'angular',
|
||||||
|
'underscore',
|
||||||
|
'jquery',
|
||||||
|
'config',
|
||||||
|
'kbn',
|
||||||
|
'moment'
|
||||||
|
],
|
||||||
|
function (angular, _, $, config, kbn, moment) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var module = angular.module('grafana.services');
|
||||||
|
|
||||||
|
module.factory('ElasticDatasource', function($q, $http) {
|
||||||
|
|
||||||
|
function ElasticDatasource(datasource) {
|
||||||
|
this.type = 'elastic';
|
||||||
|
this.basicAuth = datasource.basicAuth;
|
||||||
|
this.url = datasource.url;
|
||||||
|
this.name = datasource.name;
|
||||||
|
this.supportAnnotations = true;
|
||||||
|
this.annotationEditorSrc = 'app/partials/elasticsearch/annotation_editor.html';
|
||||||
|
}
|
||||||
|
|
||||||
|
ElasticDatasource.prototype.annotationQuery = function(annotation, filterSrv, rangeUnparsed) {
|
||||||
|
};
|
||||||
|
|
||||||
|
return ElasticDatasource;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user