Created
February 22, 2015 21:47
-
-
Save bcicen/85adef95aafdd9c2cce8 to your computer and use it in GitHub Desktop.
Kibana Scripted Dashboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dashboard, queries; | |
// All url parameters are available via the ARGS object | |
var ARGS; | |
// Intialize a skeleton with nothing but a rows array and service object | |
dashboard = { | |
rows : [], | |
services : {} | |
}; | |
dashboard.title = ARGS.domain; | |
dashboard.failover = false; | |
// Lock down this dashboard | |
dashboard.loader = { save_gist: false, | |
save_elasticsearch: false, | |
save_local: false, | |
save_default: false, | |
save_temp: false, | |
save_temp_ttl_enable: false, | |
save_temp_ttl: "30d", | |
load_gist: false, | |
load_elasticsearch: false, | |
load_elasticsearch_size: 20, | |
load_local: false, | |
hide: true} | |
dashboard.pulldowns = [] | |
dashboard.editable = false | |
// Allow the user to set the index, if they dont, fall back to logstash. | |
if(!_.isUndefined(ARGS.index)) { | |
dashboard.index = { | |
default: 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', | |
interval: ARGS.interval||'day' | |
}; | |
} | |
queries = { | |
0: { | |
query: 'http_host:"' + ARGS.domain + '" OR http_host:"www.' + ARGS.domain + '"', | |
id: 0 | |
} | |
}; | |
// Now populate the query service with our objects | |
dashboard.services.query = { | |
list : queries, | |
ids : _.map(_.keys(queries),function(v){return parseInt(v,10);}) | |
}; | |
dashboard.services.filter = { | |
list: { | |
0:{ | |
type: "time", | |
field: "@timestamp", | |
from: "now-6h", | |
to: "now", | |
mandate: "must", | |
active: true, | |
alias: "", | |
id: 0 | |
} | |
}, | |
ids: [0] | |
}; | |
dashboard.rows = [ | |
{ | |
title: "1", | |
editable: false, | |
height: "300px" | |
}, | |
{ | |
title: "2", | |
editable: false, | |
height: '150px' | |
}, | |
{ | |
title: "3", | |
editable: false, | |
height: '150px' | |
}, | |
{ | |
title: "4", | |
editable: false, | |
height: '350px' | |
}, | |
{ | |
title: "5", | |
editable: false, | |
height: '450px' | |
} | |
]; | |
dashboard.rows[0].panels = [ | |
{ | |
span: 8, | |
editable: false, | |
type: "histogram", | |
loadingEditor: false, | |
mode: "count", | |
time_field: "@timestamp", | |
value_field: null, | |
scale: 1, | |
y_format: "none", | |
grid: { | |
max: null, | |
min: 0 | |
}, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
annotate: { | |
enable: false, | |
query: "*", | |
size: 20, | |
field: "_type", | |
sort: [ | |
"_score", | |
"desc" | |
] | |
}, | |
auto_int: true, | |
resolution: 100, | |
interval: "5m", | |
intervals: [ | |
"auto", | |
"1s", | |
"1m", | |
"5m", | |
"10m", | |
"30m", | |
"1h", | |
"3h", | |
"12h", | |
"1d", | |
"1w", | |
"1y" | |
], | |
lines: false, | |
fill: 0, | |
linewidth: 3, | |
points: false, | |
pointradius: 5, | |
bars: true, | |
stack: true, | |
spyable: true, | |
zoomlinks: true, | |
options: true, | |
legend: false, | |
show_query: true, | |
interactive: true, | |
legend_counts: true, | |
timezone: "browser", | |
percentage: false, | |
zerofill: true, | |
derivative: false, | |
tooltip: { | |
value_type: "cumulative", | |
query_as_alias: true | |
} | |
}, | |
{ | |
error: false, | |
span: 4, | |
editable: false, | |
type: "column", | |
loadingEditor: false, | |
panels: [ | |
{ | |
type: "hits", | |
chart: "total", | |
arrangement: "vertical", | |
style: { | |
"font-size": "60pt" | |
}, | |
counter_pos: "above", | |
donut: false, | |
tilt: false, | |
labels: true, | |
spyable: true, | |
editable: false, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
title: "Hits", | |
span: 6, | |
height: "160px" | |
}, | |
{ | |
loading: false, | |
sizeable: false, | |
draggable: false, | |
removable: false, | |
span: 10, | |
height: "160px", | |
editable: false, | |
type: "trends", | |
arrangement: "vertical", | |
ago: "1h", | |
spyable: true, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
style: { | |
"font-size": "52pt" | |
}, | |
title: "Event trend over last 60m", | |
reverse: false | |
} | |
] | |
} | |
]; | |
dashboard.rows[1].panels = [ | |
{ | |
error: false, | |
span: 12, | |
editable: false, | |
type: "terms", | |
loadingEditor: false, | |
field: "http_host", | |
exclude: [], | |
missing: false, | |
other: false, | |
size: 15, | |
order: "count", | |
style: { | |
"font-size": "14pt" | |
}, | |
donut: false, | |
tilt: false, | |
labels: true, | |
arrangement: "horizontal", | |
chart: "table", | |
counter_pos: "above", | |
spyable: true, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
tmode: "terms", | |
tstat: "total", | |
valuefield: "", | |
title: "Included Domains:" | |
} | |
]; | |
dashboard.rows[2].panels = [ | |
{ | |
error: false, | |
span: 12, | |
editable: false, | |
type: "terms", | |
loadingEditor: false, | |
field: "http_referrer.raw", | |
exclude: [], | |
missing: false, | |
other: false, | |
size: 13, | |
order: "count", | |
style: { | |
"font-size": "12pt" | |
}, | |
donut: false, | |
tilt: false, | |
labels: true, | |
arrangement: "horizontal", | |
chart: "table", | |
counter_pos: "above", | |
spyable: true, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
tmode: "terms", | |
tstat: "total", | |
valuefield: "", | |
title: "Trending Referrers" | |
} | |
]; | |
dashboard.rows[3].panels = [ | |
{ | |
error: false, | |
span: 8, | |
editable: false, | |
type: "terms", | |
loadingEditor: false, | |
field: "request", | |
exclude: [], | |
missing: false, | |
other: false, | |
size: 25, | |
order: "count", | |
style: { | |
"font-size": "10pt" | |
}, | |
donut: false, | |
tilt: false, | |
labels: true, | |
arrangement: "vertical", | |
chart: "bar", | |
counter_pos: "none", | |
spyable: true, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
tmode: "terms", | |
tstat: "count", | |
valuefield: "", | |
title: "Top Requests" | |
}, | |
{ | |
error: false, | |
span: 4, | |
editable: false, | |
type: "column", | |
loadingEditor: false, | |
panels: [ | |
{ | |
loading: false, | |
error: false, | |
sizeable: false, | |
draggable: false, | |
removable: false, | |
span: 10, | |
height: "170px", | |
editable: false, | |
type: "terms", | |
tmode: "terms", | |
field: "http_user_agent", | |
size: 5, | |
order: "count", | |
exclude: [], | |
missing: false, | |
other: false, | |
style: { | |
"font-size": "10pt" | |
}, | |
donut: false, | |
tilt: false, | |
labels: true, | |
arrangement: "horizontal", | |
chart: "table", | |
counter_pos: "above", | |
spyable: true, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
tstat: "total", | |
valuefield: "" | |
}, | |
{ | |
loading: false, | |
error: false, | |
sizeable: false, | |
draggable: false, | |
removable: false, | |
span: 10, | |
height: "170px", | |
editable: false, | |
type: "terms", | |
tmode: "terms", | |
field: "status", | |
size: 8, | |
order: "count", | |
exclude: [], | |
missing: false, | |
other: false, | |
style: { | |
"font-size": "10pt" | |
}, | |
donut: false, | |
tilt: false, | |
labels: true, | |
arrangement: "horizontal", | |
chart: "table", | |
counter_pos: "above", | |
spyable: true, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
tstat: "total", | |
valuefield: "", | |
title: "Top Response Codes" | |
} | |
], | |
title: "Top User Agents" | |
} | |
]; | |
dashboard.rows[4].panels = [ | |
{ | |
error: false, | |
span: 12, | |
editable: false, | |
type: "table", | |
loadingEditor: false, | |
size: 50, | |
pages: 5, | |
offset: 0, | |
sort: [ | |
"_score", | |
"desc" | |
], | |
overflow: "min-height", | |
fields: [], | |
highlight: [], | |
sortable: true, | |
header: true, | |
paging: true, | |
field_list: true, | |
all_fields: false, | |
trimFactor: 300, | |
localTime: false, | |
timeField: "@timestamp", | |
spyable: true, | |
queries: { | |
mode: "all", | |
ids: [ | |
1 | |
] | |
}, | |
style: { | |
"font-size": "9pt" | |
}, | |
normTimes: true | |
} | |
]; | |
return dashboard; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A pretty in-depth scripted dashboard for use with Kibana when reading nginx logs. Largely locked-down from being edited or allowing for access to other dashboards. Depends on an arg of
?domain=mydomain.com
and expects logs from nginx to be in the format: