kibana-rack 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -2
- data.tar.gz.sig +0 -0
- data/AUTHORS.md +9 -0
- data/CHANGELOG.md +4 -0
- data/lib/kibana/rack/version.rb +1 -1
- data/lib/kibana/rack/web.rb +54 -11
- data/spec/unit/kibana/rack/web_spec.rb +33 -4
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9b991332964c43f341d86bf0eb6f037aba64e76
|
4
|
+
data.tar.gz: 5c25476aa7ac8daee036ec839b4b86d3eaa5fc4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7339e39d1c59ae6be114aa0f5031e9ceac796272fa4e884059a3e188c9baa36b14f62c7b43f105ba7917bf867128dd55b974b3e6b0a912ff8f586dbf3fff748
|
7
|
+
data.tar.gz: 4c51e220d44aa5ee78d133314651b9c47a79a4cea0048bdacf90270fc4b88f99de16758a1f1d546e854337825da8443387a15047f94632a4f4bd857e4c26f66d
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�t�H���r�γ����9��YX<);��YI�Nnv���*���m)!�W9]��e�?A5D=��S��Ӗ�bڥ�6�%H?��%�Y�+� ��:�@��� �^�r�F레Iך>��C��l���/�AƵ??�bx�{p
|
2
|
+
'�@Ycm.�$+fqq�Dz�Ct��F�Ԯ;�9�'��S�;��V��
|
3
|
+
�w����*Pq>}]
|
data.tar.gz.sig
CHANGED
Binary file
|
data/AUTHORS.md
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Change history for kibana-rack
|
2
2
|
|
3
|
+
## [v0.1.4](https://github.com/tabolario/kibana-rack/releases/tag/v0.1.4)
|
4
|
+
|
5
|
+
* [Bug] [Proxy temporary and permanent dashboards to ES](https://github.com/tabolario/kibana-rack/pull/12) - [dcarley](https://github.com/dcarley)
|
6
|
+
|
3
7
|
## [v0.1.3](https://github.com/tabolario/kibana-rack/releases/tag/v0.1.3)
|
4
8
|
|
5
9
|
* [Bug] [Serve dashboard files from app/dashboards](https://github.com/tabolario/kibana-rack/issues/10)
|
data/lib/kibana/rack/version.rb
CHANGED
data/lib/kibana/rack/web.rb
CHANGED
@@ -15,11 +15,33 @@ module Kibana
|
|
15
15
|
set :kibana_index, -> { Kibana.kibana_index }
|
16
16
|
|
17
17
|
helpers do
|
18
|
+
def validate_kibana_index_name
|
19
|
+
render_not_found unless params[:index] == settings.kibana_index
|
20
|
+
end
|
21
|
+
|
18
22
|
def proxy
|
19
23
|
es_host = settings.elasticsearch_host
|
20
24
|
es_port = settings.elasticsearch_port
|
21
25
|
@proxy ||= Faraday.new(url: "http://#{es_host}:#{es_port}")
|
22
26
|
end
|
27
|
+
|
28
|
+
def proxy_es_request
|
29
|
+
request.body.rewind
|
30
|
+
|
31
|
+
proxy_method = request.request_method.downcase.to_sym
|
32
|
+
proxy_response = proxy.send(proxy_method) do |proxy_request|
|
33
|
+
proxy_request.url(request.path_info)
|
34
|
+
proxy_request.headers['Content-Type'] = 'application/json'
|
35
|
+
proxy_request.params = env['rack.request.query_hash']
|
36
|
+
proxy_request.body = request.body.read if [:post, :put].include?(proxy_method)
|
37
|
+
end
|
38
|
+
|
39
|
+
[proxy_response.status, proxy_response.headers, proxy_response.body]
|
40
|
+
end
|
41
|
+
|
42
|
+
def render_not_found
|
43
|
+
halt(404, '<h1>Not Found</h1>')
|
44
|
+
end
|
23
45
|
end
|
24
46
|
|
25
47
|
get '/' do
|
@@ -36,25 +58,46 @@ module Kibana
|
|
36
58
|
dashboard_ext = params[:captures][1]
|
37
59
|
dashboard_path = File.join(settings.kibana_dashboards_path, "#{dashboard_name}.#{dashboard_ext}")
|
38
60
|
|
39
|
-
|
61
|
+
render_not_found unless File.exist?(dashboard_path)
|
40
62
|
|
41
63
|
template = IO.read(dashboard_path)
|
42
64
|
content_type "application/#{dashboard_ext}"
|
43
65
|
erb template
|
44
66
|
end
|
45
67
|
|
46
|
-
route(:delete, :get, :post, :put,
|
47
|
-
|
68
|
+
route(:delete, :get, :post, :put, '/_aliases') do
|
69
|
+
proxy_es_request
|
70
|
+
end
|
48
71
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
72
|
+
route(:delete, :get, :post, :put, '/_nodes') do
|
73
|
+
proxy_es_request
|
74
|
+
end
|
75
|
+
|
76
|
+
route(:delete, :get, :post, :put, '/:index/_aliases') do
|
77
|
+
proxy_es_request
|
78
|
+
end
|
79
|
+
|
80
|
+
route(:delete, :get, :post, :put, '/:index/_mapping') do
|
81
|
+
proxy_es_request
|
82
|
+
end
|
83
|
+
|
84
|
+
route(:delete, :get, :post, :put, '/:index/_search') do
|
85
|
+
proxy_es_request
|
86
|
+
end
|
87
|
+
|
88
|
+
route(:delete, :get, :post, :put, '/:index/temp') do
|
89
|
+
validate_kibana_index_name
|
90
|
+
proxy_es_request
|
91
|
+
end
|
92
|
+
|
93
|
+
route(:delete, :get, :post, :put, '/:index/temp/:name') do
|
94
|
+
validate_kibana_index_name
|
95
|
+
proxy_es_request
|
96
|
+
end
|
56
97
|
|
57
|
-
|
98
|
+
route(:delete, :get, :post, :put, '/:index/dashboard/:dashboard') do
|
99
|
+
validate_kibana_index_name
|
100
|
+
proxy_es_request
|
58
101
|
end
|
59
102
|
end
|
60
103
|
end
|
@@ -3,14 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe Kibana::Rack::Web do
|
4
4
|
include Rack::Test::Methods
|
5
5
|
|
6
|
-
|
6
|
+
KIBANA_INDEX = 'test-int'
|
7
7
|
|
8
|
+
let(:app) { described_class }
|
8
9
|
let(:dashboards_path) { File.expand_path('../../../../fixtures/dashboards', __FILE__) }
|
9
10
|
|
10
11
|
before do
|
11
12
|
app.set(:raise_exceptions, true)
|
12
13
|
app.set(:show_exceptions, false)
|
13
14
|
app.set(:kibana_dashboards_path, dashboards_path)
|
15
|
+
app.set(:kibana_index, KIBANA_INDEX)
|
14
16
|
end
|
15
17
|
|
16
18
|
it 'serves the Kibana application' do
|
@@ -49,17 +51,44 @@ describe Kibana::Rack::Web do
|
|
49
51
|
it 'returns 404 if a dashboard does not exist' do
|
50
52
|
get '/app/dashboards/nonexistent.json'
|
51
53
|
|
52
|
-
expect(last_response.body.strip).to eql('
|
54
|
+
expect(last_response.body.strip).to eql('<h1>Not Found</h1>')
|
53
55
|
expect(last_response.status).to eql(404)
|
54
56
|
end
|
55
57
|
|
58
|
+
[
|
59
|
+
%w(put /_cluster/settings),
|
60
|
+
%w(post /_shutdown),
|
61
|
+
%w(post /_cluster/nodes/_shutdown),
|
62
|
+
%w(delete /*),
|
63
|
+
%w(delete /_all),
|
64
|
+
%w(delete /_all/_query?q=*),
|
65
|
+
%w(delete /logstash-2014.08.08/_query?q=*),
|
66
|
+
%w(delete /logstash-2014.08.08),
|
67
|
+
%w(post /logstash-2014.08.08),
|
68
|
+
%w(put /logstash-2014.08.08/message/123),
|
69
|
+
%w(post /logstash-2014.08.08/message/123/_update),
|
70
|
+
%w(get /logstash-2014.08.08/dashboard/123),
|
71
|
+
%w(get /logstash-2014.08.08/temp/123)
|
72
|
+
].each do |method, path|
|
73
|
+
it "should prevent #{method.upcase} #{path} being proxied to Elasticsearch" do
|
74
|
+
send(method, path)
|
75
|
+
|
76
|
+
expect(last_response.body.strip).to eql('<h1>Not Found</h1>')
|
77
|
+
expect(last_response.status).to eql(404)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
56
81
|
{
|
57
82
|
'/_aliases' => { method: :get },
|
58
83
|
'/_nodes' => { method: :get },
|
59
84
|
'/_all/_aliases' => { method: :get },
|
60
85
|
'/_all/_mapping' => { method: :get },
|
61
86
|
'/_all/_search' => { method: :post, body: '{"j":"s","o":"n"}' },
|
62
|
-
'/logstash-2014.08.08,logstash-2014.08.09/_aliases' => { method: :get, params: { ignore_missing: 'true' } }
|
87
|
+
'/logstash-2014.08.08,logstash-2014.08.09/_aliases' => { method: :get, params: { ignore_missing: 'true' } },
|
88
|
+
"/#{KIBANA_INDEX}/temp?ttl=30d" => { method: :post, body: '{"j":"s","o":"n"}' },
|
89
|
+
"/#{KIBANA_INDEX}/temp/GjO0MfT5QL6dLqOytd6qDw" => { method: :get, params: { cache: 123 } },
|
90
|
+
"/#{KIBANA_INDEX}/dashboard/read_example" => { method: :get, params: { cache: 123 } },
|
91
|
+
"/#{KIBANA_INDEX}/dashboard/write_example" => { method: :put, body: '{"j":"s","o":"n"}' }
|
63
92
|
}.each do |path, options|
|
64
93
|
it "proxies #{options[:method].upcase} #{path} to Elasticsearch" do
|
65
94
|
request_method = options[:method]
|
@@ -67,7 +96,7 @@ describe Kibana::Rack::Web do
|
|
67
96
|
.with(body: options[:body], query: options[:params])
|
68
97
|
.to_return(body: '{}', headers: { 'foo' => 'bar' }, status: 200)
|
69
98
|
|
70
|
-
request_params =
|
99
|
+
request_params = options[:body] || options[:params]
|
71
100
|
send(request_method, path, request_params)
|
72
101
|
|
73
102
|
expect(last_response.body).to eql('{}')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kibana-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Burns
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
WdK2SktNC0LYNRz+x3DdkcnVGS5BbSE7CYk7ap0J9jTobkmBTZ6tNWhVQiy7eJLr
|
31
31
|
pOgabsoLeT6zXAW+EOudMh1S/ZA=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-08-
|
33
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: faraday
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- ".simplecov"
|
105
105
|
- ".travis.yml"
|
106
106
|
- ".yardopts"
|
107
|
+
- AUTHORS.md
|
107
108
|
- CHANGELOG.md
|
108
109
|
- CONTRIBUTING.md
|
109
110
|
- Gemfile
|
metadata.gz.sig
CHANGED
Binary file
|