Commit 7e5c36e9 by Rashid Khan

Made logstash.js look more like logstash.json. Added info notice for lack of…

Made logstash.js look more like logstash.json. Added info notice for lack of failover and time filter
parent 968c5754
/* 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
ARGS = arguments[0];
......@@ -22,6 +42,8 @@ if(!_.isUndefined(ARGS.index)) {
interval: 'none'
}
} else {
// Don't fail to default
dashboard.failover = false;
dashboard.index = {
default: ARGS.index||'ADD_A_TIME_FILTER',
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
// This isn't strictly needed, but it gets rid of the info alert about the missing time filter
dashboard.services.filter = {
list: {
0: {
from: kbn.time_ago(ARGS.from||'15m'),
from: kbn.time_ago(ARGS.from||_d_timespan),
to: new Date(),
field: ARGS.timefield||"@timestamp",
type: "time",
......@@ -75,7 +98,11 @@ dashboard.services.filter = {
// Ok, lets make some rows. The Filters row is collapsed by default
dashboard.rows = [
{
title: "Input",
title: "Options",
height: "30px"
},
{
title: "Query",
height: "30px"
},
{
......@@ -96,25 +123,33 @@ dashboard.rows = [
// Setup some panels. A query panel and a filter panel on the same row
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 = [
{
type: 'Query'
}
]
// Add a filtering panel to the 3rd row
dashboard.rows[2].panels = [
{
type: 'filtering'
}
]
// And a histogram that allows the user to specify the interval and time field
dashboard.rows[2].panels = [
dashboard.rows[3].panels = [
{
type: 'histogram',
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
dashboard.rows[3].panels = [
dashboard.rows[4].panels = [
{
type: 'table',
fields: !_.isUndefined(ARGS.fields) ? ARGS.fields.split(',') : ['@timestamp','@message'],
......
......@@ -659,9 +659,7 @@ angular.module('kibana.services', [])
if(self.current.failover) {
self.indices = [self.current.index.default];
} else {
alertSrv.set('No indices matched','The pattern <i>'+self.current.index.pattern+
'</i> did not match any indices in your selected'+
' time range.','info',5000);
// Do not issue refresh if no indices match. This should be removed when panels
// properly understand when no indices are present
return false;
......@@ -670,10 +668,14 @@ angular.module('kibana.services', [])
$rootScope.$broadcast('refresh');
});
} else {
// This is not optimal, we should be getting the entire index list here, or at least every
// index that possibly matches the pattern
self.indices = [self.current.index.default];
$rootScope.$broadcast('refresh');
if(self.current.failover) {
self.indices = [self.current.index.default];
$rootScope.$broadcast('refresh');
} else {
alertSrv.set("No time filter",
'Timestamped indices are configured without a failover. Waiting for time filter.',
'info',5000);
}
}
} else {
self.indices = [self.current.index.default];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment