fluent-plugin-kibana-server 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/LICENSE.md +22 -0
- data/README.md +44 -0
- data/Rakefile +11 -0
- data/example.conf +8 -0
- data/fluent-plugin-kibana-server.gemspec +20 -0
- data/lib/fluent/plugin/in_kibana_server.rb +117 -0
- data/test/helper.rb +27 -0
- data/test/plugin/test_in_kibana_server.rb +72 -0
- metadata +75 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# fluent-plugin-kibana-server
|
2
|
+
|
3
|
+
Copyright (c) 2013 OKUNO Akihiro
|
4
|
+
|
5
|
+
Apache License, Version 2.0
|
6
|
+
|
7
|
+
----
|
8
|
+
# Kibana
|
9
|
+
|
10
|
+
Copyright 2012-2013 Elasticsearch BV
|
11
|
+
|
12
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you
|
13
|
+
may not use this file except in compliance with the License. You may
|
14
|
+
obtain a copy of the License at
|
15
|
+
|
16
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
|
18
|
+
Unless required by applicable law or agreed to in writing, software
|
19
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
20
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
21
|
+
implied. See the License for the specific language governing
|
22
|
+
permissions and limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Fluent::Plugin::KibanaServer
|
2
|
+
|
3
|
+
Fluent plugin to serve [Kibana](https://github.com/elasticsearch/kibana)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
`$ fluent-gem install fluent-plugin-kibana-server`
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
### Example
|
12
|
+
|
13
|
+
```
|
14
|
+
<source **>
|
15
|
+
type kibana_server
|
16
|
+
bind 0.0.0.0
|
17
|
+
port 24300
|
18
|
+
mount /kibana/
|
19
|
+
access_log_path /Users/okuno/tmp/var/log/kibana/access.log
|
20
|
+
elasticsearch_url http://localhost:9200
|
21
|
+
</source>
|
22
|
+
```
|
23
|
+
|
24
|
+
### Parameter
|
25
|
+
|
26
|
+
|parameter|description|default|
|
27
|
+
|---|---|---|
|
28
|
+
|bind|Local address for the server to bind to|0.0.0.0|
|
29
|
+
|port|Port to listen on|24300|
|
30
|
+
|mount|Root path of Kibana||
|
31
|
+
|access_log_path|Path to access log. No logs will be written if this parameter is ommited.||
|
32
|
+
|elasticsearch_url|URL of elasticsearch. This parameter is used in config.js of Kibana.||
|
33
|
+
|
34
|
+
## TODO
|
35
|
+
|
36
|
+
pathches welcome!
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/example.conf
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "fluent-plugin-kibana-server"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.authors = ["OKUNO Akihiro"]
|
8
|
+
s.email = ["choplin.choplin@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/choplin/fluent-plugin-kibana-server"
|
10
|
+
s.summary = %q{Fluentd plugin which serves Kibana within fluentd process}
|
11
|
+
s.description = s.summary
|
12
|
+
s.license = "Apache 2.0"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_runtime_dependency "fluentd"
|
20
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module Fluent
|
2
|
+
class KibanaServerInput < Input
|
3
|
+
Plugin.register_input('kibana_server', self)
|
4
|
+
|
5
|
+
PATH_TO_KIBANA = File.join(File.dirname(__FILE__), '../../../vendor/kibana-3.0.0milestone4')
|
6
|
+
CONFIG_JS_PATH = File.join(PATH_TO_KIBANA, 'config.js')
|
7
|
+
|
8
|
+
require 'webrick'
|
9
|
+
|
10
|
+
config_param :bind, :string, :default => '0.0.0.0'
|
11
|
+
config_param :port, :integer, :default => 24300
|
12
|
+
config_param :mount, :string, :default => '/'
|
13
|
+
config_param :access_log_path, :string, :default => nil
|
14
|
+
config_param :elasticsearch_url, :string, :default => nil
|
15
|
+
|
16
|
+
def start
|
17
|
+
$log.info "listening http server for kinaba on http://#{@bind}:#{@port}#{@mount}"
|
18
|
+
|
19
|
+
@access_log = File.open(@access_log_path, 'a') if @access_log_path
|
20
|
+
|
21
|
+
File.open(CONFIG_JS_PATH, 'w') {|f| f.write(kibana_config)}
|
22
|
+
|
23
|
+
@srv = WEBrick::HTTPServer.new({
|
24
|
+
:BindAddress => @bind,
|
25
|
+
:Port => @port,
|
26
|
+
:Logger => WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
|
27
|
+
:AccessLog => @access_log ? [[@access_log, WEBrick::AccessLog::CLF]] : [],
|
28
|
+
})
|
29
|
+
|
30
|
+
@srv.mount(@mount, WEBrick::HTTPServlet::FileHandler, PATH_TO_KIBANA)
|
31
|
+
|
32
|
+
@thread = Thread.new { @srv.start }
|
33
|
+
end
|
34
|
+
|
35
|
+
def shutdown
|
36
|
+
if @srv
|
37
|
+
@srv.shutdown
|
38
|
+
@srv = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
if @access_log and (not @access_log.closed?)
|
42
|
+
@access_log.close
|
43
|
+
end
|
44
|
+
|
45
|
+
if @thread
|
46
|
+
@thread.join
|
47
|
+
@thread = nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def kibana_config
|
54
|
+
elasticsearch = if @elasticsearch_url
|
55
|
+
%Q{"#{@elasticsearch_url}"}
|
56
|
+
else
|
57
|
+
%Q{"http://"+window.location.hostname+":9200"}
|
58
|
+
end
|
59
|
+
<<-CONFIG
|
60
|
+
/**
|
61
|
+
* These is the app's configuration, If you need to configure
|
62
|
+
* the default dashboard, please see dashboards/default
|
63
|
+
*/
|
64
|
+
define(['settings'],
|
65
|
+
function (Settings) {
|
66
|
+
|
67
|
+
|
68
|
+
return new Settings({
|
69
|
+
|
70
|
+
/**
|
71
|
+
* URL to your elasticsearch server. You almost certainly don't
|
72
|
+
* want 'http://localhost:9200' here. Even if Kibana and ES are on
|
73
|
+
* the same host
|
74
|
+
*
|
75
|
+
* By default this will attempt to reach ES at the same host you have
|
76
|
+
* elasticsearch installed on. You probably want to set it to the FQDN of your
|
77
|
+
* elasticsearch host
|
78
|
+
* @type {String}
|
79
|
+
*/
|
80
|
+
elasticsearch: #{elasticsearch},
|
81
|
+
|
82
|
+
/**
|
83
|
+
* The default ES index to use for storing Kibana specific object
|
84
|
+
* such as stored dashboards
|
85
|
+
* @type {String}
|
86
|
+
*/
|
87
|
+
kibana_index: "kibana-int",
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Panel modules available. Panels will only be loaded when they are defined in the
|
91
|
+
* dashboard, but this list is used in the "add panel" interface.
|
92
|
+
* @type {Array}
|
93
|
+
*/
|
94
|
+
panel_names: [
|
95
|
+
'histogram',
|
96
|
+
'map',
|
97
|
+
'pie',
|
98
|
+
'table',
|
99
|
+
'filtering',
|
100
|
+
'timepicker',
|
101
|
+
'text',
|
102
|
+
'fields',
|
103
|
+
'hits',
|
104
|
+
'dashcontrol',
|
105
|
+
'column',
|
106
|
+
'derivequeries',
|
107
|
+
'trends',
|
108
|
+
'bettermap',
|
109
|
+
'query',
|
110
|
+
'terms'
|
111
|
+
]
|
112
|
+
});
|
113
|
+
});
|
114
|
+
CONFIG
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
require 'fluent/plugin/in_kibana_server'
|
25
|
+
|
26
|
+
class Test::Unit::TestCase
|
27
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class KibanaServerInputTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
Fluent::Test.setup
|
9
|
+
end
|
10
|
+
|
11
|
+
BIND = '0.0.0.0'
|
12
|
+
PORT = 24300
|
13
|
+
MOUNT = '/kibana/'
|
14
|
+
ACCESS_LOG_PATH = File.join(File.dirname(__FILE__), 'access.log')
|
15
|
+
|
16
|
+
ELASTICSEARCH_URL = 'http://localhost:9200'
|
17
|
+
|
18
|
+
|
19
|
+
def create_driver(conf)
|
20
|
+
Fluent::Test::InputTestDriver.new(Fluent::KibanaServerInput).configure(conf)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_configure
|
24
|
+
d = create_driver(create_config)
|
25
|
+
|
26
|
+
assert_equal BIND, d.instance.bind
|
27
|
+
assert_equal PORT, d.instance.port
|
28
|
+
assert_equal MOUNT, d.instance.mount
|
29
|
+
assert_equal ACCESS_LOG_PATH, d.instance.access_log_path
|
30
|
+
assert_equal ELASTICSEARCH_URL, d.instance.elasticsearch_url
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_listen
|
34
|
+
d = create_driver(create_config(bind:'localhost'))
|
35
|
+
|
36
|
+
d.run do
|
37
|
+
res = Net::HTTP.get_response(URI.parse("http://localhost:#{PORT}#{MOUNT}"))
|
38
|
+
assert_equal Net::HTTPOK, res.class
|
39
|
+
end
|
40
|
+
|
41
|
+
FileUtils.rm_f ACCESS_LOG_PATH
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_access_log
|
45
|
+
d = create_driver(create_config(bind:'localhost'))
|
46
|
+
d.run
|
47
|
+
assert_equal true, File.file?(ACCESS_LOG_PATH)
|
48
|
+
FileUtils.rm_f ACCESS_LOG_PATH
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def create_config(opts={})
|
54
|
+
merged = {
|
55
|
+
bind: BIND,
|
56
|
+
port: PORT,
|
57
|
+
mount: MOUNT,
|
58
|
+
access_log_path: ACCESS_LOG_PATH,
|
59
|
+
elasticsearch_url: ELASTICSEARCH_URL,
|
60
|
+
}.merge(opts)
|
61
|
+
|
62
|
+
%Q{
|
63
|
+
type kibana_server
|
64
|
+
bind #{merged[:bind]}
|
65
|
+
port #{merged[:port]}
|
66
|
+
mount #{merged[:mount]}
|
67
|
+
access_log_path #{merged[:access_log_path]}
|
68
|
+
elasticsearch_url #{merged[:elasticsearch_url]}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-kibana-server
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- OKUNO Akihiro
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Fluentd plugin which serves Kibana within fluentd process
|
31
|
+
email:
|
32
|
+
- choplin.choplin@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.md
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- example.conf
|
43
|
+
- fluent-plugin-kibana-server.gemspec
|
44
|
+
- lib/fluent/plugin/in_kibana_server.rb
|
45
|
+
- test/helper.rb
|
46
|
+
- test/plugin/test_in_kibana_server.rb
|
47
|
+
homepage: https://github.com/choplin/fluent-plugin-kibana-server
|
48
|
+
licenses:
|
49
|
+
- Apache 2.0
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.23
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Fluentd plugin which serves Kibana within fluentd process
|
72
|
+
test_files:
|
73
|
+
- test/helper.rb
|
74
|
+
- test/plugin/test_in_kibana_server.rb
|
75
|
+
has_rdoc:
|