Commit 4deca04e by Rashid Khan

Merge pull request #220 from rashidkpc/master

Fix for trend panel and stacked bars on default dashboard
parents fdb34928 2d542aed
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
"spyable": true, "spyable": true,
"zoomlinks": true, "zoomlinks": true,
"bars": true, "bars": true,
"stack": false, "stack": true,
"points": false, "points": false,
"lines": false, "lines": false,
"legend": true, "legend": true,
...@@ -266,4 +266,4 @@ ...@@ -266,4 +266,4 @@
"pattern": "[logstash-]YYYY.MM.DD", "pattern": "[logstash-]YYYY.MM.DD",
"default": "logstash-*" "default": "logstash-*"
} }
} }
\ No newline at end of file
...@@ -48,9 +48,22 @@ angular.module('kibana.trends', []) ...@@ -48,9 +48,22 @@ angular.module('kibana.trends', [])
if(dashboard.indices.length == 0) { if(dashboard.indices.length == 0) {
return return
} else { } else {
$scope.index = dashboard.indices $scope.index = segment > 0 ? $scope.index : dashboard.indices;
} }
// Determine a time field
var timeField = _.uniq(_.pluck(filterSrv.getByType('time'),'field'))
if(timeField.length > 1) {
$scope.panel.error = "Time field must be consistent amongst time filters"
return
} else if(timeField.length == 0) {
$scope.panel.error = "A time filter must exist for this panel to function"
return
} else {
timeField = timeField[0]
}
$scope.time = filterSrv.timeRange('min');
$scope.old_time = { $scope.old_time = {
from : new Date($scope.time.from.getTime() - interval_to_seconds($scope.panel.ago)*1000), from : new Date($scope.time.from.getTime() - interval_to_seconds($scope.panel.ago)*1000),
to : new Date($scope.time.to.getTime() - interval_to_seconds($scope.panel.ago)*1000) to : new Date($scope.time.to.getTime() - interval_to_seconds($scope.panel.ago)*1000)
...@@ -58,12 +71,18 @@ angular.module('kibana.trends', []) ...@@ -58,12 +71,18 @@ angular.module('kibana.trends', [])
var _segment = _.isUndefined(segment) ? 0 : segment var _segment = _.isUndefined(segment) ? 0 : segment
var request = $scope.ejs.Request(); var request = $scope.ejs.Request();
var _ids_without_time = _.difference(filterSrv.ids,filterSrv.idsByType('time'))
// Build the question part of the query // Build the question part of the query
_.each(query.ids, function(id) { _.each(query.ids, function(id) {
var q = $scope.ejs.FilteredQuery( var q = $scope.ejs.FilteredQuery(
ejs.QueryStringQuery(query.list[id].query || '*'), ejs.QueryStringQuery(query.list[id].query || '*'),
filterSrv.getBoolFilter(filterSrv.ids)) filterSrv.getBoolFilter(_ids_without_time).must(
ejs.RangeFilter(timeField)
.from($scope.time.from)
.to($scope.time.to)
))
request = request request = request
.facet($scope.ejs.QueryFacet(id) .facet($scope.ejs.QueryFacet(id)
...@@ -75,9 +94,11 @@ angular.module('kibana.trends', []) ...@@ -75,9 +94,11 @@ angular.module('kibana.trends', [])
_.each(query.ids, function(id) { _.each(query.ids, function(id) {
var q = $scope.ejs.FilteredQuery( var q = $scope.ejs.FilteredQuery(
ejs.QueryStringQuery(query.list[id].query || '*'), ejs.QueryStringQuery(query.list[id].query || '*'),
ejs.RangeFilter($scope.time.field) filterSrv.getBoolFilter(_ids_without_time).must(
ejs.RangeFilter(timeField)
.from($scope.old_time.from) .from($scope.old_time.from)
.to($scope.old_time.to)) .to($scope.old_time.to)
))
request = request request = request
.facet($scope.ejs.QueryFacet("old_"+id) .facet($scope.ejs.QueryFacet("old_"+id)
.query(q) .query(q)
...@@ -92,11 +113,13 @@ angular.module('kibana.trends', []) ...@@ -92,11 +113,13 @@ angular.module('kibana.trends', [])
kbnIndex.indices( kbnIndex.indices(
$scope.old_time.from, $scope.old_time.from,
$scope.old_time.to, $scope.old_time.to,
$scope.time.pattern, dashboard.current.index.pattern,
$scope.time.interval dashboard.current.index.interval
).then(function (p) { ).then(function (p) {
$scope.index = _.union(p,$scope.index); $scope.index = _.union(p,$scope.index);
process_results(request.indices($scope.index[_segment]).doSearch()); request = request.indices($scope.index[_segment])
process_results(request.doSearch());
}); });
} else { } else {
process_results(request.indices($scope.index[_segment]).doSearch()); process_results(request.indices($scope.index[_segment]).doSearch());
......
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