mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
Added elasticsearch _ fields to table, eg _id, _index, _type
This commit is contained in:
parent
a6d1bdaac9
commit
ebb38b5eb1
@ -49,7 +49,7 @@ define(['angular', 'jquery', 'underscore', 'moment'], function (angular, $, _, m
|
||||
if(_.isObject(arr) && !_.isArray(arr)) {
|
||||
return angular.toJson(arr);
|
||||
} else {
|
||||
return arr.toString();
|
||||
return _.isNull(arr) ? null : arr.toString();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -18,6 +18,11 @@
|
||||
|
||||
|
||||
<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">
|
||||
<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>
|
||||
@ -62,7 +67,7 @@
|
||||
</thead>
|
||||
<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">
|
||||
<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>
|
||||
</tr>
|
||||
<tr ng-show="event.kibana.details">
|
||||
|
@ -87,6 +87,7 @@ function (angular, app, _, kbn, moment) {
|
||||
|
||||
$scope.init = function () {
|
||||
$scope.Math = Math;
|
||||
$scope.metaFields = [];
|
||||
$scope.identity = angular.identity;
|
||||
$scope.$on('refresh',function(){$scope.get_data();});
|
||||
|
||||
@ -205,6 +206,12 @@ function (angular, app, _, kbn, moment) {
|
||||
};
|
||||
|
||||
$scope.get_data = function(segment,query_id) {
|
||||
var
|
||||
_segment,
|
||||
request,
|
||||
boolQuery,
|
||||
results;
|
||||
|
||||
$scope.panel.error = false;
|
||||
|
||||
// Make sure we have everything for the request to complete
|
||||
@ -216,12 +223,12 @@ function (angular, app, _, kbn, moment) {
|
||||
|
||||
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
||||
|
||||
var _segment = _.isUndefined(segment) ? 0 : segment;
|
||||
_segment = _.isUndefined(segment) ? 0 : 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) {
|
||||
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
||||
});
|
||||
@ -242,7 +249,7 @@ function (angular, app, _, kbn, moment) {
|
||||
|
||||
$scope.populate_modal(request);
|
||||
|
||||
var results = request.doSearch();
|
||||
results = request.doSearch();
|
||||
|
||||
// Populate scope when we have results
|
||||
results.then(function(results) {
|
||||
@ -263,11 +270,15 @@ function (angular, app, _, kbn, moment) {
|
||||
// Check that we're still on the same query, if not stop
|
||||
if($scope.query_id === query_id) {
|
||||
$scope.data= $scope.data.concat(_.map(results.hits.hits, function(hit) {
|
||||
var _h = _.clone(hit);
|
||||
//_h._source = kbn.flatten_json(hit._source);
|
||||
//_h.highlight = kbn.flatten_json(hit.highlight||{});
|
||||
var
|
||||
_h = _.clone(hit),
|
||||
_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 = {
|
||||
_source : kbn.flatten_json(hit._source),
|
||||
_source : _.extend(kbn.flatten_json(hit._source),_p),
|
||||
highlight : kbn.flatten_json(hit.highlight||{})
|
||||
};
|
||||
return _h;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 409 B After Width: | Height: | Size: 480 B |
Loading…
Reference in New Issue
Block a user