fluent-plugin-rabbitmq 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +7 -0
- data/COPYING +13 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +176 -0
- data/README.md +108 -0
- data/Rakefile +11 -0
- data/fluent-plugin-rabbitmq.gemspec +27 -0
- data/lib/fluent/plugin/in_rabbitmq.rb +128 -0
- data/lib/fluent/plugin/out_rabbitmq.rb +146 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e47609ed6424f827a4e7e47740ee8db04b857f42
|
4
|
+
data.tar.gz: 7f1d1754879e16b920056d3e8ae11afd81819959
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f2d0d0626e4c28642d7ea0722d00685d46209a3e8990c6911e65faaf77a668661dd119ea5533208399fee4436dbc44c776ec638fb85ad1ae68a66df424c3786
|
7
|
+
data.tar.gz: e4d094626d1a8332f1e2a15a7003f7ed4b5bcb7a097fc4c8f80f65a0cd46eeb5d4e478ba09f5e72387f69d5ab451e895433de4bf6446d22c8d57bbf05a1cc0f1
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/COPYING
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2017 NTT Communications
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# fluent-plugin-rabbitmq
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/nttcom/fluent-plugin-rabbitmq.svg?branch=master)](https://travis-ci.org/nttcom/fluent-plugin-rabbitmq)
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
This repository includes input/output plugins for RabbitMQ.
|
8
|
+
|
9
|
+
## Requirements
|
10
|
+
|
11
|
+
fluentd >= 0.14.0
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
$ fluent-gem install fluent-plugin-rabbitmq
|
16
|
+
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
### Input
|
20
|
+
|
21
|
+
```
|
22
|
+
<source>
|
23
|
+
@type rabbitmq
|
24
|
+
tag foo
|
25
|
+
host 127.0.0.1
|
26
|
+
# or hosts ["192.168.1.1", "192.168.1.2"]
|
27
|
+
user guest
|
28
|
+
pass guest
|
29
|
+
vhost /
|
30
|
+
exchange foo # not required. if specified, the queue will be bound to the exchange
|
31
|
+
queue bar
|
32
|
+
routing_key hoge # if not specified, the tag is used
|
33
|
+
heartbeat 10 # integer as seconds or :server (interval specified by server)
|
34
|
+
<parse>
|
35
|
+
@type json # or msgpack, ltsv, none
|
36
|
+
</parse>
|
37
|
+
</source>
|
38
|
+
```
|
39
|
+
|
40
|
+
#### Other Configurations for Input
|
41
|
+
|
42
|
+
|key|example|default value|description|
|
43
|
+
|:--|---|---|---|
|
44
|
+
|durable|true|false|set durable flag of the queue|
|
45
|
+
|exclusive|true|false|set exclusive flag of the queue|
|
46
|
+
|auto_delete|true|false|set auto_delete flag of the queue|
|
47
|
+
|prefetch_count|10|nil||
|
48
|
+
|consumer_pool_size|5|nil||
|
49
|
+
|
50
|
+
### Output
|
51
|
+
|
52
|
+
```
|
53
|
+
<match pattern>
|
54
|
+
@type rabbitmq
|
55
|
+
host 127.0.0.1
|
56
|
+
# or hosts ["192.168.1.1", "192.168.1.2"]
|
57
|
+
user guest
|
58
|
+
pass guest
|
59
|
+
vhost /
|
60
|
+
format json # or msgpack, ltsv, none
|
61
|
+
exchange foo # required: name of exchange
|
62
|
+
exchange_type fanout # required: type of exchange e.g. topic, direct
|
63
|
+
exchange_durable false
|
64
|
+
routing_key hoge # if not specified, the tag is used
|
65
|
+
heartbeat 10 # integer as seconds or :server (interval specified by server)
|
66
|
+
<format>
|
67
|
+
@type json # or msgpack, ltsv, none
|
68
|
+
</format>
|
69
|
+
</match>
|
70
|
+
```
|
71
|
+
|
72
|
+
#### Other Configurations for Output
|
73
|
+
|
74
|
+
|key|example|default value|description|
|
75
|
+
|:--|---|---|---|
|
76
|
+
|persistent|true|false|messages is persistent to disk|
|
77
|
+
|timestamp|true|false|if true, time of record is used as timestamp in AMQP message|
|
78
|
+
|content_type|application/json|nil|message content type|
|
79
|
+
|mandatory||true|nil||
|
80
|
+
|expiration|3600|nil|message time-to-live|
|
81
|
+
|message_type||nil||
|
82
|
+
|priority||nil||
|
83
|
+
|app_id||nil||
|
84
|
+
|
85
|
+
### TLS related configurations
|
86
|
+
|
87
|
+
```
|
88
|
+
tls false # enable TLS or not
|
89
|
+
tls_cert /path/to/cert
|
90
|
+
tls_key /path/to/key
|
91
|
+
tls_ca_certificates ["/path/to/ca_certificate"]
|
92
|
+
verify_peer true
|
93
|
+
```
|
94
|
+
|
95
|
+
### Other Configurations for Input/Output
|
96
|
+
|
97
|
+
|key|example|default value|description|
|
98
|
+
|:--|---|---|---|
|
99
|
+
|automatically_recover|true|nil|automatic network failure recovery|
|
100
|
+
|network_recovery_interval|30|nil|interval between reconnection attempts|
|
101
|
+
|recovery_attempts|3|nil|limits the number of connection recovery|
|
102
|
+
|connection_timeout|30|nil||
|
103
|
+
|continuation_timeout|600|nil||
|
104
|
+
|
105
|
+
## License
|
106
|
+
|
107
|
+
The gem is available as open source under the terms of the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt).
|
108
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "fluent-plugin-rabbitmq"
|
6
|
+
spec.version = "0.0.1"
|
7
|
+
spec.authors = ["NTT Communications"]
|
8
|
+
spec.email = ["masaki.matsushita@ntt.com"]
|
9
|
+
|
10
|
+
spec.summary = %q{fluent plugin for rabbitmq (AMQP)}
|
11
|
+
spec.description = %q{fluent plugin for rabbitmq (AMQP)}
|
12
|
+
spec.homepage = "https://github.com/nttcom/fluent-plugin-rabbitmq"
|
13
|
+
spec.license = "Apache-2.0"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
spec.add_development_dependency "test-unit"
|
21
|
+
spec.add_development_dependency "ltsv"
|
22
|
+
spec.add_development_dependency "msgpack"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "fluentd", ">= 0.14.0"
|
25
|
+
|
26
|
+
spec.add_dependency "bunny", "~> 2.7.0"
|
27
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#
|
2
|
+
# fluent-plugin-rabbitmq
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
#
|
17
|
+
require "fluent/input"
|
18
|
+
|
19
|
+
module Fluent::Plugin
|
20
|
+
class RabbitMQInput < Input
|
21
|
+
Fluent::Plugin.register_input("rabbitmq", self)
|
22
|
+
|
23
|
+
helpers :parser, :compat_parameters
|
24
|
+
|
25
|
+
config_param :tag, :string
|
26
|
+
|
27
|
+
config_section :parse do
|
28
|
+
config_set_default :@type, "json"
|
29
|
+
end
|
30
|
+
|
31
|
+
config_param :host, :string, default: nil
|
32
|
+
config_param :hosts, :array, default: nil
|
33
|
+
config_param :port, :integer, default: nil
|
34
|
+
config_param :user, :string, default: nil
|
35
|
+
config_param :pass, :string, default: nil, secret: true
|
36
|
+
config_param :vhost, :string, default: nil
|
37
|
+
config_param :exchange, :string, default: nil
|
38
|
+
config_param :routing_key, :string, default: nil
|
39
|
+
config_param :connection_timeout, :time, default: nil
|
40
|
+
config_param :continuation_timeout, :integer, default: nil
|
41
|
+
config_param :automatically_recover, :bool, default: nil
|
42
|
+
config_param :network_recovery_interval, :time, default: nil
|
43
|
+
config_param :recovery_attempts, :integer, default: nil
|
44
|
+
config_param :auth_mechanism, :string, default: nil
|
45
|
+
config_param :heartbeat, default: nil do |param|
|
46
|
+
param == "server" ? :server : Integer(param)
|
47
|
+
end
|
48
|
+
config_param :consumer_pool_size, :integer, default: nil
|
49
|
+
|
50
|
+
config_param :tls, :bool, default: false
|
51
|
+
config_param :tls_cert, :string, default: nil
|
52
|
+
config_param :tls_key, :string, default: nil
|
53
|
+
config_param :tls_ca_certificates, :array, default: nil
|
54
|
+
config_param :verify_peer, :bool, default: true
|
55
|
+
|
56
|
+
config_param :queue, :string
|
57
|
+
config_param :durable, :bool, default: false
|
58
|
+
config_param :exclusive, :bool, default: false
|
59
|
+
config_param :auto_delete, :bool, default: false
|
60
|
+
|
61
|
+
config_param :prefetch_count, :integer, default: nil
|
62
|
+
|
63
|
+
def initialize
|
64
|
+
super
|
65
|
+
require "bunny"
|
66
|
+
end
|
67
|
+
|
68
|
+
def configure(conf)
|
69
|
+
compat_parameters_convert(conf, :parser)
|
70
|
+
|
71
|
+
super
|
72
|
+
|
73
|
+
bunny_options = {}
|
74
|
+
bunny_options[:host] = @host if @host
|
75
|
+
bunny_options[:hosts] = @hosts if @hosts
|
76
|
+
bunny_options[:port] = @port if @port
|
77
|
+
bunny_options[:user] = @user if @user
|
78
|
+
bunny_options[:pass] = @pass if @pass
|
79
|
+
bunny_options[:vhost] = @vhost if @vhost
|
80
|
+
bunny_options[:connection_timeout] = @connection_timeout if @connection_timeout
|
81
|
+
bunny_options[:continuation_timeout] = @continuation_timeout if @continuation_timeout
|
82
|
+
bunny_options[:automatically_recover] = @automatically_recover if @automatically_recover
|
83
|
+
bunny_options[:network_recovery_interval] = @network_recovery_interval if @network_recovery_interval
|
84
|
+
bunny_options[:recovery_attempts] = @recovery_attempts
|
85
|
+
bunny_options[:auth_mechanism] = @auth_mechanism if @auth_mechanism
|
86
|
+
bunny_options[:heartbeat] = @heartbeat if @heartbeat
|
87
|
+
bunny_options[:logger] = log
|
88
|
+
|
89
|
+
bunny_options[:tls] = @tls
|
90
|
+
bunny_options[:tls_cert] = @tls_cert if @tls_cert
|
91
|
+
bunny_options[:tls_key] = @tls_key if @tls_key
|
92
|
+
bunny_options[:tls_ca_certificates] = @tls_ca_certificates if @tls_ca_certificates
|
93
|
+
bunny_options[:verify_peer] = @verify_peer
|
94
|
+
|
95
|
+
@parser = parser_create
|
96
|
+
|
97
|
+
@routing_key ||= @tag
|
98
|
+
@bunny = Bunny.new(bunny_options)
|
99
|
+
end
|
100
|
+
|
101
|
+
def start
|
102
|
+
super
|
103
|
+
@bunny.start
|
104
|
+
channel = @bunny.create_channel(nil, @consumer_pool_size)
|
105
|
+
channel.prefetch(@prefetch_count) if @prefetch_count
|
106
|
+
queue = channel.queue(
|
107
|
+
@queue,
|
108
|
+
durable: @durable,
|
109
|
+
exclusive: @exclusive,
|
110
|
+
auto_delete: @auto_delete
|
111
|
+
)
|
112
|
+
if @exchange
|
113
|
+
queue.bind(@exchange, routing_key: @routing_key)
|
114
|
+
end
|
115
|
+
queue.subscribe do |delivery_info, properties, payload|
|
116
|
+
@parser.parse(payload) do |time, record|
|
117
|
+
time = properties[:timestamp] || time
|
118
|
+
router.emit(@tag, time, record)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def shutdown
|
124
|
+
@bunny.close
|
125
|
+
super
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#
|
2
|
+
# fluent-plugin-rabbitmq
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
#
|
17
|
+
require "fluent/output"
|
18
|
+
|
19
|
+
module Fluent::Plugin
|
20
|
+
class RabbitMQOutput < Output
|
21
|
+
Fluent::Plugin.register_output("rabbitmq", self)
|
22
|
+
|
23
|
+
helpers :formatter, :inject, :compat_parameters
|
24
|
+
|
25
|
+
config_section :format do
|
26
|
+
config_set_default :@type, "json"
|
27
|
+
end
|
28
|
+
|
29
|
+
config_param :host, :string, default: nil
|
30
|
+
config_param :hosts, :array, default: nil
|
31
|
+
config_param :port, :integer, default: nil
|
32
|
+
config_param :user, :string, default: nil
|
33
|
+
config_param :pass, :string, default: nil, secret: true
|
34
|
+
config_param :vhost, :string, default: nil
|
35
|
+
config_param :connection_timeout, :time, default: nil
|
36
|
+
config_param :continuation_timeout, :integer, default: nil
|
37
|
+
config_param :automatically_recover, :bool, default: nil
|
38
|
+
config_param :network_recovery_interval, :time, default: nil
|
39
|
+
config_param :recovery_attempts, :integer, default: nil
|
40
|
+
config_param :auth_mechanism, :string, default: nil
|
41
|
+
config_param :heartbeat, default: nil do |param|
|
42
|
+
param == "server" ? :server : Integer(param)
|
43
|
+
end
|
44
|
+
config_param :threaded, :bool, default: true
|
45
|
+
|
46
|
+
config_param :tls, :bool, default: false
|
47
|
+
config_param :tls_cert, :string, default: nil
|
48
|
+
config_param :tls_key, :string, default: nil
|
49
|
+
config_param :tls_ca_certificates, :array, default: nil
|
50
|
+
config_param :verify_peer, :bool, default: true
|
51
|
+
|
52
|
+
config_param :exchange, :string
|
53
|
+
config_param :exchange_type, :string
|
54
|
+
config_param :exchange_durable, :bool, default: false
|
55
|
+
|
56
|
+
config_param :persistent, :bool, default: false
|
57
|
+
config_param :routing_key, :string, default: nil
|
58
|
+
config_param :timestamp, :bool, default: false
|
59
|
+
config_param :content_type, :string, default: nil
|
60
|
+
config_param :mandatory, :bool, default: nil
|
61
|
+
config_param :expiration, :integer, default: nil
|
62
|
+
config_param :message_type, :integer, default: nil
|
63
|
+
config_param :priority, :integer, default: nil
|
64
|
+
config_param :app_id, :string, default: nil
|
65
|
+
|
66
|
+
def initialize
|
67
|
+
super
|
68
|
+
require "bunny"
|
69
|
+
end
|
70
|
+
|
71
|
+
def configure(conf)
|
72
|
+
compat_parameters_convert(conf, :inject, :formatter, default_chunk_key: "time")
|
73
|
+
super
|
74
|
+
|
75
|
+
bunny_options = {}
|
76
|
+
bunny_options[:host] = @host if @host
|
77
|
+
bunny_options[:hosts] = @hosts if @hosts
|
78
|
+
bunny_options[:port] = @port if @port
|
79
|
+
bunny_options[:user] = @user if @user
|
80
|
+
bunny_options[:pass] = @pass if @pass
|
81
|
+
bunny_options[:vhost] = @vhost if @vhost
|
82
|
+
bunny_options[:connection_timeout] = @connection_timeout if @connection_timeout
|
83
|
+
bunny_options[:continuation_timeout] = @continuation_timeout if @continuation_timeout
|
84
|
+
bunny_options[:automatically_recover] = @automatically_recover if @automatically_recover
|
85
|
+
bunny_options[:network_recovery_interval] = @network_recovery_interval if @network_recovery_interval
|
86
|
+
bunny_options[:recovery_attempts] = @recovery_attempts
|
87
|
+
bunny_options[:auth_mechanism] = @auth_mechanism if @auth_mechanism
|
88
|
+
bunny_options[:heartbeat] = @heartbeat if @heartbeat
|
89
|
+
bunny_options[:threaded] = @threaded
|
90
|
+
bunny_options[:logger] = log
|
91
|
+
|
92
|
+
bunny_options[:tls] = @tls
|
93
|
+
bunny_options[:tls_cert] = @tls_cert if @tls_cert
|
94
|
+
bunny_options[:tls_key] = @tls_key if @tls_key
|
95
|
+
bunny_options[:tls_ca_certificates] = @tls_ca_certificates if @tls_ca_certificates
|
96
|
+
bunny_options[:verify_peer] = @verify_peer
|
97
|
+
|
98
|
+
@bunny = Bunny.new(bunny_options)
|
99
|
+
|
100
|
+
@publish_options = {}
|
101
|
+
@publish_options[:content_type] = @content_type if @content_type
|
102
|
+
@publish_options[:persistent] = @persistent if @persistent
|
103
|
+
@publish_options[:mandatory] = @mandatory if @mandatory
|
104
|
+
@publish_options[:expiration] = @expiration if @expiration
|
105
|
+
@publish_options[:message_type] = @message_type if @message_type
|
106
|
+
@publish_options[:priority] = @priority if @priority
|
107
|
+
@publish_options[:app_id] = @app_id if @app_id
|
108
|
+
|
109
|
+
@formatter = formatter_create
|
110
|
+
end
|
111
|
+
|
112
|
+
def start
|
113
|
+
super
|
114
|
+
@bunny.start
|
115
|
+
@channel = @bunny.create_channel
|
116
|
+
exchange_options = {
|
117
|
+
durable: @exchange_durable,
|
118
|
+
auto_delete: @exchange_auto_delete
|
119
|
+
}
|
120
|
+
@bunny_exchange = Bunny::Exchange.new(@channel, @exchange_type, @exchange, exchange_options)
|
121
|
+
end
|
122
|
+
|
123
|
+
def shutdown
|
124
|
+
@bunny.close
|
125
|
+
super
|
126
|
+
end
|
127
|
+
|
128
|
+
def process(tag, es)
|
129
|
+
if @exchange_type != "fanout"
|
130
|
+
@publish_options[:routing_key] = @routing_key ? @routing_key : tag
|
131
|
+
end
|
132
|
+
es.each do |time, record|
|
133
|
+
@publish_options[:timestamp] = time.to_i if @timestamp
|
134
|
+
formatted = format(tag, time, record)
|
135
|
+
@bunny_exchange.publish(formatted, @publish_options)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def format(tag, time, record)
|
142
|
+
record = inject_values_to_record(tag, time, record)
|
143
|
+
@formatter.format(tag, time, record)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-rabbitmq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- NTT Communications
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ltsv
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: msgpack
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fluentd
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.14.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.14.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bunny
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.7.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.7.0
|
111
|
+
description: fluent plugin for rabbitmq (AMQP)
|
112
|
+
email:
|
113
|
+
- masaki.matsushita@ntt.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
120
|
+
- COPYING
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- fluent-plugin-rabbitmq.gemspec
|
126
|
+
- lib/fluent/plugin/in_rabbitmq.rb
|
127
|
+
- lib/fluent/plugin/out_rabbitmq.rb
|
128
|
+
homepage: https://github.com/nttcom/fluent-plugin-rabbitmq
|
129
|
+
licenses:
|
130
|
+
- Apache-2.0
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.6.12
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: fluent plugin for rabbitmq (AMQP)
|
152
|
+
test_files: []
|