mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Added cluster status panel
This commit is contained in:
parent
c0be4069da
commit
4b1d4240f5
4 changed files with 205 additions and 0 deletions
5
panels/cluster/editor.html
Normal file
5
panels/cluster/editor.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<div class="row-fluid">
|
||||
<div class="section">
|
||||
No options available.
|
||||
</div>
|
||||
</div>
|
26
panels/cluster/module.html
Normal file
26
panels/cluster/module.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<div ng-controller='marvel.cluster' ng-init='init()'>
|
||||
<style>
|
||||
.marvel-cluster-health {
|
||||
padding: 0px 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<ul class="inline" ng-if="!_.isUndefined(panel.optin)">
|
||||
<li><strong>Name:</strong> {{data.cluster_name}}</li>
|
||||
<li><strong>Status:</strong> <span ng-class="healthClass(data.status)">{{data.status}}</span></li>
|
||||
<li><strong>Nodes:</strong> {{data.nodes.count.total}}</li>
|
||||
<li><strong>Indices:</strong> {{data.indices.count}}</li>
|
||||
<li><strong>Shards:</strong> {{data.indices.shards.total}}</li>
|
||||
<li><strong>Data Size:</strong> {{data.indices.store.size_in_bytes|marvelBytes}}</li>
|
||||
|
||||
<li>
|
||||
<span class="strong" ng-show="data.nodes.versions.length == 1">Version:</span>
|
||||
<span class="strong" ng-show="data.nodes.versions.length > 1">Versions:</span>
|
||||
|
||||
<span ng-repeat='version in data.nodes.versions'>
|
||||
{{version}}<span ng-hide='$last'>, </span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
155
panels/cluster/module.js
Normal file
155
panels/cluster/module.js
Normal file
|
@ -0,0 +1,155 @@
|
|||
/** @scratch /panels/5
|
||||
* include::panels/cluster.asciidoc[]
|
||||
*/
|
||||
|
||||
/** @scratch /panels/cluster/0
|
||||
* == cluster
|
||||
* Status: *Experimental*
|
||||
*
|
||||
* Displays a simple view of cluster health.
|
||||
*
|
||||
*/
|
||||
define([
|
||||
'angular',
|
||||
'app',
|
||||
'underscore',
|
||||
'kbn'
|
||||
],
|
||||
function (angular, app, _, kbn) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('kibana.panels.marvel.cluster', []);
|
||||
app.useModule(module);
|
||||
|
||||
module.controller('marvel.cluster', function($scope, $modal, $q, querySrv, dashboard, filterSrv) {
|
||||
$scope.panelMeta = {
|
||||
modals : [],
|
||||
editorTabs : [],
|
||||
status: "Experimental",
|
||||
description: "A simple view of cluster health<p>"
|
||||
};
|
||||
|
||||
// Set and populate defaults
|
||||
var _d = {
|
||||
title: 'Cluster Status',
|
||||
optin: undefined,
|
||||
};
|
||||
_.defaults($scope.panel,_d);
|
||||
|
||||
$scope.init = function () {
|
||||
// If the user hasn't opted in or out, ask them to.
|
||||
if(_.isUndefined($scope.panel.optin)) {
|
||||
$scope.optInModal();
|
||||
}
|
||||
|
||||
$scope.$on('refresh',function(){$scope.get_data();});
|
||||
$scope.get_data();
|
||||
};
|
||||
|
||||
$scope.get_data = function(segment,query_id) {
|
||||
var
|
||||
request,
|
||||
_segment;
|
||||
|
||||
$scope.panel.error = false;
|
||||
|
||||
// Make sure we have everything for the request to complete
|
||||
if(dashboard.indices.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_segment = _.isUndefined(segment) ? 0 : segment;
|
||||
|
||||
request = $scope.ejs.Request().indices(dashboard.indices[_segment]);
|
||||
|
||||
console.log($scope.$id);
|
||||
|
||||
request = request.query(
|
||||
$scope.ejs.FilteredQuery(
|
||||
$scope.ejs.QueryStringQuery('_type:cluster_stats'),
|
||||
filterSrv.getBoolFilter(filterSrv.ids)
|
||||
))
|
||||
.size(1)
|
||||
.sort([$scope.ejs.Sort('@timestamp').order('desc')]);
|
||||
|
||||
$scope.populate_modal(request);
|
||||
|
||||
// Populate scope when we have results
|
||||
request.doSearch().then(function(results) {
|
||||
console.log(results);
|
||||
$scope.panelMeta.loading = false;
|
||||
|
||||
if(_segment === 0) {
|
||||
$scope.data = undefined;
|
||||
query_id = $scope.query_id = new Date().getTime();
|
||||
}
|
||||
|
||||
// Check for error and abort if found
|
||||
if(!(_.isUndefined(results.error))) {
|
||||
$scope.panel.error = $scope.parse_error(results.error);
|
||||
return;
|
||||
// Are we still on the same query? No? Abort.
|
||||
} else if ($scope.query_id !== query_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.data = _.isArray(results.hits.hits) ? results.hits.hits[0]._source : undefined;
|
||||
|
||||
// Did we find anything in that index? No? Try the next one.
|
||||
if (_.isUndefined($scope.data) && _segment+1 < dashboard.indices.length) {
|
||||
$scope.get_data(_segment+1,$scope.query_id);
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
$scope.healthClass = function(color) {
|
||||
switch(color)
|
||||
{
|
||||
case 'green':
|
||||
return 'text-success';
|
||||
case 'yellow':
|
||||
return 'text-warning';
|
||||
case 'red':
|
||||
return 'text-error';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
$scope.populate_modal = function(request) {
|
||||
$scope.inspector = angular.toJson(JSON.parse(request.toString()),true);
|
||||
};
|
||||
|
||||
$scope.setOptIn = function(c) {
|
||||
$scope.panel.optin = c;
|
||||
};
|
||||
|
||||
$scope.optInModal = function() {
|
||||
var panelModal = $modal({
|
||||
template: './app/panels/marvel/cluster/optin.html',
|
||||
persist: true,
|
||||
show: false,
|
||||
scope: $scope,
|
||||
keyboard: false
|
||||
});
|
||||
|
||||
// and show it
|
||||
$q.when(panelModal).then(function(modalEl) {
|
||||
modalEl.modal('show');
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
// WIP
|
||||
module.filter('marvelBytes', function(){
|
||||
return function(text) {
|
||||
if(_.isUndefined(text)) {
|
||||
return '';
|
||||
}
|
||||
return kbn.byteFormat(text);
|
||||
};
|
||||
});
|
||||
|
||||
});
|
19
panels/cluster/optin.html
Normal file
19
panels/cluster/optin.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<div class="modal-body">
|
||||
<h2>Welcome to Elasticsearch Marvel</h2>
|
||||
<div>
|
||||
<h4>Help us improve elasticsearch!</h4>
|
||||
Would you like to help us improve Elasticsearch by reporting <strong>anonymous</strong>
|
||||
cluster statistics including information about
|
||||
the size and performance of your cluster. Data is sent once daily and is under 1 kilobyte. To
|
||||
see a sample report click <span class="link" ng-click="showSample=true">here</span>
|
||||
<div ng-show="showSample">
|
||||
<h4>Sample Statistics</h4>
|
||||
<pre>{{ data | json }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button ng-click="setOptIn(true);dismiss();" class="btn btn-success">Sure!</button>
|
||||
<span ng-click="setOptIn(false);dismiss();" class="pointer small">No Thanks</span>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue