mirror of
https://github.com/grafana/grafana.git
synced 2025-01-01 11:47:05 -06:00
Added support for hourly/daily/weekly/monthly/yearly index patterns, fixed field list bug
This commit is contained in:
parent
722e40d35e
commit
0aacb86688
@ -7,18 +7,14 @@ function get_object_fields(obj) {
|
||||
return field_array.sort();
|
||||
}
|
||||
|
||||
function get_all_fields(json) {
|
||||
var field_array = [];
|
||||
var obj_fields;
|
||||
for (hit in json.hits.hits) {
|
||||
obj_fields = get_object_fields(json.hits.hits[hit]);
|
||||
for (index in obj_fields) {
|
||||
if (_.indexOf(field_array,obj_fields[index]) < 0) {
|
||||
field_array.push(obj_fields[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return field_array.sort();
|
||||
function get_all_fields(data) {
|
||||
var fields = [];
|
||||
_.each(data,function(hit) {
|
||||
fields = _.uniq(fields.concat(_.keys(hit)))
|
||||
})
|
||||
// Remove stupid angular key
|
||||
fields = _.without(fields,'$$hashKey')
|
||||
return fields;
|
||||
}
|
||||
|
||||
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) {
|
||||
var field_array = []
|
||||
_.each(docs, function(doc) {
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
<div style="height:{{panel.height || row.height}};overflow-y:auto;overflow-x:auto">
|
||||
<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 = (panel.offset - panel.size)" ng-show="panel.offset > 0" class='icon-arrow-left pointer'></i>
|
||||
</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>
|
||||
<small> of {{data.length}} available for paging</small>
|
||||
</div>
|
||||
@ -41,7 +41,7 @@
|
||||
<th>Action</th>
|
||||
<th>Value</th>
|
||||
</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>
|
||||
<i class='icon-search pointer' ng-click="build_search(key,value)"></i>
|
||||
|
@ -83,6 +83,7 @@ angular.module('kibana.table', [])
|
||||
$scope.panel.loading = true;
|
||||
|
||||
var _segment = _.isUndefined(segment) ? 0 : segment
|
||||
$scope.segment = _segment;
|
||||
|
||||
var request = $scope.ejs.Request().indices($scope.panel.index[_segment])
|
||||
.query(ejs.FilteredQuery(
|
||||
@ -139,8 +140,8 @@ angular.module('kibana.table', [])
|
||||
}
|
||||
|
||||
// This breaks, use $scope.data for this
|
||||
$scope.all_fields = get_all_fields(results);
|
||||
|
||||
$scope.all_fields = get_all_fields($scope.data);
|
||||
|
||||
broadcast_results();
|
||||
|
||||
// If we're not sorting in reverse chrono order, query every index for
|
||||
|
@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<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">
|
||||
<p class="small">
|
||||
Time stamped indices use your selected time range to create a list of
|
||||
@ -30,10 +30,10 @@
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<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 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">
|
||||
</div>
|
||||
<div class="span4">
|
||||
|
@ -11,7 +11,6 @@ a pattern
|
||||
* timespan :: The default options selected for the relative view. Default: '15m'
|
||||
* timefield :: The field in which time is stored in the document.
|
||||
* 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
|
||||
* refresh: Object containing refresh parameters
|
||||
* enable :: true/false, enable auto refresh by default. Default: false
|
||||
@ -37,7 +36,6 @@ angular.module('kibana.timepicker', [])
|
||||
index : '_all',
|
||||
defaultindex : "_all",
|
||||
index_interval: "day",
|
||||
timed_indices : false,
|
||||
group : "default",
|
||||
refresh : {
|
||||
enable : false,
|
||||
@ -205,7 +203,7 @@ angular.module('kibana.timepicker', [])
|
||||
|
||||
// Get indices for the time period, then broadcast time range and index list
|
||||
// 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) {
|
||||
$scope.time.index = p;
|
||||
eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time)
|
||||
|
Loading…
Reference in New Issue
Block a user