|
@@ -23,6 +23,8 @@ angular.module('kibana.histogram', [])
|
|
|
|
|
|
|
|
$scope.init = function() {
|
|
$scope.init = function() {
|
|
|
eventBus.register($scope,'time', function(event,time){$scope.set_time(time)});
|
|
eventBus.register($scope,'time', function(event,time){$scope.set_time(time)});
|
|
|
|
|
+
|
|
|
|
|
+ // Consider eliminating the check for array, this should always be an array
|
|
|
eventBus.register($scope,'query', function(event, query) {
|
|
eventBus.register($scope,'query', function(event, query) {
|
|
|
if(_.isArray(query)) {
|
|
if(_.isArray(query)) {
|
|
|
$scope.panel.query = _.map(query,function(q) {
|
|
$scope.panel.query = _.map(query,function(q) {
|
|
@@ -33,6 +35,7 @@ angular.module('kibana.histogram', [])
|
|
|
}
|
|
}
|
|
|
$scope.get_data();
|
|
$scope.get_data();
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
// Now that we're all setup, request the time from our group if we don't
|
|
// Now that we're all setup, request the time from our group if we don't
|
|
|
// have it yet
|
|
// have it yet
|
|
|
if(_.isUndefined($scope.time))
|
|
if(_.isUndefined($scope.time))
|
|
@@ -60,9 +63,8 @@ angular.module('kibana.histogram', [])
|
|
|
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
|
|
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
- var _segment = _.isUndefined(segment) ? 0 : segment
|
|
|
|
|
-
|
|
|
|
|
$scope.panel.loading = true;
|
|
$scope.panel.loading = true;
|
|
|
|
|
+ var _segment = _.isUndefined(segment) ? 0 : segment
|
|
|
var request = $scope.ejs.Request().indices($scope.panel.index[_segment]);
|
|
var request = $scope.ejs.Request().indices($scope.panel.index[_segment]);
|
|
|
|
|
|
|
|
// Build the question part of the query
|
|
// Build the question part of the query
|
|
@@ -76,7 +78,7 @@ angular.module('kibana.histogram', [])
|
|
|
)
|
|
)
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // Build the facet part
|
|
|
|
|
|
|
+ // Build the facet part, injecting the query in as a facet filter
|
|
|
_.each(queries, function(v) {
|
|
_.each(queries, function(v) {
|
|
|
request = request
|
|
request = request
|
|
|
.facet($scope.ejs.DateHistogramFacet("chart"+_.indexOf(queries,v))
|
|
.facet($scope.ejs.DateHistogramFacet("chart"+_.indexOf(queries,v))
|
|
@@ -86,6 +88,7 @@ angular.module('kibana.histogram', [])
|
|
|
).size(0)
|
|
).size(0)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ // Populate the inspector panel
|
|
|
$scope.populate_modal(request);
|
|
$scope.populate_modal(request);
|
|
|
|
|
|
|
|
// Then run it
|
|
// Then run it
|
|
@@ -106,17 +109,11 @@ angular.module('kibana.histogram', [])
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // Make sure we're still on the same query
|
|
|
if($scope.query_id === query_id) {
|
|
if($scope.query_id === query_id) {
|
|
|
|
|
|
|
|
var i = 0;
|
|
var i = 0;
|
|
|
_.each(results.facets, function(v, k) {
|
|
_.each(results.facets, function(v, k) {
|
|
|
- // If this isn't a date histogram it must be a QueryFacet, get the
|
|
|
|
|
- // count and return
|
|
|
|
|
- if(v._type !== 'date_histogram') {
|
|
|
|
|
- //$scope.hits += v.count;
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// Null values at each end of the time range ensure we see entire range
|
|
// Null values at each end of the time range ensure we see entire range
|
|
|
if(_.isUndefined($scope.data[i]) || _segment == 0) {
|
|
if(_.isUndefined($scope.data[i]) || _segment == 0) {
|
|
@@ -131,14 +128,14 @@ angular.module('kibana.histogram', [])
|
|
|
var segment_data = [];
|
|
var segment_data = [];
|
|
|
_.each(v.entries, function(v, k) {
|
|
_.each(v.entries, function(v, k) {
|
|
|
segment_data.push([v['time'],v['count']])
|
|
segment_data.push([v['time'],v['count']])
|
|
|
- hits += v['count'];
|
|
|
|
|
- $scope.hits += v['count'];
|
|
|
|
|
|
|
+ hits += v['count']; // The series level hits counter
|
|
|
|
|
+ $scope.hits += v['count']; // Entire dataset level hits counter
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- data.splice.apply(data,[1,0].concat(segment_data))
|
|
|
|
|
|
|
+ data.splice.apply(data,[1,0].concat(segment_data)) // Join histogram data
|
|
|
|
|
|
|
|
|
|
|
|
|
- // Create the flot series
|
|
|
|
|
|
|
+ // Create the flot series object
|
|
|
var series = {
|
|
var series = {
|
|
|
data: {
|
|
data: {
|
|
|
label: $scope.panel.query[i].label || "query"+(parseInt(i)+1),
|
|
label: $scope.panel.query[i].label || "query"+(parseInt(i)+1),
|
|
@@ -155,7 +152,10 @@ angular.module('kibana.histogram', [])
|
|
|
i++;
|
|
i++;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // Tell the histogram directive to render.
|
|
|
$scope.$emit('render')
|
|
$scope.$emit('render')
|
|
|
|
|
+
|
|
|
|
|
+ // If we still have segments left, get them
|
|
|
if(_segment < $scope.panel.index.length-1) {
|
|
if(_segment < $scope.panel.index.length-1) {
|
|
|
$scope.get_data(_segment+1,query_id)
|
|
$scope.get_data(_segment+1,query_id)
|
|
|
}
|
|
}
|
|
@@ -209,8 +209,6 @@ angular.module('kibana.histogram', [])
|
|
|
|
|
|
|
|
// Function for rendering panel
|
|
// Function for rendering panel
|
|
|
function render_panel() {
|
|
function render_panel() {
|
|
|
- // Determine format
|
|
|
|
|
-
|
|
|
|
|
// Set barwidth based on specified interval
|
|
// Set barwidth based on specified interval
|
|
|
var barwidth = interval_to_seconds(scope.panel.interval)*1000
|
|
var barwidth = interval_to_seconds(scope.panel.interval)*1000
|
|
|
|
|
|
|
@@ -226,10 +224,8 @@ angular.module('kibana.histogram', [])
|
|
|
|
|
|
|
|
// Populate element
|
|
// Populate element
|
|
|
try {
|
|
try {
|
|
|
- var plot = $.plot(elem, scope.data, {
|
|
|
|
|
- legend: {
|
|
|
|
|
- show: false,
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ scope.plot = $.plot(elem, scope.data, {
|
|
|
|
|
+ legend: { show: false },
|
|
|
series: {
|
|
series: {
|
|
|
stack: stack,
|
|
stack: stack,
|
|
|
lines: {
|
|
lines: {
|
|
@@ -264,11 +260,6 @@ angular.module('kibana.histogram', [])
|
|
|
},
|
|
},
|
|
|
colors: ['#EB6841','#00A0B0','#6A4A3C','#EDC951','#CC333F']
|
|
colors: ['#EB6841','#00A0B0','#6A4A3C','#EDC951','#CC333F']
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
- scope.legend = [];
|
|
|
|
|
- _.each(plot.getData(),function(series) {
|
|
|
|
|
- scope.legend.push(_.pick(series,'label','color','hits'))
|
|
|
|
|
- })
|
|
|
|
|
|
|
|
|
|
// Work around for missing legend at initialization
|
|
// Work around for missing legend at initialization
|
|
|
if(!scope.$$phase)
|
|
if(!scope.$$phase)
|