2013-11-06 05:34:33 +01:00
|
|
|
/* global _ */
|
|
|
|
|
|
|
|
/*
|
2013-11-06 05:42:34 +01:00
|
|
|
* Node statistics scripted dashboard
|
|
|
|
* This script generates a dashboard object that Kibana can load.
|
2013-11-06 05:34:33 +01:00
|
|
|
*
|
2013-11-06 05:42:34 +01:00
|
|
|
* Parameters (all optional)
|
|
|
|
* nodes :: By default, a comma seperated list of queries to run. Default: *
|
|
|
|
* show :: The names of the rows to expand
|
|
|
|
* from :: Search this amount of time back, eg 15m, 1h, 2d. Default: 1d
|
2013-11-06 05:34:33 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Setup some variables
|
2013-12-02 23:04:29 +01:00
|
|
|
var dashboard, queries, _d_timespan, marker_query;
|
2013-11-06 05:34:33 +01:00
|
|
|
|
|
|
|
// All url parameters are available via the ARGS object
|
|
|
|
var ARGS;
|
|
|
|
|
|
|
|
// Set a default timespan if one isn't specified
|
|
|
|
_d_timespan = '1d';
|
|
|
|
|
|
|
|
// Intialize a skeleton with nothing but a rows array and service object
|
|
|
|
dashboard = {
|
2013-11-06 22:25:43 +01:00
|
|
|
rows: [],
|
|
|
|
services: {}
|
2013-11-06 05:34:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Set a title
|
2013-11-07 21:20:02 +01:00
|
|
|
dashboard.title = 'Marvel - Node Statistics';
|
2013-11-06 05:34:33 +01:00
|
|
|
|
2013-11-06 05:42:34 +01:00
|
|
|
// And the index options
|
2013-11-06 05:34:33 +01:00
|
|
|
dashboard.failover = false;
|
|
|
|
dashboard.index = {
|
2013-11-07 21:20:02 +01:00
|
|
|
'default': 'ADD_A_TIME_FILTER',
|
2013-11-21 15:04:27 +01:00
|
|
|
'pattern': '[.marvel-]YYYY.MM.DD',
|
2013-12-13 20:32:59 +01:00
|
|
|
'interval': 'day',
|
|
|
|
'warm_fields': false
|
2013-11-06 05:34:33 +01:00
|
|
|
};
|
|
|
|
|
2013-12-05 13:58:38 +01:00
|
|
|
dashboard.refresh="5s";
|
2013-12-02 20:28:07 +01:00
|
|
|
|
2013-11-06 05:42:34 +01:00
|
|
|
// In this dashboard we let users pass nodes as comma seperated list to the query parameter.
|
|
|
|
// If nodes are defined, split into a list of query objects, otherwise, show all
|
2013-11-06 05:34:33 +01:00
|
|
|
// NOTE: ids must be integers, hence the parseInt()s
|
2013-11-14 16:43:26 +01:00
|
|
|
if (!_.isUndefined(ARGS.queries)) {
|
|
|
|
queries = _.object(_.map(JSON.parse(ARGS.queries), function (v, k) {
|
2013-11-06 22:25:43 +01:00
|
|
|
return [k, {
|
2013-11-07 21:20:02 +01:00
|
|
|
query: v.q,
|
|
|
|
alias: v.a || v.q,
|
2013-11-06 17:08:50 +01:00
|
|
|
pin: true,
|
2013-11-06 22:25:43 +01:00
|
|
|
id: parseInt(k, 10)
|
2013-11-06 05:34:33 +01:00
|
|
|
}];
|
|
|
|
}));
|
2013-12-02 23:04:29 +01:00
|
|
|
marker_query = "(" + _.pluck(queries,"query").join(") OR (") + ")";
|
2013-11-06 05:34:33 +01:00
|
|
|
} else {
|
|
|
|
// No queries passed? Initialize a single query to match everything
|
|
|
|
queries = {
|
|
|
|
0: {
|
|
|
|
query: '*',
|
2013-11-06 18:20:20 +01:00
|
|
|
id: 0
|
2013-11-06 05:34:33 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-12-02 23:04:29 +01:00
|
|
|
var annotate_config;
|
|
|
|
|
|
|
|
if (marker_query) {
|
|
|
|
annotate_config = {
|
|
|
|
"enable": true,
|
|
|
|
"query": "_type:shard_event AND (" + marker_query + ")",
|
|
|
|
"size": 100,
|
|
|
|
"field": "message",
|
|
|
|
"sort": [
|
|
|
|
"@timestamp",
|
|
|
|
"desc"
|
|
|
|
]
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
annotate_config = {};
|
|
|
|
}
|
|
|
|
|
2013-11-07 21:20:02 +01:00
|
|
|
var show = (ARGS.show || "").split(',');
|
2013-11-06 05:34:33 +01:00
|
|
|
|
|
|
|
// Now populate the query service with our objects
|
|
|
|
dashboard.services.query = {
|
2013-11-06 22:25:43 +01:00
|
|
|
list: queries,
|
|
|
|
ids: _.map(_.keys(queries), function (v) {
|
|
|
|
return parseInt(v, 10);
|
2013-11-07 21:20:02 +01:00
|
|
|
})
|
2013-11-06 05:34:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Lets also add a default time filter, the value of which can be specified by the user
|
|
|
|
dashboard.services.filter = {
|
|
|
|
list: {
|
|
|
|
0: {
|
2013-11-07 21:20:02 +01:00
|
|
|
from: ARGS.from || "now-" + _d_timespan,
|
|
|
|
to: ARGS.to || "now",
|
2013-11-06 05:42:34 +01:00
|
|
|
field: "@timestamp",
|
2013-11-06 05:34:33 +01:00
|
|
|
type: "time",
|
|
|
|
active: true,
|
2013-11-06 18:20:20 +01:00
|
|
|
id: 0
|
|
|
|
},
|
|
|
|
1: {
|
|
|
|
type: "querystring",
|
|
|
|
mandate: "must",
|
|
|
|
active: true,
|
|
|
|
alias: "node stats",
|
|
|
|
query: "_type:node_stats",
|
|
|
|
id: 1
|
2013-11-06 05:34:33 +01:00
|
|
|
}
|
2013-11-06 22:25:43 +01:00
|
|
|
},
|
|
|
|
ids: [0, 1]
|
2013-11-06 18:20:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var row_defaults = {
|
|
|
|
height: "150px",
|
|
|
|
collapse: true,
|
|
|
|
collapsable: true
|
2013-11-06 05:34:33 +01:00
|
|
|
};
|
|
|
|
|
2013-11-06 18:20:20 +01:00
|
|
|
var panel_defaults_by_type = {};
|
|
|
|
|
|
|
|
panel_defaults_by_type["histogram"] = {
|
|
|
|
span: 4,
|
|
|
|
time_field: '@timestamp',
|
|
|
|
bars: false,
|
|
|
|
lines: true,
|
|
|
|
stack: false,
|
2013-11-06 22:25:43 +01:00
|
|
|
linewidth: 2,
|
2013-11-28 21:22:32 +01:00
|
|
|
legend_counts: false,
|
2013-11-06 18:20:20 +01:00
|
|
|
mode: 'max',
|
|
|
|
zoomlinks: false,
|
|
|
|
options: false,
|
|
|
|
legend: true,
|
2013-12-02 23:04:29 +01:00
|
|
|
resolution: 20,
|
2013-12-13 20:32:59 +01:00
|
|
|
annotate: annotate_config,
|
|
|
|
y_format: "short"
|
2013-11-06 18:20:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-11-06 05:34:33 +01:00
|
|
|
var rows = [
|
|
|
|
{
|
2013-11-06 18:20:20 +01:00
|
|
|
"title": "Server",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "os.cpu.user",
|
|
|
|
"title": "CPU (user)",
|
|
|
|
"grid": {
|
|
|
|
"max": 100,
|
|
|
|
"min": 0
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "os.mem.used_percent",
|
|
|
|
"title": "Memory usage (%)",
|
|
|
|
"grid": {
|
|
|
|
"max": 100,
|
|
|
|
"min": 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "os.load_average.1m",
|
|
|
|
"title": "Load (1m)"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Server 2",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"time_field": "@timestamp",
|
|
|
|
"value_field": "os.swap.used_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Used Swap",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-06 18:20:20 +01:00
|
|
|
}
|
2013-11-07 10:52:53 +01:00
|
|
|
]
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "JVM Memory",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"time_field": "@timestamp",
|
|
|
|
"value_field": "jvm.mem.heap_used_in_bytes",
|
2013-11-07 21:20:02 +01:00
|
|
|
"title": "Heap",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "jvm.gc.collectors.ParNew.collection_time_in_millis",
|
2013-12-02 20:40:10 +01:00
|
|
|
"title": "GC Young Gen duration (time %)",
|
2013-11-07 10:52:53 +01:00
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-12-02 20:40:10 +01:00
|
|
|
"scaleSeconds": true,
|
|
|
|
"scale": 0.001 * 100,
|
|
|
|
"grid": {
|
|
|
|
"max": 100,
|
|
|
|
"min": 0
|
|
|
|
}
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "jvm.gc.collectors.ParNew.collection_count",
|
|
|
|
"title": "GC counts",
|
2013-11-07 10:52:53 +01:00
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-07 10:52:53 +01:00
|
|
|
"scaleSeconds": true
|
2013-11-06 18:20:20 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "JVM Memory 2",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "jvm.gc.collectors.ConcurrentMarkSweep.collection_time_in_millis",
|
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-12-02 20:40:10 +01:00
|
|
|
"title": "GC Old Gen duration (time %)",
|
|
|
|
"scaleSeconds": true,
|
|
|
|
"scale": 0.001 * 100,
|
|
|
|
"grid": {
|
|
|
|
"max": 100,
|
|
|
|
"min": 0
|
|
|
|
}
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "jvm.gc.collectors.ConcurrentMarkSweep.collection_count",
|
|
|
|
"derivative": true,
|
2013-11-07 10:52:53 +01:00
|
|
|
"scaleSeconds": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-06 18:20:20 +01:00
|
|
|
"title": "GC Old Gen count"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Caches",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "indices.fielddata.memory_size_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Field Data",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "indices.filter_cache.memory_size_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Filter cache",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "indices.id_cache.memory_size_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Id cache",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-06 18:20:20 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Caches 2",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "indices.completion.size_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Completion size",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-06 18:20:20 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
2013-11-07 21:20:02 +01:00
|
|
|
"title": "Disk",
|
2013-11-06 18:20:20 +01:00
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "fs.data.disk_read_size_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Disk reads per sec.",
|
2013-11-07 10:52:53 +01:00
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-28 21:22:32 +01:00
|
|
|
"scaleSeconds": true,
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-28 21:22:32 +01:00
|
|
|
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "fs.data.disk_write_size_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Disk writes per sec.",
|
2013-11-07 10:52:53 +01:00
|
|
|
"derivative": true,
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes",
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-07 10:52:53 +01:00
|
|
|
"scaleSeconds": true
|
2013-11-07 21:20:02 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "fs.data.available_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Disk Free space",
|
|
|
|
"mode": "min",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-06 18:20:20 +01:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"notice": false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Network",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "http.current_open",
|
|
|
|
"title": "HTTP currently open"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "http.total_opened",
|
|
|
|
"title": "HTTP opened",
|
2013-11-07 10:52:53 +01:00
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-07 10:52:53 +01:00
|
|
|
"scaleSeconds": true
|
2013-11-06 18:20:20 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Indexing",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "indices.indexing.index_total",
|
|
|
|
"derivative": true,
|
2013-11-07 10:52:53 +01:00
|
|
|
"scaleSeconds": true,
|
2013-11-06 18:20:20 +01:00
|
|
|
"title": "Indexing requests"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "indices.merges.current_size_in_bytes",
|
2013-11-28 21:22:32 +01:00
|
|
|
"title": "Merges size",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "indices.refresh.total_time_in_millis",
|
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-07 10:52:53 +01:00
|
|
|
"scaleSeconds": true,
|
2013-11-06 18:20:20 +01:00
|
|
|
"title": "Avg refresh time"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Indexing 2",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "indices.flush.total",
|
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-06 18:20:20 +01:00
|
|
|
"title": "Flush count"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Search & Get",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "indices.search.query_total",
|
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-07 10:52:53 +01:00
|
|
|
"scaleSeconds": true,
|
2013-11-06 18:20:20 +01:00
|
|
|
"title": "Search requests"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "indices.get.total",
|
|
|
|
"derivative": true,
|
2013-11-13 13:45:32 +01:00
|
|
|
"mode": "min",
|
2013-11-07 10:52:53 +01:00
|
|
|
"scaleSeconds": true,
|
2013-11-06 18:20:20 +01:00
|
|
|
"title": "Get requests"
|
|
|
|
}
|
|
|
|
]
|
2013-11-06 05:34:33 +01:00
|
|
|
},
|
2013-12-02 22:06:00 +01:00
|
|
|
{
|
|
|
|
"title": "Data",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "indices.docs.count",
|
|
|
|
"title": "Documents"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "indices.store.size_in_bytes",
|
|
|
|
"title": "Size",
|
2013-12-13 20:32:59 +01:00
|
|
|
"y_format": "bytes"
|
2013-12-02 22:06:00 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Segments",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "indices.segments.count",
|
|
|
|
"title": "Segment no."
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2013-11-06 05:34:33 +01:00
|
|
|
{
|
2013-11-06 18:20:20 +01:00
|
|
|
"title": "Process",
|
|
|
|
"panels": [
|
|
|
|
{
|
|
|
|
"value_field": "process.cpu.percent",
|
|
|
|
"title": "Process CPU"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "jvm.threads.count",
|
|
|
|
"title": "Threads"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value_field": "process.open_file_descriptors",
|
2013-11-13 13:45:32 +01:00
|
|
|
"title": "File descriptors"
|
2013-11-06 18:20:20 +01:00
|
|
|
}
|
|
|
|
]
|
2013-11-06 05:34:33 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2013-11-06 18:20:20 +01:00
|
|
|
var showedSomething;
|
|
|
|
|
2013-11-06 22:25:43 +01:00
|
|
|
dashboard.rows = _.map(rows, function (r) {
|
|
|
|
_.defaults(r, row_defaults);
|
2013-11-06 18:20:20 +01:00
|
|
|
_.each(r.panels, function (panel) {
|
2013-11-06 22:25:43 +01:00
|
|
|
if (!panel.type) {
|
|
|
|
panel.type = "histogram";
|
|
|
|
}
|
2013-11-06 18:20:20 +01:00
|
|
|
_.defaults(panel, panel_defaults_by_type[panel.type]);
|
2013-11-06 22:25:43 +01:00
|
|
|
if (_.contains(show, panel.value_field)) {
|
2013-11-06 18:20:20 +01:00
|
|
|
showedSomething = true;
|
|
|
|
r.collapse = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return r;
|
2013-11-06 05:34:33 +01:00
|
|
|
});
|
|
|
|
|
2013-11-06 18:20:20 +01:00
|
|
|
if (!showedSomething && dashboard.rows.length > 0) {
|
|
|
|
dashboard.rows[0].collapse = false;
|
2013-11-06 22:25:43 +01:00
|
|
|
}
|
|
|
|
|
2013-11-06 18:20:20 +01:00
|
|
|
|
|
|
|
dashboard.pulldowns = [
|
|
|
|
{
|
|
|
|
"type": "query",
|
|
|
|
"collapse": false,
|
|
|
|
"notice": false,
|
2013-11-07 21:20:02 +01:00
|
|
|
"enable": true
|
2013-11-06 18:20:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "filtering",
|
|
|
|
"collapse": true
|
|
|
|
}
|
|
|
|
];
|
2013-11-06 05:34:33 +01:00
|
|
|
|
|
|
|
// Now return the object and we're good!
|
|
|
|
return dashboard;
|