Commit ebb38b5e by Rashid Khan

Added elasticsearch _ fields to table, eg _id, _index, _type

parent a6d1bdaa
...@@ -49,7 +49,7 @@ define(['angular', 'jquery', 'underscore', 'moment'], function (angular, $, _, m ...@@ -49,7 +49,7 @@ define(['angular', 'jquery', 'underscore', 'moment'], function (angular, $, _, m
if(_.isObject(arr) && !_.isArray(arr)) { if(_.isObject(arr) && !_.isArray(arr)) {
return angular.toJson(arr); return angular.toJson(arr);
} else { } else {
return arr.toString(); return _.isNull(arr) ? null : arr.toString();
} }
}; };
}); });
......
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
<ul class="unstyled" style="{{panel.overflow}}:{{panel.height || row.height}};overflow-y:auto;overflow-x:hidden;"> <ul class="unstyled" style="{{panel.overflow}}:{{panel.height || row.height}};overflow-y:auto;overflow-x:hidden;">
<li ng-style="panel.style" ng-repeat="field in metaFields|filter:fieldFilter|orderBy:identity">
<i class="pointer" ng-class="{'icon-check': _.contains(panel.fields,field),'icon-check-empty': !_.contains(panel.fields,field)}" ng-click="toggle_field(field)"></i>
<a class="pointer" data-unique="1" bs-popover="'app/panels/table/micropanel.html'" data-placement="rightTop" ng-click="toggle_micropanel(field,true)" ng-class="{label: _.contains(panel.fields,field)}">{{field}}</a>
</li>
<li ng-style="panel.style" ng-repeat="field in fields.list|filter:fieldFilter|orderBy:identity" ng-show="panel.all_fields"> <li ng-style="panel.style" ng-repeat="field in fields.list|filter:fieldFilter|orderBy:identity" ng-show="panel.all_fields">
<i class="pointer" ng-class="{'icon-check': _.contains(panel.fields,field),'icon-check-empty': !_.contains(panel.fields,field)}" ng-click="toggle_field(field)"></i> <i class="pointer" ng-class="{'icon-check': _.contains(panel.fields,field),'icon-check-empty': !_.contains(panel.fields,field)}" ng-click="toggle_field(field)"></i>
<a class="pointer" data-unique="1" bs-popover="'app/panels/table/micropanel.html'" data-placement="rightTop" ng-click="toggle_micropanel(field,true)" ng-class="{label: _.contains(panel.fields,field)}">{{field}}</a> <a class="pointer" data-unique="1" bs-popover="'app/panels/table/micropanel.html'" data-placement="rightTop" ng-click="toggle_micropanel(field,true)" ng-class="{label: _.contains(panel.fields,field)}">{{field}}</a>
...@@ -62,7 +67,7 @@ ...@@ -62,7 +67,7 @@
</thead> </thead>
<tbody ng-repeat="event in data| slice:panel.offset:panel.offset+panel.size" ng-class-odd="'odd'"> <tbody ng-repeat="event in data| slice:panel.offset:panel.offset+panel.size" ng-class-odd="'odd'">
<tr ng-click="toggle_details(event)" class="pointer"> <tr ng-click="toggle_details(event)" class="pointer">
<td ng-show="panel.fields.length<1">{{event._source|stringify|tableTruncate:panel.trimFactor:1}}</td> <td ng-show="panel.fields.length<1">{{event.kibana._source|stringify|tableTruncate:panel.trimFactor:1}}</td>
<td ng-show="panel.fields.length>0" ng-repeat="field in panel.fields" ng-bind-html-unsafe="(event.kibana.highlight[field]||event.kibana._source[field]) |tableHighlight | tableTruncate:panel.trimFactor:panel.fields.length"></td> <td ng-show="panel.fields.length>0" ng-repeat="field in panel.fields" ng-bind-html-unsafe="(event.kibana.highlight[field]||event.kibana._source[field]) |tableHighlight | tableTruncate:panel.trimFactor:panel.fields.length"></td>
</tr> </tr>
<tr ng-show="event.kibana.details"> <tr ng-show="event.kibana.details">
......
...@@ -87,6 +87,7 @@ function (angular, app, _, kbn, moment) { ...@@ -87,6 +87,7 @@ function (angular, app, _, kbn, moment) {
$scope.init = function () { $scope.init = function () {
$scope.Math = Math; $scope.Math = Math;
$scope.metaFields = [];
$scope.identity = angular.identity; $scope.identity = angular.identity;
$scope.$on('refresh',function(){$scope.get_data();}); $scope.$on('refresh',function(){$scope.get_data();});
...@@ -205,6 +206,12 @@ function (angular, app, _, kbn, moment) { ...@@ -205,6 +206,12 @@ function (angular, app, _, kbn, moment) {
}; };
$scope.get_data = function(segment,query_id) { $scope.get_data = function(segment,query_id) {
var
_segment,
request,
boolQuery,
results;
$scope.panel.error = false; $scope.panel.error = false;
// Make sure we have everything for the request to complete // Make sure we have everything for the request to complete
...@@ -216,12 +223,12 @@ function (angular, app, _, kbn, moment) { ...@@ -216,12 +223,12 @@ function (angular, app, _, kbn, moment) {
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
var _segment = _.isUndefined(segment) ? 0 : segment; _segment = _.isUndefined(segment) ? 0 : segment;
$scope.segment = _segment; $scope.segment = _segment;
var request = $scope.ejs.Request().indices(dashboard.indices[_segment]); request = $scope.ejs.Request().indices(dashboard.indices[_segment]);
var boolQuery = $scope.ejs.BoolQuery(); boolQuery = $scope.ejs.BoolQuery();
_.each($scope.panel.queries.ids,function(id) { _.each($scope.panel.queries.ids,function(id) {
boolQuery = boolQuery.should(querySrv.getEjsObj(id)); boolQuery = boolQuery.should(querySrv.getEjsObj(id));
}); });
...@@ -242,7 +249,7 @@ function (angular, app, _, kbn, moment) { ...@@ -242,7 +249,7 @@ function (angular, app, _, kbn, moment) {
$scope.populate_modal(request); $scope.populate_modal(request);
var results = request.doSearch(); results = request.doSearch();
// Populate scope when we have results // Populate scope when we have results
results.then(function(results) { results.then(function(results) {
...@@ -263,11 +270,15 @@ function (angular, app, _, kbn, moment) { ...@@ -263,11 +270,15 @@ function (angular, app, _, kbn, moment) {
// Check that we're still on the same query, if not stop // Check that we're still on the same query, if not stop
if($scope.query_id === query_id) { if($scope.query_id === query_id) {
$scope.data= $scope.data.concat(_.map(results.hits.hits, function(hit) { $scope.data= $scope.data.concat(_.map(results.hits.hits, function(hit) {
var _h = _.clone(hit); var
//_h._source = kbn.flatten_json(hit._source); _h = _.clone(hit),
//_h.highlight = kbn.flatten_json(hit.highlight||{}); _p = _.omit(hit,'_source','sort','_score');
$scope.metaFields = _.union(_.keys(_p),$scope.metaFields);
// _source is kind of a lie here, never display it, only select values from it
_h.kibana = { _h.kibana = {
_source : kbn.flatten_json(hit._source), _source : _.extend(kbn.flatten_json(hit._source),_p),
highlight : kbn.flatten_json(hit.highlight||{}) highlight : kbn.flatten_json(hit.highlight||{})
}; };
return _h; return _h;
......

409 Bytes | W: | H:

480 Bytes | W: | H:

src/img/small.png
src/img/small.png
src/img/small.png
src/img/small.png
  • 2-up
  • Swipe
  • Onion skin
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