fluent-plugin-rackspace-cloud-files 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.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/LICENSE.md +191 -0
- data/README.rdoc +119 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/fluent-plugin-rackspace-cloud-files.gemspec +26 -0
- data/lib/fluent/plugin/out_rackspace_cloud_files.rb +186 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 201ecc3eda9ed0df1575b007bb8cdda2520f2ed8
|
4
|
+
data.tar.gz: 3bf221888b302fd996b40f52226a2825b11a642a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a44131405adc403c7b5e4e4faeb8c8205d96e34512bee52453e10f548eed47020ae09ed1ecd54b0805f009f9e9b3e35dbb892df47df057fd4e6a4e38bd95a6c
|
7
|
+
data.tar.gz: ca51e0226d0258f5d552fff0e6ce62c3dc1ffbdf22bc7a25f57d350794b3828712c594cfd7854b77c30adeb05852a2e024a2c37e3fd0a6ee84dd3aac275859f1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
13
|
+
owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
21
|
+
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
23
|
+
permissions granted by this License.
|
24
|
+
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
27
|
+
files.
|
28
|
+
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
31
|
+
generated documentation, and conversions to other media types.
|
32
|
+
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
35
|
+
in or attached to the work (an example is provided in the Appendix below).
|
36
|
+
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
43
|
+
|
44
|
+
"Contribution" shall mean any work of authorship, including the original version
|
45
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
46
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
47
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
48
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
49
|
+
"submitted" means any form of electronic, verbal, or written communication sent
|
50
|
+
to the Licensor or its representatives, including but not limited to
|
51
|
+
communication on electronic mailing lists, source code control systems, and
|
52
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
53
|
+
the purpose of discussing and improving the Work, but excluding communication
|
54
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
55
|
+
owner as "Not a Contribution."
|
56
|
+
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
59
|
+
incorporated within the Work.
|
60
|
+
|
61
|
+
2. Grant of Copyright License.
|
62
|
+
|
63
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
64
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
65
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
66
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
67
|
+
Derivative Works in Source or Object form.
|
68
|
+
|
69
|
+
3. Grant of Patent License.
|
70
|
+
|
71
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
72
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
73
|
+
irrevocable (except as stated in this section) patent license to make, have
|
74
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
75
|
+
such license applies only to those patent claims licensable by such Contributor
|
76
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
77
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
78
|
+
submitted. If You institute patent litigation against any entity (including a
|
79
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
80
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
81
|
+
patent infringement, then any patent licenses granted to You under this License
|
82
|
+
for that Work shall terminate as of the date such litigation is filed.
|
83
|
+
|
84
|
+
4. Redistribution.
|
85
|
+
|
86
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
87
|
+
in any medium, with or without modifications, and in Source or Object form,
|
88
|
+
provided that You meet the following conditions:
|
89
|
+
|
90
|
+
You must give any other recipients of the Work or Derivative Works a copy of
|
91
|
+
this License; and
|
92
|
+
You must cause any modified files to carry prominent notices stating that You
|
93
|
+
changed the files; and
|
94
|
+
You must retain, in the Source form of any Derivative Works that You distribute,
|
95
|
+
all copyright, patent, trademark, and attribution notices from the Source form
|
96
|
+
of the Work, excluding those notices that do not pertain to any part of the
|
97
|
+
Derivative Works; and
|
98
|
+
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
99
|
+
Derivative Works that You distribute must include a readable copy of the
|
100
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
101
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
102
|
+
following places: within a NOTICE text file distributed as part of the
|
103
|
+
Derivative Works; within the Source form or documentation, if provided along
|
104
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
105
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
106
|
+
the NOTICE file are for informational purposes only and do not modify the
|
107
|
+
License. You may add Your own attribution notices within Derivative Works that
|
108
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
109
|
+
provided that such additional attribution notices cannot be construed as
|
110
|
+
modifying the License.
|
111
|
+
You may add Your own copyright statement to Your modifications and may provide
|
112
|
+
additional or different license terms and conditions for use, reproduction, or
|
113
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
114
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
115
|
+
with the conditions stated in this License.
|
116
|
+
|
117
|
+
5. Submission of Contributions.
|
118
|
+
|
119
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
120
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
121
|
+
conditions of this License, without any additional terms or conditions.
|
122
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
123
|
+
any separate license agreement you may have executed with Licensor regarding
|
124
|
+
such Contributions.
|
125
|
+
|
126
|
+
6. Trademarks.
|
127
|
+
|
128
|
+
This License does not grant permission to use the trade names, trademarks,
|
129
|
+
service marks, or product names of the Licensor, except as required for
|
130
|
+
reasonable and customary use in describing the origin of the Work and
|
131
|
+
reproducing the content of the NOTICE file.
|
132
|
+
|
133
|
+
7. Disclaimer of Warranty.
|
134
|
+
|
135
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
136
|
+
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
137
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
138
|
+
including, without limitation, any warranties or conditions of TITLE,
|
139
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
140
|
+
solely responsible for determining the appropriateness of using or
|
141
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
142
|
+
permissions under this License.
|
143
|
+
|
144
|
+
8. Limitation of Liability.
|
145
|
+
|
146
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
147
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
148
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
149
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
150
|
+
or consequential damages of any character arising as a result of this License or
|
151
|
+
out of the use or inability to use the Work (including but not limited to
|
152
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
153
|
+
any and all other commercial damages or losses), even if such Contributor has
|
154
|
+
been advised of the possibility of such damages.
|
155
|
+
|
156
|
+
9. Accepting Warranty or Additional Liability.
|
157
|
+
|
158
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
159
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
160
|
+
other liability obligations and/or rights consistent with this License. However,
|
161
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
162
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
163
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
164
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
165
|
+
accepting any such warranty or additional liability.
|
166
|
+
|
167
|
+
END OF TERMS AND CONDITIONS
|
168
|
+
|
169
|
+
APPENDIX: How to apply the Apache License to your work
|
170
|
+
|
171
|
+
To apply the Apache License to your work, attach the following boilerplate
|
172
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
173
|
+
identifying information. (Don't include the brackets!) The text should be
|
174
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
175
|
+
recommend that a file or class name and description of purpose be included on
|
176
|
+
the same "printed page" as the copyright notice for easier identification within
|
177
|
+
third-party archives.
|
178
|
+
|
179
|
+
Copyright 2015 Brint O'Hearn
|
180
|
+
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
182
|
+
you may not use this file except in compliance with the License.
|
183
|
+
You may obtain a copy of the License at
|
184
|
+
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
186
|
+
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
190
|
+
See the License for the specific language governing permissions and
|
191
|
+
limitations under the License.
|
data/README.rdoc
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
= Rackspace Cloud Files output plugin for Fluent event collector
|
2
|
+
|
3
|
+
== Overview
|
4
|
+
|
5
|
+
This has only been tested on fluentd version 0.12.12.
|
6
|
+
|
7
|
+
*rackspace-cloud-files* output plugin buffers event logs in local file and upload it to Rackspace Cloud Files periodically.
|
8
|
+
|
9
|
+
This plugin splits files exactly by using the time of event logs (not the time when the logs are received). For example, a log '2011-01-02 message B' is reached, and then another log '2011-01-03 message B' is reached in this order, the former one is stored in "20110102.gz" file, and latter one in "20110103.gz" file.
|
10
|
+
|
11
|
+
|
12
|
+
== Installation
|
13
|
+
|
14
|
+
Simply use RubyGems:
|
15
|
+
|
16
|
+
gem install fluent-plugin-rackspace-cloud-files
|
17
|
+
|
18
|
+
If you have fluentd installed, you will need to use it's embedded ruby installation to complete the install:
|
19
|
+
|
20
|
+
/usr/sbin/td-agent-gem install fluent-plugin-rackspace-cloud-files
|
21
|
+
|
22
|
+
|
23
|
+
== Configuration
|
24
|
+
|
25
|
+
<match pattern>
|
26
|
+
type rackspace_cloud_files
|
27
|
+
|
28
|
+
rackspace_auth_url, :string, :default => Fog::Rackspace::US_AUTH_ENDPOINT
|
29
|
+
rackspace_username rax-user
|
30
|
+
rackspace_api_key apikey
|
31
|
+
rackspace_container container_name
|
32
|
+
rackspace_region dfw
|
33
|
+
|
34
|
+
object_key_format %{path}%{time_slice}_%{index}.%{file_extension}
|
35
|
+
ssl_verify false
|
36
|
+
|
37
|
+
path logs/
|
38
|
+
buffer_path /var/log/fluent/rackspace-cloud-files
|
39
|
+
|
40
|
+
time_slice_format %Y%m%d-%H
|
41
|
+
time_slice_wait 10m
|
42
|
+
utc
|
43
|
+
</match>
|
44
|
+
|
45
|
+
[rackspace_auth_url] Authentication URL. Defaults to the Rackspace US endpoint.
|
46
|
+
|
47
|
+
[rackspace_username] Authentication User Name.
|
48
|
+
|
49
|
+
[rackspace_api_key] Authentication API Key.
|
50
|
+
|
51
|
+
[rackspace_container] Container name.
|
52
|
+
|
53
|
+
[object_key_format] The format of Rackspace Cloud Files object keys. You can use several built-in variables:
|
54
|
+
|
55
|
+
- %{path}
|
56
|
+
- %{time_slice}
|
57
|
+
- %{index}
|
58
|
+
- %{file_extension}
|
59
|
+
|
60
|
+
to decide keys dynamically.
|
61
|
+
|
62
|
+
%{path} is exactly the value of *path* configured in the configuration file. E.g., "logs/" in the example configuration above.
|
63
|
+
%{time_slice} is the time-slice in text that are formatted with *time_slice_format*.
|
64
|
+
%{index} is the sequential number starts from 0, increments when multiple files are uploaded to S3 in the same time slice.
|
65
|
+
%{file_extention} is always "gz" for now.
|
66
|
+
|
67
|
+
The default format is "%{path}%{time_slice}_%{index}.%{file_extension}".
|
68
|
+
|
69
|
+
For instance, using the example configuration above, actual object keys on Rackspace Cloud Files will be something like:
|
70
|
+
|
71
|
+
"logs/20130111-22_0.gz"
|
72
|
+
"logs/20130111-23_0.gz"
|
73
|
+
"logs/20130111-23_1.gz"
|
74
|
+
"logs/20130112-00_0.gz"
|
75
|
+
|
76
|
+
With the configuration:
|
77
|
+
|
78
|
+
object_key_format %{path}/events/ts=%{time_slice}/events_%{index}.%{file_extension}
|
79
|
+
path log
|
80
|
+
time_slice_format %Y%m%d-%H
|
81
|
+
|
82
|
+
You get:
|
83
|
+
|
84
|
+
"log/events/ts=20130111-22/events_0.gz"
|
85
|
+
"log/events/ts=20130111-23/events_0.gz"
|
86
|
+
"log/events/ts=20130111-23/events_1.gz"
|
87
|
+
"log/events/ts=20130112-00/events_0.gz"
|
88
|
+
|
89
|
+
The {fluent-mixin-config-placeholders}[https://github.com/tagomoris/fluent-mixin-config-placeholders] mixin is also incorporated, so additional variables such as %{hostname}, %{uuid}, etc. can be used in the s3_object_key_format. This could prove useful in preventing filename conflicts when writing from multiple servers.
|
90
|
+
|
91
|
+
object_key_format %{path}/events/ts=%{time_slice}/events_%{index}-%{hostname}.%{file_extension}
|
92
|
+
|
93
|
+
[store_as] archive format on Rackspace Cloud Files. You can use serveral format:
|
94
|
+
|
95
|
+
- gzip (default)
|
96
|
+
- json
|
97
|
+
- text
|
98
|
+
- lzo (Need lzop command)
|
99
|
+
|
100
|
+
[auto_create_container] Create Cloud Files container if it does not exists. Default is true.
|
101
|
+
|
102
|
+
[path] path prefix of the files on Cloud Files. Default is "" (no prefix).
|
103
|
+
|
104
|
+
[buffer_path (required)] path prefix of the files to buffer logs.
|
105
|
+
|
106
|
+
[time_slice_format] Format of the time used as the file name. Default is '%Y%m%d'. Use '%Y%m%d%H' to split files hourly.
|
107
|
+
|
108
|
+
[time_slice_wait] The time to wait old logs. Default is 10 minutes. Specify larger value if old logs may reache.
|
109
|
+
|
110
|
+
[utc] Use UTC instead of local time.
|
111
|
+
|
112
|
+
|
113
|
+
== Copyright
|
114
|
+
|
115
|
+
Copyright:: Copyright (c) 2015 Brint O'Hearn.
|
116
|
+
|
117
|
+
This software is based on fluent-plugin-swift ( https://github.com/yuuzi41/fluent-plugin-swift ), written by Yuji Hagiwara, licensed by Apache License, Version 2.0.
|
118
|
+
|
119
|
+
License:: Apache License, Version 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'rake/testtask'
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |test|
|
8
|
+
test.libs << 'lib' << 'test'
|
9
|
+
test.test_files = FileList['test/*.rb']
|
10
|
+
test.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => [:build]
|
14
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "fluent-plugin-rackspace-cloud-files"
|
6
|
+
gem.description = "Rackspace Cloud Files output plugin for Fluent event collector"
|
7
|
+
gem.homepage = "https://github.com/brint/fluent-plugin-rackspace-cloud-files"
|
8
|
+
gem.summary = gem.description
|
9
|
+
gem.version = File.read("VERSION").strip
|
10
|
+
gem.authors = ["brint"]
|
11
|
+
gem.email = "brintly@gmail.com"
|
12
|
+
gem.license = "Apache License 2.0"
|
13
|
+
gem.has_rdoc = false
|
14
|
+
#gem.platform = Gem::Platform::RUBY
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency "fluentd", "~> 0.12.12"
|
21
|
+
gem.add_dependency "fog", "~> 1.33.0"
|
22
|
+
gem.add_dependency "yajl-ruby", "~> 1.2.1"
|
23
|
+
gem.add_dependency "fluent-mixin-config-placeholders", "~> 0.3.0"
|
24
|
+
gem.add_development_dependency "rake", ">= 10.1.0"
|
25
|
+
gem.add_development_dependency "flexmock", ">= 1.2.0"
|
26
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
module Fluent
|
2
|
+
|
3
|
+
require 'fluent/mixin/config_placeholders'
|
4
|
+
|
5
|
+
class RackspaceCloudFilesOutput < TimeSlicedOutput
|
6
|
+
Fluent::Plugin.register_output('rackspace_cloud_files', self)
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
require 'fog'
|
11
|
+
require 'zlib'
|
12
|
+
require 'time'
|
13
|
+
require 'tempfile'
|
14
|
+
require 'open3'
|
15
|
+
end
|
16
|
+
|
17
|
+
config_param :path, :string, :default => ""
|
18
|
+
config_param :time_format, :string, :default => nil
|
19
|
+
|
20
|
+
include SetTagKeyMixin
|
21
|
+
config_set_default :include_tag_key, false
|
22
|
+
|
23
|
+
include SetTimeKeyMixin
|
24
|
+
config_set_default :include_time_key, false
|
25
|
+
|
26
|
+
config_param :rackspace_auth_url, :string, :default => "https://identity.api.rackspacecloud.com/v2.0"
|
27
|
+
config_param :rackspace_username, :string
|
28
|
+
config_param :rackspace_api_key, :string
|
29
|
+
config_param :rackspace_container, :string
|
30
|
+
config_param :rackspace_region, :string
|
31
|
+
|
32
|
+
config_param :object_key_format, :string, :default => "%{path}%{time_slice}_%{index}.%{file_extension}"
|
33
|
+
config_param :store_as, :string, :default => "gzip"
|
34
|
+
config_param :auto_create_container, :bool, :default => true
|
35
|
+
config_param :check_apikey_on_start, :bool, :default => true
|
36
|
+
config_param :proxy_uri, :string, :default => nil
|
37
|
+
config_param :ssl_verify, :bool, :default => true
|
38
|
+
|
39
|
+
# attr_reader :container
|
40
|
+
|
41
|
+
include Fluent::Mixin::ConfigPlaceholders
|
42
|
+
|
43
|
+
def placeholders
|
44
|
+
[:percent]
|
45
|
+
end
|
46
|
+
|
47
|
+
def configure(conf)
|
48
|
+
super
|
49
|
+
|
50
|
+
if format_json = conf['format_json']
|
51
|
+
@format_json = true
|
52
|
+
else
|
53
|
+
@format_json = false
|
54
|
+
end
|
55
|
+
|
56
|
+
@ext, @mime_type = case @store_as
|
57
|
+
when 'gzip' then ['gz', 'application/x-gzip']
|
58
|
+
when 'lzo' then
|
59
|
+
begin
|
60
|
+
Open3.capture3('lzop -V')
|
61
|
+
rescue Errno::ENOENT
|
62
|
+
raise ConfigError, "'lzop' utility must be in PATH for LZO compression"
|
63
|
+
end
|
64
|
+
['lzo', 'application/x-lzop']
|
65
|
+
when 'json' then ['json', 'application/json']
|
66
|
+
else ['txt', 'text/plain']
|
67
|
+
end
|
68
|
+
|
69
|
+
@timef = TimeFormatter.new(@time_format, @localtime)
|
70
|
+
|
71
|
+
if @localtime
|
72
|
+
@path_slicer = Proc.new {|path|
|
73
|
+
Time.now.strftime(path)
|
74
|
+
}
|
75
|
+
else
|
76
|
+
@path_slicer = Proc.new {|path|
|
77
|
+
Time.now.utc.strftime(path)
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def start
|
83
|
+
super
|
84
|
+
|
85
|
+
Excon.defaults[:ssl_verify_peer] = @ssl_verify
|
86
|
+
|
87
|
+
@storage = Fog::Storage.new :provider => 'Rackspace',
|
88
|
+
:rackspace_auth_url => @rackspace_auth_url,
|
89
|
+
:rackspace_username => @rackspace_username,
|
90
|
+
:rackspace_api_key => @rackspace_api_key,
|
91
|
+
:rackspace_region => @rackspace_region
|
92
|
+
|
93
|
+
check_container
|
94
|
+
end
|
95
|
+
|
96
|
+
def format(tag, time, record)
|
97
|
+
if @include_time_key || !@format_json
|
98
|
+
time_str = @timef.format(time)
|
99
|
+
end
|
100
|
+
|
101
|
+
# copied from each mixin because current TimeSlicedOutput can't support mixins.
|
102
|
+
if @include_tag_key
|
103
|
+
record[@tag_key] = tag
|
104
|
+
end
|
105
|
+
if @include_time_key
|
106
|
+
record[@time_key] = time_str
|
107
|
+
end
|
108
|
+
|
109
|
+
if @format_json
|
110
|
+
Yajl.dump(record) + "\n"
|
111
|
+
else
|
112
|
+
"#{time_str}\t#{tag}\t#{Yajl.dump(record)}\n"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def write(chunk)
|
117
|
+
i = 0
|
118
|
+
|
119
|
+
begin
|
120
|
+
path = @path_slicer.call(@path)
|
121
|
+
values_for_swift_object_key = {
|
122
|
+
"path" => path,
|
123
|
+
"time_slice" => chunk.key,
|
124
|
+
"file_extension" => @ext,
|
125
|
+
"index" => i
|
126
|
+
}
|
127
|
+
swift_path = @object_key_format.gsub(%r(%{[^}]+})) { |expr|
|
128
|
+
values_for_swift_object_key[expr[2...expr.size-1]]
|
129
|
+
}
|
130
|
+
i += 1
|
131
|
+
end while check_object_exists(@rackspace_container, swift_path)
|
132
|
+
|
133
|
+
tmp = Tempfile.new("rackspace-cloud-files-")
|
134
|
+
begin
|
135
|
+
if @store_as == "gzip"
|
136
|
+
w = Zlib::GzipWriter.new(tmp)
|
137
|
+
chunk.write_to(w)
|
138
|
+
w.close
|
139
|
+
elsif @store_as == "lzo"
|
140
|
+
w = Tempfile.new("chunk-tmp")
|
141
|
+
chunk.write_to(w)
|
142
|
+
w.close
|
143
|
+
tmp.close
|
144
|
+
# We don't check the return code because we can't recover lzop failure.
|
145
|
+
system "lzop -qf1 -o #{tmp.path} #{w.path}"
|
146
|
+
else
|
147
|
+
chunk.write_to(tmp)
|
148
|
+
tmp.close
|
149
|
+
end
|
150
|
+
File.open(tmp.path) do |file|
|
151
|
+
@storage.put_object(@rackspace_container, swift_path, file, {:content_type => @mime_type})
|
152
|
+
end
|
153
|
+
$log.info "Put Log to Rackspace Cloud Files. container=#{@rackspace_container} object=#{swift_path}"
|
154
|
+
ensure
|
155
|
+
tmp.close(true) rescue nil
|
156
|
+
w.close rescue nil
|
157
|
+
w.unlink rescue nil
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def check_container
|
164
|
+
begin
|
165
|
+
@storage.get_container(@rackspace_container)
|
166
|
+
rescue Fog::Storage::Rackspace::NotFound
|
167
|
+
if @auto_create_container
|
168
|
+
$log.info "Creating container #{@rackspace_container} in region #{@rackspace_region}"
|
169
|
+
@storage.put_container(@rackspace_container)
|
170
|
+
else
|
171
|
+
raise "The specified container does not exist: container = #{rackspace_container}"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def check_object_exists(container, object)
|
177
|
+
begin
|
178
|
+
@storage.head_object(container, object)
|
179
|
+
rescue Fog::Storage::Rackspace::NotFound
|
180
|
+
return false
|
181
|
+
end
|
182
|
+
return true
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-rackspace-cloud-files
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- brint
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.12.12
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.12.12
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fog
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.33.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.33.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yajl-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.2.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.2.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fluent-mixin-config-placeholders
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.3.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 10.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 10.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: flexmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.2.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.2.0
|
97
|
+
description: Rackspace Cloud Files output plugin for Fluent event collector
|
98
|
+
email: brintly@gmail.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
103
|
+
- ".gitignore"
|
104
|
+
- Gemfile
|
105
|
+
- LICENSE.md
|
106
|
+
- README.rdoc
|
107
|
+
- Rakefile
|
108
|
+
- VERSION
|
109
|
+
- fluent-plugin-rackspace-cloud-files.gemspec
|
110
|
+
- lib/fluent/plugin/out_rackspace_cloud_files.rb
|
111
|
+
homepage: https://github.com/brint/fluent-plugin-rackspace-cloud-files
|
112
|
+
licenses:
|
113
|
+
- Apache License 2.0
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.4.6
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Rackspace Cloud Files output plugin for Fluent event collector
|
135
|
+
test_files: []
|