Added some comments

This commit is contained in:
Rashid Khan 2013-11-05 21:42:34 -07:00
parent 5a464fcaf9
commit e33d4bb6f1

View file

@ -1,22 +1,13 @@
/* global _ */ /* global _ */
/* /*
* Complex scripted dashboard * Node statistics scripted dashboard
* This script generates a dashboard object that Kibana can load. It also takes a number of user * This script generates a dashboard object that Kibana can load.
* supplied URL parameters, none are required:
* *
* index :: Which index to search? If this is specified, interval is set to 'none' * Parameters (all optional)
* pattern :: Does nothing if index is specified. Set a timestamped index pattern. Default: [logstash-]YYYY.MM.DD * nodes :: By default, a comma seperated list of queries to run. Default: *
* interval :: Sets the index interval (eg: day,week,month,year), Default: day * show :: The names of the rows to expand
* * from :: Search this amount of time back, eg 15m, 1h, 2d. Default: 1d
* split :: The character to split the queries on Default: ','
* query :: By default, a comma seperated list of queries to run. Default: *
*
* from :: Search this amount of time back, eg 15m, 1h, 2d. Default: 15m
* timefield :: The field containing the time to filter on, Default: @timestamp
*
* fields :: comma seperated list of fields to show in the table
* sort :: comma seperated field to sort on, and direction, eg sort=@timestamp,desc
* *
*/ */
@ -40,16 +31,16 @@ dashboard = {
// Set a title // Set a title
dashboard.title = 'Node Statistics'; dashboard.title = 'Node Statistics';
// And the index options
dashboard.failover = false; dashboard.failover = false;
dashboard.index = { dashboard.index = {
default: ARGS.index||'ADD_A_TIME_FILTER', default: 'ADD_A_TIME_FILTER',
pattern: ARGS.pattern||'[es_monitor-]YYYY.MM.DD', pattern: '[es_monitor-]YYYY.MM.DD',
interval: ARGS.interval||'day' interval: 'day'
}; };
// In this dashboard we let users pass queries as comma seperated list to the query parameter. // In this dashboard we let users pass nodes as comma seperated list to the query parameter.
// If query is defined, split it into a list of query objects // If nodes are defined, split into a list of query objects, otherwise, show all
// NOTE: ids must be integers, hence the parseInt()s // NOTE: ids must be integers, hence the parseInt()s
if(!_.isUndefined(ARGS.nodes)) { if(!_.isUndefined(ARGS.nodes)) {
queries = _.object(_.map(ARGS.nodes.split(','), function(v,k) { queries = _.object(_.map(ARGS.nodes.split(','), function(v,k) {
@ -83,7 +74,7 @@ dashboard.services.filter = {
0: { 0: {
from: "now-"+(ARGS.from||_d_timespan), from: "now-"+(ARGS.from||_d_timespan),
to: "now", to: "now",
field: ARGS.timefield||"@timestamp", field: "@timestamp",
type: "time", type: "time",
active: true, active: true,
id: 0, id: 0,
@ -92,7 +83,8 @@ dashboard.services.filter = {
ids: [0] ids: [0]
}; };
// Ok, lets make some rows. The Filters row is collapsed by default // Ok, lets make some rows. Since all of our panels are similar, we can abstract this.
// Obviously this is a partial list, feel free to expand on this.
var rows = [ var rows = [
{ {
name:'OS', name:'OS',
@ -128,6 +120,7 @@ dashboard.rows = _.map(rows, function(r) {
height: '150px', height: '150px',
collapse: !_.contains(show,r.name), collapse: !_.contains(show,r.name),
panels: _.map(r.charts,function(c) { panels: _.map(r.charts,function(c) {
// A bunch of histogram panels, with similar defaults
return { return {
title: c.field, title: c.field,
type: 'histogram', type: 'histogram',
@ -139,17 +132,17 @@ dashboard.rows = _.map(rows, function(r) {
lines: true, lines: true,
stack: false, stack: false,
linewidth:2, linewidth:2,
mode: 'max', mode: 'max', // Pretty sure we want max for all of these? No? Average for some?
zoomlinks: false, zoomlinks: false,
options: false, options: false,
legend: false, legend: false, // Might want to enable this, cleaner without it though
interactive: false interactive: false // Because the filter pulldown is hidden
}; };
}) })
}; };
}); });
// No pulldowns available, and they can't be enabled. // No pulldowns shown, and they can't be enabled.
dashboard.pulldowns = []; dashboard.pulldowns = [];
// Now return the object and we're good! // Now return the object and we're good!