fluent-plugin-https-json 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README.md +25 -0
- data/fluent-plugin-https-json.gemspec +21 -0
- data/lib/fluent/plugin/out_https_json.rb +62 -0
- metadata +113 -0
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
fluentd_https_out
|
2
|
+
=================
|
3
|
+
|
4
|
+
A fluentd buffered output filter that posts to https a json array of records
|
5
|
+
|
6
|
+
Installation
|
7
|
+
=================
|
8
|
+
|
9
|
+
gem install 'fluent-plugin-https-json'
|
10
|
+
|
11
|
+
Usage
|
12
|
+
=================
|
13
|
+
|
14
|
+
```
|
15
|
+
<match SOME_EVENT>
|
16
|
+
type https_json
|
17
|
+
buffer_path /tmp/buffer
|
18
|
+
|
19
|
+
buffer_chunk_limit 256m
|
20
|
+
buffer_queue_limit 128
|
21
|
+
flush_interval 10s
|
22
|
+
endpoint http://127.0.0.1:3000/consume_json_arrays_of_some_event/
|
23
|
+
|
24
|
+
</match>
|
25
|
+
```
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "fluent-plugin-https-json"
|
5
|
+
gem.version = "0.0.1"
|
6
|
+
gem.authors = ["Jay OConnor"]
|
7
|
+
gem.email = ["jaydoconnor@gmail.com"]
|
8
|
+
gem.summary = %q{Fluentd output plugin to buffer logs as json arrays to a url}
|
9
|
+
gem.description = gem.summary
|
10
|
+
gem.homepage = "https://github.com/jdoconnor/fluentd_https_out"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
|
17
|
+
gem.add_development_dependency "bundler"
|
18
|
+
gem.add_development_dependency "json"
|
19
|
+
gem.add_development_dependency "fluentd"
|
20
|
+
gem.add_runtime_dependency "fluentd"
|
21
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class Fluent::HttpsJsonOutput < Fluent::TimeSlicedOutput
|
2
|
+
# First, register the plugin. NAME is the name of this plugin
|
3
|
+
# and identifies the plugin in the configuration file.
|
4
|
+
Fluent::Plugin.register_output('https_json', self)
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
require 'net/http'
|
8
|
+
require 'net/https'
|
9
|
+
require 'uri'
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
# This method is called before starting.
|
14
|
+
# 'conf' is a Hash that includes configuration parameters.
|
15
|
+
# If the configuration is invalid, raise Fluent::ConfigError.
|
16
|
+
def configure(conf)
|
17
|
+
super
|
18
|
+
@uri = URI.parse(conf['endpoint'])
|
19
|
+
@http = Net::HTTP.new(@uri.host,@uri.port)
|
20
|
+
@https = Net::HTTP.new(@uri.host,@uri.port)
|
21
|
+
@https.use_ssl = true
|
22
|
+
@use_https = conf['use_https'] == 'true'
|
23
|
+
end
|
24
|
+
|
25
|
+
# This method is called when starting.
|
26
|
+
# Open sockets or files here.
|
27
|
+
def start
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
# This method is called when shutting down.
|
32
|
+
# Shutdown the thread and close sockets or files here.
|
33
|
+
def shutdown
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
## Optionally, you can use to_msgpack to serialize the object.
|
38
|
+
def format(tag, time, record)
|
39
|
+
[tag, time, record].to_msgpack
|
40
|
+
end
|
41
|
+
|
42
|
+
# This method is called every flush interval. Write the buffer chunk
|
43
|
+
# to files or databases here.
|
44
|
+
# 'chunk' is a buffer chunk that includes multiple formatted
|
45
|
+
# events. You can use 'data = chunk.read' to get all events and
|
46
|
+
# 'chunk.open {|io| ... }' to get IO objects.
|
47
|
+
def write(chunk)
|
48
|
+
events = []
|
49
|
+
chunk.msgpack_each {|(tag,time,record)|
|
50
|
+
events << {:tag => tag, :time => time, :record => record}
|
51
|
+
}
|
52
|
+
events = events.to_json
|
53
|
+
req = Net::HTTP::Post.new(@uri.path)
|
54
|
+
req.set_form_data({"events" => events})
|
55
|
+
if @use_https
|
56
|
+
res = @https.request(req)
|
57
|
+
else
|
58
|
+
res = @http.request(req)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-https-json
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jay OConnor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
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
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fluentd
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: fluentd
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Fluentd output plugin to buffer logs as json arrays to a url
|
79
|
+
email:
|
80
|
+
- jaydoconnor@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- Gemfile
|
86
|
+
- README.md
|
87
|
+
- fluent-plugin-https-json.gemspec
|
88
|
+
- lib/fluent/plugin/out_https_json.rb
|
89
|
+
homepage: https://github.com/jdoconnor/fluentd_https_out
|
90
|
+
licenses: []
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 1.8.24
|
110
|
+
signing_key:
|
111
|
+
specification_version: 3
|
112
|
+
summary: Fluentd output plugin to buffer logs as json arrays to a url
|
113
|
+
test_files: []
|