|
@@ -1,7 +1,27 @@
|
|
|
-/* Complex scripted Logstash dashboard */
|
|
|
|
|
|
|
+/*
|
|
|
|
|
+ * Complex scripted Logstash dashboard
|
|
|
|
|
+ * This script generates a dashboard object that Kibana can load. It also takes a number of user
|
|
|
|
|
+ * supplied URL parameters, none are required:
|
|
|
|
|
+ *
|
|
|
|
|
+ * index :: Which index to search? If this is specified, interval is set to 'none'
|
|
|
|
|
+ * pattern :: Does nothing if index is specified. Set a timestamped index pattern. Default: [logstash-]YYYY.MM.DD
|
|
|
|
|
+ * interval :: Sets the index interval (eg: day,week,month,year), Default: day
|
|
|
|
|
+ *
|
|
|
|
|
+ * 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
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
|
|
+var dashboard, ARGS, queries, _d_timespan;
|
|
|
|
|
|
|
|
-var dashboard, ARGS, queries;
|
|
|
|
|
|
|
+// Set a default timespan if one isn't specified
|
|
|
|
|
+_d_timespan = '1h';
|
|
|
|
|
|
|
|
// arguments[0] contains a hash of the URL parameters, make it shorter
|
|
// arguments[0] contains a hash of the URL parameters, make it shorter
|
|
|
ARGS = arguments[0];
|
|
ARGS = arguments[0];
|
|
@@ -22,6 +42,8 @@ if(!_.isUndefined(ARGS.index)) {
|
|
|
interval: 'none'
|
|
interval: 'none'
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ // Don't fail to default
|
|
|
|
|
+ dashboard.failover = false;
|
|
|
dashboard.index = {
|
|
dashboard.index = {
|
|
|
default: ARGS.index||'ADD_A_TIME_FILTER',
|
|
default: ARGS.index||'ADD_A_TIME_FILTER',
|
|
|
pattern: ARGS.pattern||'[logstash-]YYYY.MM.DD',
|
|
pattern: ARGS.pattern||'[logstash-]YYYY.MM.DD',
|
|
@@ -58,10 +80,11 @@ dashboard.services.query = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Lets also add a default time filter, the value of which can be specified by the user
|
|
// Lets also add a default time filter, the value of which can be specified by the user
|
|
|
|
|
+// This isn't strictly needed, but it gets rid of the info alert about the missing time filter
|
|
|
dashboard.services.filter = {
|
|
dashboard.services.filter = {
|
|
|
list: {
|
|
list: {
|
|
|
0: {
|
|
0: {
|
|
|
- from: kbn.time_ago(ARGS.from||'15m'),
|
|
|
|
|
|
|
+ from: kbn.time_ago(ARGS.from||_d_timespan),
|
|
|
to: new Date(),
|
|
to: new Date(),
|
|
|
field: ARGS.timefield||"@timestamp",
|
|
field: ARGS.timefield||"@timestamp",
|
|
|
type: "time",
|
|
type: "time",
|
|
@@ -75,7 +98,11 @@ dashboard.services.filter = {
|
|
|
// Ok, lets make some rows. The Filters row is collapsed by default
|
|
// Ok, lets make some rows. The Filters row is collapsed by default
|
|
|
dashboard.rows = [
|
|
dashboard.rows = [
|
|
|
{
|
|
{
|
|
|
- title: "Input",
|
|
|
|
|
|
|
+ title: "Options",
|
|
|
|
|
+ height: "30px"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: "Query",
|
|
|
height: "30px"
|
|
height: "30px"
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -96,25 +123,33 @@ dashboard.rows = [
|
|
|
// Setup some panels. A query panel and a filter panel on the same row
|
|
// Setup some panels. A query panel and a filter panel on the same row
|
|
|
dashboard.rows[0].panels = [
|
|
dashboard.rows[0].panels = [
|
|
|
{
|
|
{
|
|
|
- type: 'query',
|
|
|
|
|
- span: 7
|
|
|
|
|
|
|
+ type: 'timepicker',
|
|
|
|
|
+ span: 6,
|
|
|
|
|
+ timespan: ARGS.from||_d_timespan
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- type: 'timepicker',
|
|
|
|
|
- span: 5,
|
|
|
|
|
- timespan: ARGS.from||'15m'
|
|
|
|
|
|
|
+ type: 'dashcontrol',
|
|
|
|
|
+ span: 3
|
|
|
}
|
|
}
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
-// Add a filtering panel to the 2nd row
|
|
|
|
|
|
|
+// Add a filtering panel to the 3rd row
|
|
|
dashboard.rows[1].panels = [
|
|
dashboard.rows[1].panels = [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'Query'
|
|
|
|
|
+ }
|
|
|
|
|
+]
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// Add a filtering panel to the 3rd row
|
|
|
|
|
+dashboard.rows[2].panels = [
|
|
|
{
|
|
{
|
|
|
type: 'filtering'
|
|
type: 'filtering'
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
// And a histogram that allows the user to specify the interval and time field
|
|
// And a histogram that allows the user to specify the interval and time field
|
|
|
-dashboard.rows[2].panels = [
|
|
|
|
|
|
|
+dashboard.rows[3].panels = [
|
|
|
{
|
|
{
|
|
|
type: 'histogram',
|
|
type: 'histogram',
|
|
|
time_field: ARGS.timefield||"@timestamp",
|
|
time_field: ARGS.timefield||"@timestamp",
|
|
@@ -123,7 +158,7 @@ dashboard.rows[2].panels = [
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
// And a table row where you can specify field and sort order
|
|
// And a table row where you can specify field and sort order
|
|
|
-dashboard.rows[3].panels = [
|
|
|
|
|
|
|
+dashboard.rows[4].panels = [
|
|
|
{
|
|
{
|
|
|
type: 'table',
|
|
type: 'table',
|
|
|
fields: !_.isUndefined(ARGS.fields) ? ARGS.fields.split(',') : ['@timestamp','@message'],
|
|
fields: !_.isUndefined(ARGS.fields) ? ARGS.fields.split(',') : ['@timestamp','@message'],
|