Commit 0aacb866 by Rashid Khan

Added support for hourly/daily/weekly/monthly/yearly index patterns, fixed field list bug

parent 722e40d3
...@@ -7,18 +7,14 @@ function get_object_fields(obj) { ...@@ -7,18 +7,14 @@ function get_object_fields(obj) {
return field_array.sort(); return field_array.sort();
} }
function get_all_fields(json) { function get_all_fields(data) {
var field_array = []; var fields = [];
var obj_fields; _.each(data,function(hit) {
for (hit in json.hits.hits) { fields = _.uniq(fields.concat(_.keys(hit)))
obj_fields = get_object_fields(json.hits.hits[hit]); })
for (index in obj_fields) { // Remove stupid angular key
if (_.indexOf(field_array,obj_fields[index]) < 0) { fields = _.without(fields,'$$hashKey')
field_array.push(obj_fields[index]); return fields;
}
}
}
return field_array.sort();
} }
function has_field(obj,field) { function has_field(obj,field) {
...@@ -30,39 +26,6 @@ function has_field(obj,field) { ...@@ -30,39 +26,6 @@ function has_field(obj,field) {
} }
} }
function get_objids_with_field(json,field) {
var objid_array = [];
for (hit in json.hits.hits) {
if(has_field(json.hits.hits[hit],field)) {
objid_array.push(hit);
}
}
return objid_array;
}
function get_objids_with_field_value(json,field,value) {
var objid_array = [];
for (hit in json.hits.hits) {
var hit_obj = json.hits.hits[hit];
if(has_field(hit_obj,field)) {
var field_val = get_field_value(hit_obj,field,'raw')
if(_.isArray(field_val)) {
if(_.inArray(field_val,field) >= 0) {
objid_array.push(hit);
}
} else {
if(field_val == value) {
objid_array.push(hit);
}
}
} else {
if ( value == '')
objid_array.push(hit);
}
}
return objid_array;
}
function get_related_fields(docs,field) { function get_related_fields(docs,field) {
var field_array = [] var field_array = []
_.each(docs, function(doc) { _.each(docs, function(doc) {
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<div style="height:{{panel.height || row.height}};overflow-y:auto;overflow-x:auto"> <div style="height:{{panel.height || row.height}};overflow-y:auto;overflow-x:auto">
<div class="row-fluid"> <div class="row-fluid">
<div class="span1 offset3" style="text-align:right"> <div class="span1 offset1" style="text-align:right">
<i ng-click="panel.offset = 0" ng-show="panel.offset > 0" class='icon-circle-arrow-left pointer'></i> <i ng-click="panel.offset = 0" ng-show="panel.offset > 0" class='icon-circle-arrow-left pointer'></i>
<i ng-click="panel.offset = (panel.offset - panel.size)" ng-show="panel.offset > 0" class='icon-arrow-left pointer'></i> <i ng-click="panel.offset = (panel.offset - panel.size)" ng-show="panel.offset > 0" class='icon-arrow-left pointer'></i>
</div> </div>
<div class="span4" style="text-align:center"> <div class="span8" style="text-align:center">
<strong>{{panel.offset}}</strong> to <strong>{{panel.offset + data.slice(panel.offset,panel.offset+panel.size).length}}</strong> <strong>{{panel.offset}}</strong> to <strong>{{panel.offset + data.slice(panel.offset,panel.offset+panel.size).length}}</strong>
<small> of {{data.length}} available for paging</small> <small> of {{data.length}} available for paging</small>
</div> </div>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<th>Action</th> <th>Action</th>
<th>Value</th> <th>Value</th>
</thead> </thead>
<tr ng-repeat="(key,value) in row.kibana.details"> <tr ng-repeat="(key,value) in row.kibana.details" ng-class-odd="'odd'">
<td>{{key}}</td> <td>{{key}}</td>
<td> <td>
<i class='icon-search pointer' ng-click="build_search(key,value)"></i> <i class='icon-search pointer' ng-click="build_search(key,value)"></i>
......
...@@ -83,6 +83,7 @@ angular.module('kibana.table', []) ...@@ -83,6 +83,7 @@ angular.module('kibana.table', [])
$scope.panel.loading = true; $scope.panel.loading = true;
var _segment = _.isUndefined(segment) ? 0 : segment var _segment = _.isUndefined(segment) ? 0 : segment
$scope.segment = _segment;
var request = $scope.ejs.Request().indices($scope.panel.index[_segment]) var request = $scope.ejs.Request().indices($scope.panel.index[_segment])
.query(ejs.FilteredQuery( .query(ejs.FilteredQuery(
...@@ -139,7 +140,7 @@ angular.module('kibana.table', []) ...@@ -139,7 +140,7 @@ angular.module('kibana.table', [])
} }
// This breaks, use $scope.data for this // This breaks, use $scope.data for this
$scope.all_fields = get_all_fields(results); $scope.all_fields = get_all_fields($scope.data);
broadcast_results(); broadcast_results();
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<h5>Index Settings</h5> <h5>Index Settings</h5>
<div ng-show="panel.timed_indices" class="row-fluid"> <div ng-show="panel.index_interval != 'none'" class="row-fluid">
<div class="span12"> <div class="span12">
<p class="small"> <p class="small">
Time stamped indices use your selected time range to create a list of Time stamped indices use your selected time range to create a list of
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<div class="span2"> <div class="span2">
<h6>Timestamped</h6><input type="checkbox" ng-model="panel.timed_indices" ng-checked="panel.timed_indices"> <h6>Timestamp</h6><select class="input-mini" ng-model="panel.index_interval" ng-options='f for f in ["none","hour","day","week","month","year"]'></select>
</div> </div>
<div class="span5"> <div class="span5">
<h6>Index <span ng-show="panel.timed_indices">pattern</span> <small ng-show="panel.timed_indices">Absolutes in double quotes</small></h6> <h6>Index <span ng-show="panel.index_interval != 'none'">pattern <small>Absolutes in double quotes</small></span></h6>
<input type="text" class="input-medium" ng-model="panel.index"> <input type="text" class="input-medium" ng-model="panel.index">
</div> </div>
<div class="span4"> <div class="span4">
......
...@@ -11,7 +11,6 @@ a pattern ...@@ -11,7 +11,6 @@ a pattern
* timespan :: The default options selected for the relative view. Default: '15m' * timespan :: The default options selected for the relative view. Default: '15m'
* timefield :: The field in which time is stored in the document. * timefield :: The field in which time is stored in the document.
* index :: Index pattern to match. Literals should be double quoted. Default: '_all' * index :: Index pattern to match. Literals should be double quoted. Default: '_all'
* timed_indices :: Should kibana generate a list of indices to try based on selected time range?
* defaultindex :: Index to failover to if index not found * defaultindex :: Index to failover to if index not found
* refresh: Object containing refresh parameters * refresh: Object containing refresh parameters
* enable :: true/false, enable auto refresh by default. Default: false * enable :: true/false, enable auto refresh by default. Default: false
...@@ -37,7 +36,6 @@ angular.module('kibana.timepicker', []) ...@@ -37,7 +36,6 @@ angular.module('kibana.timepicker', [])
index : '_all', index : '_all',
defaultindex : "_all", defaultindex : "_all",
index_interval: "day", index_interval: "day",
timed_indices : false,
group : "default", group : "default",
refresh : { refresh : {
enable : false, enable : false,
...@@ -205,7 +203,7 @@ angular.module('kibana.timepicker', []) ...@@ -205,7 +203,7 @@ angular.module('kibana.timepicker', [])
// Get indices for the time period, then broadcast time range and index list // Get indices for the time period, then broadcast time range and index list
// in a single object. Not sure if I like this. // in a single object. Not sure if I like this.
if($scope.panel.timed_indices) { if($scope.panel.index_interval !== 'none') {
indices($scope.time.from,$scope.time.to).then(function (p) { indices($scope.time.from,$scope.time.to).then(function (p) {
$scope.time.index = p; $scope.time.index = p;
eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time) eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time)
......
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