Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Add raw export option #316

Open
wants to merge 1 commit into
base: kibana-ruby
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/kibana-app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,24 @@ def link_to url_fragment, mode=:full_url
end
end

get '/raw/:hash/?:count?' do
count = KibanaConfig::Export_show
# TODO: Make the count number above/below functional w/ hard limit setting
# count = params[:count].nil? ? 20000 : params[:count].to_i
sep = KibanaConfig::Export_delimiter

req = ClientRequest.new(params[:hash])
query = SortedQuery.new(req.search,req.from,req.to,0,count)
indices = Kelastic.index_range(req.from,req.to)
result = KelasticMulti.new(query,indices)
flat = KelasticResponse.flatten_response(result.response, %w{@message})

headers "Content-Type" => "text/plain",
"Content-Disposition" => "attachment;filename=Kibana_#{Time.now.to_i}.txt"

flat.map(&:first).join("\n")
end

# Transient URL Routes
#
# Access route
Expand Down
6 changes: 4 additions & 2 deletions public/lib/js/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,10 @@ function mFields(field) {
function feedLinks(obj) {
return "<a href=rss/" + Base64.encode(JSON.stringify(obj, null, '')) +">rss " +
"<i class='icon-rss'></i></a> "+
"<a href=export/" + Base64.encode(JSON.stringify(obj, null, '')) + ">export " +
"<i class='icon-hdd'></i></a> "+
"<a href=export/" + Base64.encode(JSON.stringify(obj, null, '')) + ">csv " +
"<i class='icon-table'></i></a> "+
"<a href=raw/" + Base64.encode(JSON.stringify(obj, null, '')) + ">raw " +
"<i class='icon-file'></i></a> "+
"<a href=stream#" + Base64.encode(JSON.stringify(obj, null, '')) + ">stream " +
"<i class='icon-dashboard'></i></a>"
}
Expand Down