From 2f916cd30259fb1d802f38ef693099d40adeae43 Mon Sep 17 00:00:00 2001 From: Thomas Kuther Date: Mon, 26 Nov 2012 20:21:30 +0100 Subject: [PATCH 1/3] show max. 5 lines in collapsed view --- static/lib/js/ajax.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/static/lib/js/ajax.js b/static/lib/js/ajax.js index cc876c57e..7792fc04b 100644 --- a/static/lib/js/ajax.js +++ b/static/lib/js/ajax.js @@ -854,8 +854,21 @@ function CreateLogTable(objArray, fields, theme, enableHeader) { var field = fields[index]; var value = get_field_value(object,field) var value = value === undefined ? "-" : value.toString(); + var maxlines = 5; + if (field == '@message') { + var fullvalue = xmlEnt(wbr(value, 10)).split('
').slice(0); + var splitvalue = fullvalue.slice(0, maxlines); + if (fullvalue.length > maxlines) { + var omitted = fullvalue.length - maxlines; + var shortvalue = splitvalue.join('
') + '
[...' + omitted + ' lines omitted...]'; + } else { + var shortvalue = fullvalue.join('
'); + } + } else { + var shortvalue = xmlEnt(wbr(value, 10)); + } str += '' + - xmlEnt(wbr(value, 10)) + ''; + shortvalue + ''; } str += ''; i++; From 766ac16772da4d5cd9f59fa727a5155a2b409cb8 Mon Sep 17 00:00:00 2001 From: Thomas Kuther Date: Tue, 27 Nov 2012 09:56:00 +0100 Subject: [PATCH 2/3] make maxlines configurable --- KibanaConfig.rb | 3 +++ kibana.rb | 1 + static/lib/js/ajax.js | 7 ++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/KibanaConfig.rb b/KibanaConfig.rb index f21b4e440..b9f077388 100644 --- a/KibanaConfig.rb +++ b/KibanaConfig.rb @@ -27,6 +27,9 @@ module KibanaConfig # Results to show per page Per_page = 50 + # Maximum number of lines to display in collapsed view + Max_lines = 5 + # Timezone. Leave this set to 'user' to have the user's browser autocorrect. # Otherwise, set a timezone string # Examples: 'UTC', 'America/Phoenix', 'Europe/Athens', MST diff --git a/kibana.rb b/kibana.rb index 005382480..de0cec1f6 100644 --- a/kibana.rb +++ b/kibana.rb @@ -70,6 +70,7 @@ def link_to url_fragment, mode=:full_url result.response['kibana']['time'] = { "from" => req.from.iso8601, "to" => req.to.iso8601} result.response['kibana']['default_fields'] = KibanaConfig::Default_fields + result.response['kibana']['maxlines'] = KibanaConfig::Max_lines JSON.generate(result.response) end diff --git a/static/lib/js/ajax.js b/static/lib/js/ajax.js index 7792fc04b..bd852892a 100644 --- a/static/lib/js/ajax.js +++ b/static/lib/js/ajax.js @@ -854,13 +854,14 @@ function CreateLogTable(objArray, fields, theme, enableHeader) { var field = fields[index]; var value = get_field_value(object,field) var value = value === undefined ? "-" : value.toString(); - var maxlines = 5; + // cut long events like stack traces after Max_lines + // TODO: make fields configurable + var maxlines = window.resultjson.kibana.maxlines; if (field == '@message') { var fullvalue = xmlEnt(wbr(value, 10)).split('
').slice(0); - var splitvalue = fullvalue.slice(0, maxlines); if (fullvalue.length > maxlines) { var omitted = fullvalue.length - maxlines; - var shortvalue = splitvalue.join('
') + '
[...' + omitted + ' lines omitted...]'; + var shortvalue = fullvalue.slice(0, maxlines).join('
') + '
[...' + omitted + ' lines omitted...]'; } else { var shortvalue = fullvalue.join('
'); } From 4d2e94cac15918ecaa9abeebe8d19560d16e8f74 Mon Sep 17 00:00:00 2001 From: Thomas Kuther Date: Wed, 28 Nov 2012 08:11:20 +0100 Subject: [PATCH 3/3] make it work for all default_fields --- KibanaConfig.rb | 3 ++- static/lib/js/ajax.js | 15 +++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/KibanaConfig.rb b/KibanaConfig.rb index b9f077388..b2a2abfb2 100644 --- a/KibanaConfig.rb +++ b/KibanaConfig.rb @@ -27,7 +27,8 @@ module KibanaConfig # Results to show per page Per_page = 50 - # Maximum number of lines to display in collapsed view + # Maximum number of lines from multiline fields to display in collapsed view. + # Affects all Default_fields Max_lines = 5 # Timezone. Leave this set to 'user' to have the user's browser autocorrect. diff --git a/static/lib/js/ajax.js b/static/lib/js/ajax.js index bd852892a..edb324a30 100644 --- a/static/lib/js/ajax.js +++ b/static/lib/js/ajax.js @@ -855,18 +855,13 @@ function CreateLogTable(objArray, fields, theme, enableHeader) { var value = get_field_value(object,field) var value = value === undefined ? "-" : value.toString(); // cut long events like stack traces after Max_lines - // TODO: make fields configurable var maxlines = window.resultjson.kibana.maxlines; - if (field == '@message') { - var fullvalue = xmlEnt(wbr(value, 10)).split('
').slice(0); - if (fullvalue.length > maxlines) { - var omitted = fullvalue.length - maxlines; - var shortvalue = fullvalue.slice(0, maxlines).join('
') + '
[...' + omitted + ' lines omitted...]'; - } else { - var shortvalue = fullvalue.join('
'); - } + var fullvalue = xmlEnt(wbr(value, 10)).split('
').slice(0); + if (fullvalue.length > maxlines) { + var omitted = fullvalue.length - maxlines; + var shortvalue = fullvalue.slice(0, maxlines).join('
') + '
[...' + omitted + ' lines omitted...]'; } else { - var shortvalue = xmlEnt(wbr(value, 10)); + var shortvalue = fullvalue.join('
'); } str += '' + shortvalue + '';