Skip to content

Commit

Permalink
[StatusPage] The basics and such just to get the basics of the staus …
Browse files Browse the repository at this point in the history
…page
  • Loading branch information
panda01 committed Apr 21, 2015
1 parent 0b949fb commit 82af6b2
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 10 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"requirejs-text": "~2.0.10",
"lodash-deep": "spenceralger/lodash-deep#compat",
"marked": "~0.3.2",
"numeral": "~1.5.3"
"numeral": "~1.5.3",
"angularjs-nvd3-directives": "~0.0.7"
},
"devDependencies": {}
}
67 changes: 64 additions & 3 deletions src/hapi/plugins/status/public/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,70 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Kibana Status</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="shortcut icon" href="/styles/theme/elk.ico">
<link rel="stylesheet" href="/styles/main.css?_b=@@buildNum">

<style>
.status_chart_wrapper { float: left; }
.status_chart {
height: auto;
width: auto;
}
</style>
</head>
<body>
<h1>Kibana Status Page</h1>
<p>Statusy stuff goes here... it's goign to be totally awesome!</p>
<div class="container">
<header>
<h1>
<strong>Kibana</strong>&nbsp;Status
</h1>
</header>
<div>
<section>
<h4>What is this page?</h4>
<p>This page is your sanity check, and your savior. You can check for potential problems</p>
<p>Here is the status of your kibana instance and the plugins you have installed along with some, statistics to asses potential problems.</p>
</section>
<section>
<h4>What is this page?</h4>
<p>This page is your sanity check, and your savior. You can check for potential problems</p>
</section>
<div ng-controller="StatusPage">
<div id="system-status" class="alert alert-{{ui.systemStatus().label}}">
{{ui.systemStatus().msg}}
</div>
<div id="plugin-cont">
<div ng-repeat="(key, plugin) in ui.plugins" class="plugin">
<div class="alert alert-{{plugin.uiStatus}}">
{{key}}:&nbsp;{{plugin.message}}
</div>
</div>
</div>
<div id="chart-cont">
<div ng-repeat="(key, chart) in ui.charts" class="status_chart_wrapper">
<h2 class="title">{{key}}</h2>
<nvd3-sparkline-chart
id="{{key}}-chart"
data="chart"
width="450"
height="200"
x="ui.nvd3Config.getX"
y="ui.nvd3Config.getY">
<svg class="status_chart"></svg>
</nvd3-sparkline-chart>
</div>
</div>
</div>
</div>
<footer></footer>
</div>
<script type="text/javascript" src="/bower_components/requirejs/require.js?_b=@@buildNum"></script>
<script type="text/javascript" src="/require.config.js?_b=@@buildNum"></script>
<script type="text/javascript">
require(['/status/index.js'], function(kibanaStatus) { kibanaStatus.init(); });
</script>
</body>
</html>
106 changes: 106 additions & 0 deletions src/hapi/plugins/status/public/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
define(['angular', 'jquery', 'lodash', 'nvd3', 'nvd3_directives'],
function (angular, $, _, nvd3, directives) {

// Make sure we don't have to deal with statuses by hand
function getStatus(plugin) {
var statusMap = {
green: {
label: 'success',
msg: 'All systems are a Go.',
idx: 1
},
yellow: {
label: 'warning',
msg: 'S.N.A.F.U.',
idx: 2
},
red: {
label: 'danger',
msg: 'Danger Will Robinson! Danger!',
idx: 3
},
loading: {
label: 'info',
msg: 'Loading...',
idx: 0
}
};
if(!_.isObject(plugin) || _.isUndefined(plugin)) {
plugin = {state: plugin};
}
return statusMap[plugin.state];
}
function getLabel(plugin) { return getStatus(plugin).label; }


// The Kibana App
angular.module('KibanaStatusApp', ['nvd3ChartDirectives'])
.controller('StatusPage', ['$scope', '$http', function($scope, $http) {
// the object representing all of the elements the ui touches
$scope.ui = {
systemStatus: function() {
function getIdx(plugin) { return getStatus(plugin).idx; }
return function() {
var currentStatus = 'loading';
var currentIdx = getIdx(currentStatus);
// FIXME eh, not too thrilled about this.
var status = _.reduce($scope.ui.plugins, function(curr, plugin, key) {
var pluginIdx = getIdx(plugin);
if (pluginIdx > currentIdx) {
// set the current status
currentStatus = plugin.state;
currentIdx = getIdx(plugin);
}
return currentStatus;
}, 'loading');


// give the ui the label for colors and such
return getStatus(status);
}
}(),
charts: [],
plugins: [],
nvd3Config: {
getX: function(d) { return d[0]; },
getY: function(d) {
if(d) {
if(_.isArray(d[1])) {
return d[1][0];
}
} else {
debugger;
}
return d[1];
}
}
};


// go ahead and get the info you want
$http
.get('/status/health')
.success(function(data) {
// Assign the propper variables to the scope
$scope.ui.charts = data.metrics;
$scope.ui.plugins = _.mapValues(data.status, function(plugin) {
plugin.uiStatus = getLabel(plugin);
return plugin;
});

console.log($scope.ui);
})
.error(function() {
alert('Something went terribly wrong while making the request!!!');
});
}]);

return {
init: function() {
$(function() {
angular.bootstrap(document, ['nvd3ChartDirectives', 'KibanaStatusApp']);
});
}
};

});
2 changes: 1 addition & 1 deletion src/kibana/components/vislib/lib/resize_checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,4 @@ define(function (require) {

return ResizeChecker;
};
});
});
14 changes: 9 additions & 5 deletions src/kibana/require.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require.config({
baseUrl: './',
baseUrl: '/',
paths: {
kibana: 'index',
// special utils
Expand All @@ -21,6 +21,8 @@ require.config({
bower_components: 'bower_components',
css: 'bower_components/require-css/css',
d3: 'bower_components/d3/d3',
nvd3: 'bower_components/nvd3/nv.d3',
nvd3_directives: 'bower_components/angularjs-nvd3-directives/dist/angularjs-nvd3-directives',
elasticsearch: 'bower_components/elasticsearch/elasticsearch.angular',
faker: 'bower_components/Faker/faker',
file_saver: 'bower_components/FileSaver/FileSaver',
Expand All @@ -42,6 +44,9 @@ require.config({
deps: ['jquery'],
exports: 'angular'
},
file_saver: {
exports: 'saveAs'
},
gridster: ['jquery', 'css!bower_components/gridster/dist/jquery.gridster.css'],
'angular-route': ['angular'],
'elasticsearch': ['angular'],
Expand All @@ -53,15 +58,14 @@ require.config({
inflection: {
exports: 'inflection'
},
file_saver: {
exports: 'saveAs'
},
leaflet: {
deps: ['css!bower_components/leaflet/dist/leaflet.css']
},
marked: {
exports: 'marked'
}
},
nvd3: ['css!bower_components/nvd3/nv.d3.css', 'd3'],
nvd3_directives: ['angular', 'd3', 'nvd3']

This comment has been minimized.

Copy link
@panda01

panda01 Jun 19, 2015

Author Contributor

shouldn't need d3 again.

},
waitSeconds: 60
});

0 comments on commit 82af6b2

Please sign in to comment.