/* global _ */ /* * Node statistics scripted dashboard * This script generates a dashboard object that Kibana can load. * * 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 * */ 'use strict'; // Setup some variables var dashboard, queries, _d_timespan, marker_query; // 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 = { rows: [], services: {} }; // Set a title dashboard.title = 'Marvel - Node Statistics'; // And the index options dashboard.failover = false; dashboard.index = { 'default': 'ADD_A_TIME_FILTER', 'pattern': '[.marvel-]YYYY.MM.DD', 'interval': 'day', 'warm_fields': false }; dashboard.refresh="1m"; // 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 // NOTE: ids must be integers, hence the parseInt()s if (!_.isUndefined(ARGS.queries)) { queries = _.object(_.map(JSON.parse(ARGS.queries), function (v, k) { return [k, { query: v.q, alias: v.a || v.q, pin: true, id: parseInt(k, 10) }]; })); marker_query = "(" + _.pluck(queries,"query").join(") OR (") + ")"; } else { // No queries passed? Initialize a single query to match everything queries = { 0: { query: '*', id: 0 } }; } var annotate_config; if (marker_query) { annotate_config = { "enable": false, "query": "_type:shard_event AND (" + marker_query + ")", "size": 100, "field": "message", "sort": [ "@timestamp", "desc" ] }; } else { annotate_config = {}; } var show = (ARGS.show || "").split(','); // Now populate the query service with our objects dashboard.services.query = { list: queries, ids: _.map(_.keys(queries), function (v) { return parseInt(v, 10); }) }; // Lets also add a default time filter, the value of which can be specified by the user dashboard.services.filter = { list: { 0: { from: ARGS.from || "now-" + _d_timespan, to: ARGS.to || "now", field: "@timestamp", type: "time", active: true, id: 0 }, 1: { type: "querystring", mandate: "must", active: true, alias: "node stats", query: "_type:node_stats", id: 1 } }, ids: [0, 1] }; var row_defaults = { height: "150px", collapse: true, collapsable: true }; var panel_defaults_by_type = {}; panel_defaults_by_type["histogram"] = { span: 4, time_field: '@timestamp', bars: false, lines: true, stack: false, linewidth: 2, legend_counts: false, mode: 'max', zoomlinks: false, options: false, legend: false, resolution: 20, annotate: annotate_config, y_format: "short" }; var rows = [ { "title": "Essentials", "panels": [ { "value_field": "os.cpu.usage", "title": "OS CPU", "grid": { "max": 100, "min": 0 } }, { "value_field": "jvm.mem.heap_used_percent", "title": "JVM Heap usage (%)", "grid": { "max": 100, "min": 0 } }, { "value_field": "os.load_average.1m", "title": "Load (1m)" } ] }, { "title": "OS", "panels": [ { "value_field": "os.cpu.usage", "title": "OS CPU", "grid": { "max": 100, "min": 0 } }, { "value_field": "os.mem.used_percent", "title": "OS Memory usage (%)", "grid": { "max": 100, "min": 0 } }, { "value_field": "os.load_average.1m", "title": "OS Load (1m)" } ] }, { "title": "OS Extended", "panels": [ { "value_field": "os.cpu.sys", "title": "OS CPU Sys", "grid": { "max": 100, "min": 0 } }, { "value_field": "os.cpu.stolen", "title": "OS CPU Steal", "grid": { "max": 100, "min": 0 } }, { "time_field": "@timestamp", "value_field": "os.swap.used_in_bytes", "title": "OS Swap Used", "y_format": "bytes" } ] },{ "title": "JVM Memory", "panels": [ { "time_field": "@timestamp", "value_field": "jvm.mem.heap_used_in_bytes", "title": "JVM Heap Used", "y_format": "bytes" }, { "time_field": "@timestamp", "value_field": "jvm.mem.pools.Par Eden Space.used_in_bytes", "title": "JVM Young Gen usage", "y_format": "bytes" }, { "time_field": "@timestamp", "value_field": "jvm.mem.pools.CMS Old Gen.used_in_bytes", "title": "JVM Old Gen usage", "y_format": "bytes" } ] }, { "title": "JVM GC Young", "panels": [ { "value_field": "jvm.gc.collectors.ParNew.collection_time_in_millis", "title": "GC Young Duration (time %)", "derivative": true, "mode": "min", "scaleSeconds": true, "scale": 0.001 * 100, "grid": { "max": 100, "min": 0 }, "span": 6, "resolution": 20 }, { "value_field": "jvm.gc.collectors.ParNew.collection_count", "title": "GC Young Counts", "derivative": true, "mode": "min", "scaleSeconds": false, "span": 6, "resolution": 20 } ] }, { "title": "JVM GC Old", "panels": [ { "value_field": "jvm.gc.collectors.ConcurrentMarkSweep.collection_time_in_millis", "title": "GC Old Duration (time %)", "derivative": true, "mode": "min", "scaleSeconds": true, "scale": 0.001 * 100, "grid": { "max": 100, "min": 0 }, "span": 6, "resolution": 20 }, { "value_field": "jvm.gc.collectors.ConcurrentMarkSweep.collection_count", "title": "GC Old Counts", "derivative": true, "mode": "min", "scaleSeconds": false, "span": 6, "resolution": 20 } ] }, { "title": "Indices Memory", "panels": [ { "value_field": "indices.fielddata.memory_size_in_bytes", "title": "Indices Field Data", "y_format": "bytes" }, { "value_field": "indices.filter_cache.memory_size_in_bytes", "title": "Indices Filter cache", "y_format": "bytes" }, { "value_field": "indices.id_cache.memory_size_in_bytes", "title": "Indices Id Cache", "y_format": "bytes" } ] }, { "title": "Indices Memory Extended", "panels": [ { "value_field": "indices.percolate.size_in_bytes", "title": "Indices Percolation size", "y_format": "bytes" }, { "value_field": "indices.completion.size_in_bytes", "title": "Indices Completion size", "y_format": "bytes" } ] }, { "title": "Indices Search Requests Query", "panels": [ { "value_field": "indices.search.query_total", "derivative": true, "mode": "min", "scaleSeconds": true, "title": "Indices Search Query Rate" }, { "value_field": "indices.search.query_time_in_millis", "derivative": true, "mode": "min", "scaleSeconds": true, "scale": 0.001, "title": "Indices Total Search Query Time" } ] }, { "title": "Indices Search Requests Fetch", "panels": [ { "value_field": "indices.search.fetch_total", "derivative": true, "mode": "min", "scaleSeconds": true, "title": "Indices Search Fetch Rate" }, { "value_field": "indices.search.fetch_time_in_millis", "derivative": true, "mode": "min", "scaleSeconds": true, "scale": 0.001, "title": "Indices Total Search Fetch Time" } ] }, { "title": "Indices Indexing Requests", "panels": [ { "value_field": "indices.indexing.index_total", "derivative": true, "mode": "min", "scaleSeconds": true, "title": "Indices Indexing Rate" }, { "value_field": "indices.indexing.index_time_in_millis", "derivative": true, "mode": "min", "scaleSeconds": true, "scale": 0.001, "title": "Indices Total Indexing Time" }, { "value_field": "indices.indexing.delete_total", "derivative": true, "mode": "min", "scaleSeconds": true, "title": "Indices Delete Rate" } ] }, { "title": "Indices Get Requests", "panels": [ { "value_field": "indices.get.total", "derivative": true, "mode": "min", "scaleSeconds": true, "title": "Indices Get Requests Rate" }, { "value_field": "indices.get.time_in_millis", "derivative": true, "mode": "min", "scaleSeconds": true, "scale": 0.001, "title": "Indices Total Get Time" } ] }, { "title": "Indices Management", "panels": [ { "value_field": "indices.merges.current_size_in_bytes", "mode": "max", "y_format": "bytes", "title": "Indices Current Merges" }, { "value_field": "indices.refresh.total_time_in_millis", "derivative": true, "mode": "min", "scale": 0.001, "scaleSeconds": true, "title": "Indices Total Refresh Time" }, { "value_field": "indices.flush.total", "derivative": true, "mode": "min", "scaleSeconds": true, "title": "Indices Flush count" } ] }, { "title": "Indices Management Extended", "panels": [ { "value_field": "indices.search.open_contexts", "mode": "max", "title": "Indices Open Search Contexts" }, { "value_field": "indices.warmer.total_time_in_millis", "derivative": true, "mode": "min", "scale": 0.001, "scaleSeconds": true, "title": "Indices Total Warmer Time" }, { "value_field": "indices.segments.count", "title": "Indices Segment Count" } ] }, { "title": "Disk", "panels": [ { "value_field": "fs.total.disk_read_size_in_bytes", "title": "Disk read rate (bytes)", "derivative": true, "mode": "min", "scaleSeconds": true, "y_format": "bytes" }, { "value_field": "fs.total.disk_write_size_in_bytes", "title": "Disk write per (bytes)", "derivative": true, "y_format": "bytes", "mode": "min", "scaleSeconds": true }, { "value_field": "fs.total.available_in_bytes", "title": "Disk Free space", "mode": "min", "y_format": "bytes" } ], "notice": false }, { "title": "Disk 2", "panels": [ { "value_field": "fs.total.disk_io_op", "title": "Disk IOps", "derivative": true, "mode": "min", "scaleSeconds": true, "y_format": "short" }, { "value_field": "fs.total.disk_reads", "title": "Disk Read IOps", "derivative": true, "mode": "min", "scaleSeconds": true, "y_format": "short" }, { "value_field": "fs.total.disk_writes", "title": "Disk Write IOps", "derivative": true, "mode": "min", "scaleSeconds": true, "y_format": "short" }, ], "notice": false }, { "title": "Network", "panels": [ { "value_field": "http.current_open", "title": "HTTP currently open" }, { "value_field": "http.total_opened", "title": "HTTP opened", "derivative": true, "mode": "min", "scaleSeconds": true } ] }, { "title": "Data", "panels": [ { "value_field": "indices.docs.count", "title": "Documents" }, { "value_field": "indices.store.size_in_bytes", "title": "Size", "y_format": "bytes" } ] }, { "title": "Segments", "panels": [ { "value_field": "indices.segments.count", "title": "Segment no." } ] }, { "title": "Process", "panels": [ { "value_field": "process.cpu.percent", "title": "Process CPU" }, { "value_field": "jvm.threads.count", "title": "Threads" }, { "value_field": "process.open_file_descriptors", "title": "File descriptors" } ] } ]; var showedSomething; dashboard.rows = _.map(rows, function (r) { _.defaults(r, row_defaults); _.each(r.panels, function (panel) { if (!panel.type) { panel.type = "histogram"; } _.defaults(panel, panel_defaults_by_type[panel.type]); if (_.contains(show, panel.value_field)) { showedSomething = true; r.collapse = false; } }); return r; }); if (!showedSomething && dashboard.rows.length > 0) { dashboard.rows[0].collapse = false; } dashboard.pulldowns = [ { "type": "query", "collapse": false, "notice": false, "enable": true }, { "type": "filtering", "collapse": true } ]; // Now return the object and we're good! return dashboard;