fluent-plugin-mesosphere-filter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +19 -0
- data/.ruby-version +1 -0
- data/.travis.yml +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +201 -0
- data/README.md +3 -0
- data/Rakefile +11 -0
- data/fluent-plugin-mesosphere-filter.gemspec +36 -0
- data/lib/fluent/plugin/mesosphere.rb +104 -0
- data/test/containers/chronos.json +137 -0
- data/test/containers/marathon.json +187 -0
- data/test/helper.rb +51 -0
- data/test/plugin/test_mesosphere.rb +146 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODM4MTU1YmFjNGUyYWZjZTIzYTI1ZDUxZTE3MjZiZDY3ZWNhMWViYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTZhNTVhZWRjZTE3ODMzNGYwMjM4YzU5ZGMyNDNjM2JmY2Q5ZWM3Mg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTdkNTFiMjVkZTBkMDdhZDczZjc3ZGZhNzkzZGEyMjFlNTExYTU4ODliNjhk
|
10
|
+
ZGQ3NGU2NzdiYTZlZmY1NjYwM2MyOWY2ZDMwMTQ2ZDBjYzQyZGRmYzBkMjY2
|
11
|
+
MmQxZTM0YzdhMWNjNTY2Y2VkYzkwZTBhYzNjNzEzYzcyMjZjOGU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTNkNTA4OTYwY2JkYzgwYjQyZWJkNmI1YmNmOTAwYTE2MDJjOTk3MTEyZmU3
|
14
|
+
ZmJjOTA1ZDgyZTdjMWY5MDI5YTExNDhmM2FiNTY4ZmMxODJhMGNmMmNlMDRi
|
15
|
+
MDgxNDY2MmE3MzQzNDA2ZTQ3NWIyYTBkZjA5NmMwYjU5YzM5MjY=
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.7
|
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1.7
|
4
|
+
addons:
|
5
|
+
code_climate:
|
6
|
+
repo_token:
|
7
|
+
secure: c45OF+vJNaBMUDi5Rr+LvLtIvkDmrhub4dlAgRhqPvxwVC7PsS71JUOMV/6ZAVRA5u/05sABGwJPXaQDN+BRD2kF34u1PjTeFo1nglyqgwERikyh3pXYTM46T2nnjo/FDyaO0QW4SOxsQM8TYYFB7YnzfO8YOKRt2jOFlW0++yQ7wVyOl8r8mkSzZ0e0VLbYhcz/pF2tyWvx+DXEH4dgUe0ZbSfYTFrOadsmAhD+T4ivuKzI/GqfL6lmxynReKzALvPzKSmIL+9eGbyAej/VB8H8o5v/H7zb5QWMO49q8qysuz8Phh160ABRncX6NGqlUUOjt+FY+fwW3FTKpdM2X3BRAAm6kk9qzpx6db5vb3ES2NPFjO/P/DJCfYf+7iDNhSescTTa76aKKXiqYCFlEISUGKCJy3lPwJc8PeMyBO05rElLHbjJ3/G+v/wsbOIaQ/B4vkxMGLVkNR4liW6jd5pgxNmYTHrbkSCtyL0wyMfKEsW9zXjQE+fmUQgjhr1xic/qv+2bEsiTDWr9wjN5JQTPxEM+27M1TMA/+1chBGCGe54eYrSA3sHgtSpCF9DJ1lHzfikSF09bs/nCaicNdbQp9ej3/5Qgxnw+F17rQ4eR9dWuGsUw1o15GjOErMbQGRULV+UwekzSpm+D8pEVwnbHY0VTYxUjb2bE2YONBQY=
|
8
|
+
deploy:
|
9
|
+
provider: rubygems
|
10
|
+
api_key:
|
11
|
+
secure: sW92gLbqV2gnDMCzutJA9cZyoXj/1Z8uEjqWCxjehBbgWXLMJpfJ2JtUUXGaU2w01+hGrm10a1w5KfDJoRPa57bFfZ0TpRgF4mmBuxOTgfIRwMNoGDkgS4of0Z9nwZapEjwrF5ZVWdVph2qxVvJyMsxJ+F101VdvSminc79MhrZrO7h+jqivc68CsB8z/0R/16BHYryGcgdhHWMJ5qDeba4t+PQqwFIKRHhjmGKMjNIe3CufJh7NABvLJi8UFWLqeIpBu7xvJ0ihrD0VftDbJoEyXe15aEHmpGdj5M2LE/zXkKTvRIC5/SVx+zcB7jg+VXnFPwNi0Pcyrvme/lzykA4YxuB3os5tpDVgH1Y+DAsfHGEydFr+QJcHDvXjxGA9YlPt5kYKOb0OP12K8+wGOWdZCTmJYLC524Ed/XjgrqXEk1JFuLp+dix7YDQ4DNtfnElLuBGL5WdtxbqVIezcLpI2ZTIsvZdJp9PtPOtcT5FC/hd8PTU0A5nMFojrvdoi97OZQ7zjtmEUh06M4fGTDpWYth9qFLuwcXR12+ygQthSepKoKvkeXlS+1vZuk82RONYAoaJfcENApTsm1vpgr5uoYnoALIU8uSWpXr6pYvE4vJZx0KgY+fD9q3iAJsHhNrJCLJubvPCC+8QJPyml9Wl6bcD79MyH6C53ArtN0LY=
|
12
|
+
gem: fluent-plugin-mesosphere-filter
|
13
|
+
on:
|
14
|
+
repo: joshughes/fluent-plugin-mesosphere-filter
|
15
|
+
branch: master
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,201 @@
|
|
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,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
#MEsos Stuff
|
2
|
+
[![Code Climate](https://codeclimate.com/github/joshughes/fluent-plugin-mesosphere-filter/badges/gpa.svg)](https://codeclimate.com/github/joshughes/fluent-plugin-mesosphere-filter)
|
3
|
+
[![Test Coverage](https://codeclimate.com/github/joshughes/fluent-plugin-mesosphere-filter/badges/coverage.svg)](https://codeclimate.com/github/joshughes/fluent-plugin-mesosphere-filter/coverage)
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'fluent-plugin-mesosphere-filter'
|
7
|
+
gem.version = '0.1.0'
|
8
|
+
gem.authors = ['Joseph Hughes']
|
9
|
+
gem.email = ['jjhughes57@gmail.com']
|
10
|
+
gem.description = 'Filter plugin to add Mesosphere metadata'
|
11
|
+
gem.summary = 'Filter plugin to add Mesosphere metadata to fluentd from Chronos and Marathon'
|
12
|
+
gem.homepage = 'https://github.com/joshughes/fluent-plugin-mesosphere-filter'
|
13
|
+
gem.license = 'ASL2'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($RS)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
gem.has_rdoc = false
|
20
|
+
|
21
|
+
gem.required_ruby_version = '>= 2.0.0'
|
22
|
+
|
23
|
+
gem.add_runtime_dependency 'fluentd', '~> 0.12'
|
24
|
+
gem.add_runtime_dependency 'lru_redux', '~> 1.1'
|
25
|
+
gem.add_runtime_dependency 'docker-api', '~> 1.23'
|
26
|
+
gem.add_runtime_dependency 'oj'
|
27
|
+
|
28
|
+
gem.add_development_dependency 'bundler', '~> 1.3'
|
29
|
+
gem.add_development_dependency 'codeclimate-test-reporter'
|
30
|
+
gem.add_development_dependency 'rake'
|
31
|
+
gem.add_development_dependency 'webmock'
|
32
|
+
gem.add_development_dependency 'pry'
|
33
|
+
gem.add_development_dependency 'timecop'
|
34
|
+
gem.add_development_dependency 'simplecov'
|
35
|
+
gem.add_development_dependency 'minitest', '~> 4.0'
|
36
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd Mesosphere Metadata Filter Plugin
|
3
|
+
#
|
4
|
+
# Copyright 2015 Red Hat, Inc.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module Fluent
|
19
|
+
class MesosphereFilter < Fluent::Filter
|
20
|
+
Fluent::Plugin.register_filter('mesosphere-filter', self)
|
21
|
+
|
22
|
+
config_param :cache_size, :integer, default: 1000
|
23
|
+
config_param :cache_ttl, :integer, default: 60 * 60
|
24
|
+
|
25
|
+
config_param :merge_json_log, :bool, default: true
|
26
|
+
config_param :cronos_task_regex,
|
27
|
+
:string,
|
28
|
+
default: '(?<app>[a-z0-9]([-a-z0-9]*[a-z0-9]))-(?<date>[^-]+)-(?<time>[^-]+)-(?<task_type>[^-]+)-(?<run>[^-]+)-(?<epoc>[^-]+)'
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def configure(conf)
|
35
|
+
super
|
36
|
+
|
37
|
+
require 'docker-api'
|
38
|
+
require 'lru_redux'
|
39
|
+
require 'oj'
|
40
|
+
|
41
|
+
@cache_ttl = :none if @cache_ttl < 0
|
42
|
+
|
43
|
+
@cache = LruRedux::TTL::ThreadSafeCache.new(@cache_size, @cache_ttl)
|
44
|
+
|
45
|
+
@chronos_task_regex_compiled = Regexp.compile(@cronos_task_regex)
|
46
|
+
end
|
47
|
+
|
48
|
+
def filter_stream(tag, es)
|
49
|
+
new_es = MultiEventStream.new
|
50
|
+
|
51
|
+
container_id = tag.split('.').last
|
52
|
+
mesos_data = @cache.getset(container_id) do
|
53
|
+
get_container_metadata(container_id)
|
54
|
+
end
|
55
|
+
|
56
|
+
es.each do |time, record|
|
57
|
+
record = record.merge(mesos_data)
|
58
|
+
record = merge_json_log(record) if @merge_json_log
|
59
|
+
new_es.add(time, record)
|
60
|
+
end
|
61
|
+
|
62
|
+
new_es
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_container_metadata(id)
|
66
|
+
task_data = {}
|
67
|
+
container = Docker::Container.get(id)
|
68
|
+
if container
|
69
|
+
environment = container.json['Config']['Env']
|
70
|
+
environment.each do |env|
|
71
|
+
if env =~ /MESOS_TASK_ID/i
|
72
|
+
task_data['mesos_task_id'] = parse_env(env)
|
73
|
+
elsif env.include? 'MARATHON_APP_ID'
|
74
|
+
task_data['mesos_framework'] = 'marathon'
|
75
|
+
task_data['app'] = parse_env(env)
|
76
|
+
elsif env.include? 'CHRONOS_JOB_NAME'
|
77
|
+
match_data = parse_env(env).match(@chronos_task_regex_compiled)
|
78
|
+
task_data['mesos_framework'] = 'chronos'
|
79
|
+
task_data['app'] = match_data['app']
|
80
|
+
task_data['chronos_task_type'] = match_data['task_type']
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
task_data
|
85
|
+
end
|
86
|
+
|
87
|
+
def parse_env(env)
|
88
|
+
env.split('=').last
|
89
|
+
end
|
90
|
+
|
91
|
+
def merge_json_log(record)
|
92
|
+
if record.has_key?('log')
|
93
|
+
log = record['log'].strip
|
94
|
+
if log[0].eql?('{') && log[-1].eql?('}')
|
95
|
+
begin
|
96
|
+
record = Oj.load(log).merge(record)
|
97
|
+
rescue Oj::ParseError
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
record
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
{
|
2
|
+
"AppArmorProfile": "",
|
3
|
+
"Args": [
|
4
|
+
" task",
|
5
|
+
"task"
|
6
|
+
],
|
7
|
+
"Config": {
|
8
|
+
"AttachStderr": false,
|
9
|
+
"AttachStdin": false,
|
10
|
+
"AttachStdout": false,
|
11
|
+
"Cmd": [
|
12
|
+
" task",
|
13
|
+
"task"
|
14
|
+
],
|
15
|
+
"CpuShares": 153,
|
16
|
+
"Cpuset": "",
|
17
|
+
"Domainname": "",
|
18
|
+
"Entrypoint": [
|
19
|
+
"/minimal"
|
20
|
+
],
|
21
|
+
"Env": [
|
22
|
+
"mesos_task_id=ct:1448508194000:0:recurring-transaction2:task",
|
23
|
+
"CHRONOS_JOB_OWNER=chartreuse-team@itriagehealth.com",
|
24
|
+
"CHRONOS_JOB_NAME=some-task-app2-11182015-1718-deployTasks-1-1447867211",
|
25
|
+
"HOST=ip-10-10-30-60.ec2.internal",
|
26
|
+
"CHRONOS_RESOURCE_MEM=1024.0",
|
27
|
+
"CHRONOS_RESOURCE_CPU=0.05",
|
28
|
+
"CHRONOS_RESOURCE_DISK=256.0",
|
29
|
+
"YEAR=2016",
|
30
|
+
"VAULT_HOSTS=https://dev-use1a-pr-01-vault-vault-0001.dev-utopia.com:8200,https://dev-use1b-pr-01-vault-vault-0001.dev-utopia.com:8200,https://dev-use1e-pr-01-vault-vault-0001.dev-utopia.com:8200",
|
31
|
+
"MESOS_SANDBOX=/mnt/mesos/sandbox",
|
32
|
+
"PORT=80"
|
33
|
+
],
|
34
|
+
"ExposedPorts": {
|
35
|
+
"80/tcp": {}
|
36
|
+
},
|
37
|
+
"Hostname": "ip-10-10-30-60",
|
38
|
+
"Image": "docker-dev.itriagehealth.com/utopia/recurring-transaction2-task:564a03fd52f1800005000003",
|
39
|
+
"Labels": {},
|
40
|
+
"MacAddress": "",
|
41
|
+
"Memory": 1107296256,
|
42
|
+
"MemorySwap": -1,
|
43
|
+
"NetworkDisabled": false,
|
44
|
+
"OnBuild": null,
|
45
|
+
"OpenStdin": false,
|
46
|
+
"PortSpecs": null,
|
47
|
+
"StdinOnce": false,
|
48
|
+
"Tty": false,
|
49
|
+
"User": "",
|
50
|
+
"Volumes": null,
|
51
|
+
"WorkingDir": "/"
|
52
|
+
},
|
53
|
+
"Created": "2015-11-26T03:23:15.958740506Z",
|
54
|
+
"Driver": "overlay",
|
55
|
+
"ExecDriver": "native-0.2",
|
56
|
+
"ExecIDs": null,
|
57
|
+
"HostConfig": {
|
58
|
+
"Binds": [
|
59
|
+
"/data/mesos-slave/slaves/20151115-193554-4078832138-5050-1872-S2/docker/links/2e3e0f5c-ac02-40a0-804b-b4c7736935b5:/mnt/mesos/sandbox"
|
60
|
+
],
|
61
|
+
"CapAdd": null,
|
62
|
+
"CapDrop": null,
|
63
|
+
"CgroupParent": "",
|
64
|
+
"ContainerIDFile": "",
|
65
|
+
"CpuShares": 153,
|
66
|
+
"CpusetCpus": "",
|
67
|
+
"Devices": [],
|
68
|
+
"Dns": null,
|
69
|
+
"DnsSearch": null,
|
70
|
+
"ExtraHosts": null,
|
71
|
+
"IpcMode": "",
|
72
|
+
"Links": null,
|
73
|
+
"LogConfig": {
|
74
|
+
"Config": null,
|
75
|
+
"Type": "json-file"
|
76
|
+
},
|
77
|
+
"LxcConf": [],
|
78
|
+
"Memory": 1107296256,
|
79
|
+
"MemorySwap": -1,
|
80
|
+
"NetworkMode": "host",
|
81
|
+
"PidMode": "",
|
82
|
+
"PortBindings": {},
|
83
|
+
"Privileged": false,
|
84
|
+
"PublishAllPorts": false,
|
85
|
+
"ReadonlyRootfs": false,
|
86
|
+
"RestartPolicy": {
|
87
|
+
"MaximumRetryCount": 0,
|
88
|
+
"Name": "no"
|
89
|
+
},
|
90
|
+
"SecurityOpt": null,
|
91
|
+
"Ulimits": null,
|
92
|
+
"VolumesFrom": null
|
93
|
+
},
|
94
|
+
"HostnamePath": "/data/docker/containers/8dac46bdb4c099f8a12c12e06b104e9ca86b839e241b386bf3ddb537c9923642/hostname",
|
95
|
+
"HostsPath": "/data/docker/containers/8dac46bdb4c099f8a12c12e06b104e9ca86b839e241b386bf3ddb537c9923642/hosts",
|
96
|
+
"Id": "foobar124",
|
97
|
+
"Image": "dc41b56ccebd1433c6be3a92b838cc64c8c5f7088237a3da08a380cf43d6d6ac",
|
98
|
+
"LogPath": "/data/docker/containers/8dac46bdb4c099f8a12c12e06b104e9ca86b839e241b386bf3ddb537c9923642/8dac46bdb4c099f8a12c12e06b104e9ca86b839e241b386bf3ddb537c9923642-json.log",
|
99
|
+
"MountLabel": "",
|
100
|
+
"Name": "/mesos-2e3e0f5c-ac02-40a0-804b-b4c7736935b5",
|
101
|
+
"NetworkSettings": {
|
102
|
+
"Bridge": "",
|
103
|
+
"Gateway": "",
|
104
|
+
"GlobalIPv6Address": "",
|
105
|
+
"GlobalIPv6PrefixLen": 0,
|
106
|
+
"IPAddress": "",
|
107
|
+
"IPPrefixLen": 0,
|
108
|
+
"IPv6Gateway": "",
|
109
|
+
"LinkLocalIPv6Address": "",
|
110
|
+
"LinkLocalIPv6PrefixLen": 0,
|
111
|
+
"MacAddress": "",
|
112
|
+
"PortMapping": null,
|
113
|
+
"Ports": null
|
114
|
+
},
|
115
|
+
"Path": "/minimal",
|
116
|
+
"ProcessLabel": "",
|
117
|
+
"ResolvConfPath": "/data/docker/containers/8dac46bdb4c099f8a12c12e06b104e9ca86b839e241b386bf3ddb537c9923642/resolv.conf",
|
118
|
+
"RestartCount": 0,
|
119
|
+
"State": {
|
120
|
+
"Dead": false,
|
121
|
+
"Error": "",
|
122
|
+
"ExitCode": 0,
|
123
|
+
"FinishedAt": "2015-11-26T03:23:16.090077843Z",
|
124
|
+
"OOMKilled": false,
|
125
|
+
"Paused": false,
|
126
|
+
"Pid": 0,
|
127
|
+
"Restarting": false,
|
128
|
+
"Running": false,
|
129
|
+
"StartedAt": "2015-11-26T03:23:16.01885868Z"
|
130
|
+
},
|
131
|
+
"Volumes": {
|
132
|
+
"/mnt/mesos/sandbox": "/data/mesos-slave/slaves/20151115-193554-4078832138-5050-1872-S2/frameworks/20150821-174742-1460275722-5050-14777-0001/executors/ct:1448508194000:0:recurring-transaction2:task/runs/2e3e0f5c-ac02-40a0-804b-b4c7736935b5"
|
133
|
+
},
|
134
|
+
"VolumesRW": {
|
135
|
+
"/mnt/mesos/sandbox": true
|
136
|
+
}
|
137
|
+
}
|
@@ -0,0 +1,187 @@
|
|
1
|
+
{
|
2
|
+
"Id": "foobar123",
|
3
|
+
"Created": "2015-11-26T06:57:56.560006039Z",
|
4
|
+
"Path": "/bin/sh",
|
5
|
+
"Args": [
|
6
|
+
"-c",
|
7
|
+
"exec fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT"
|
8
|
+
],
|
9
|
+
"State": {
|
10
|
+
"Status": "running",
|
11
|
+
"Running": true,
|
12
|
+
"Paused": false,
|
13
|
+
"Restarting": false,
|
14
|
+
"OOMKilled": false,
|
15
|
+
"Dead": false,
|
16
|
+
"Pid": 6563,
|
17
|
+
"ExitCode": 0,
|
18
|
+
"Error": "",
|
19
|
+
"StartedAt": "2015-11-26T07:00:45.707356204Z",
|
20
|
+
"FinishedAt": "2015-11-26T07:00:43.278299772Z"
|
21
|
+
},
|
22
|
+
"Image": "7cd5efd43c5097c8e6a9b6bdc050f887e0e1dee49a79b7eb920e2d741c36b3b5",
|
23
|
+
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/110e3bd749e33e3b55bb55bec44a192457d722607afb1e6423e6a45a1c1e8b45/resolv.conf",
|
24
|
+
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/110e3bd749e33e3b55bb55bec44a192457d722607afb1e6423e6a45a1c1e8b45/hostname",
|
25
|
+
"HostsPath": "/mnt/sda1/var/lib/docker/containers/110e3bd749e33e3b55bb55bec44a192457d722607afb1e6423e6a45a1c1e8b45/hosts",
|
26
|
+
"LogPath": "/mnt/sda1/var/lib/docker/containers/110e3bd749e33e3b55bb55bec44a192457d722607afb1e6423e6a45a1c1e8b45/110e3bd749e33e3b55bb55bec44a192457d722607afb1e6423e6a45a1c1e8b45-json.log",
|
27
|
+
"Name": "/fluentddockertest_fluentd_server_1",
|
28
|
+
"RestartCount": 0,
|
29
|
+
"Driver": "aufs",
|
30
|
+
"ExecDriver": "native-0.2",
|
31
|
+
"MountLabel": "",
|
32
|
+
"ProcessLabel": "",
|
33
|
+
"AppArmorProfile": "",
|
34
|
+
"ExecIDs": null,
|
35
|
+
"HostConfig": {
|
36
|
+
"Binds": [
|
37
|
+
"/Users/A658307/fluentd_docker_test/fluentd/etc:/fluentd/etc:rw",
|
38
|
+
"/Users/A658307/fluentd_docker_test/fluentd/logs:/fluentd/log:rw",
|
39
|
+
"/Users/A658307/fluentd_docker_test/fluentd/plugins:/fluentd/plugins:rw"
|
40
|
+
],
|
41
|
+
"ContainerIDFile": "",
|
42
|
+
"LxcConf": null,
|
43
|
+
"Memory": 0,
|
44
|
+
"MemoryReservation": 0,
|
45
|
+
"MemorySwap": 0,
|
46
|
+
"KernelMemory": 0,
|
47
|
+
"CpuShares": 0,
|
48
|
+
"CpuPeriod": 0,
|
49
|
+
"CpusetCpus": "",
|
50
|
+
"CpusetMems": "",
|
51
|
+
"CpuQuota": 0,
|
52
|
+
"BlkioWeight": 0,
|
53
|
+
"OomKillDisable": false,
|
54
|
+
"MemorySwappiness": null,
|
55
|
+
"Privileged": false,
|
56
|
+
"PortBindings": {
|
57
|
+
"24224/tcp": [{
|
58
|
+
"HostIp": "",
|
59
|
+
"HostPort": "24224"
|
60
|
+
}]
|
61
|
+
},
|
62
|
+
"Links": null,
|
63
|
+
"PublishAllPorts": false,
|
64
|
+
"Dns": null,
|
65
|
+
"DnsOptions": null,
|
66
|
+
"DnsSearch": null,
|
67
|
+
"ExtraHosts": [],
|
68
|
+
"VolumesFrom": [],
|
69
|
+
"Devices": null,
|
70
|
+
"NetworkMode": "default",
|
71
|
+
"IpcMode": "",
|
72
|
+
"PidMode": "",
|
73
|
+
"UTSMode": "",
|
74
|
+
"CapAdd": null,
|
75
|
+
"CapDrop": null,
|
76
|
+
"GroupAdd": null,
|
77
|
+
"RestartPolicy": {
|
78
|
+
"Name": "",
|
79
|
+
"MaximumRetryCount": 0
|
80
|
+
},
|
81
|
+
"SecurityOpt": null,
|
82
|
+
"ReadonlyRootfs": false,
|
83
|
+
"Ulimits": null,
|
84
|
+
"LogConfig": {
|
85
|
+
"Type": "json-file",
|
86
|
+
"Config": {}
|
87
|
+
},
|
88
|
+
"CgroupParent": "",
|
89
|
+
"ConsoleSize": [
|
90
|
+
0,
|
91
|
+
0
|
92
|
+
],
|
93
|
+
"VolumeDriver": ""
|
94
|
+
},
|
95
|
+
"GraphDriver": {
|
96
|
+
"Name": "aufs",
|
97
|
+
"Data": null
|
98
|
+
},
|
99
|
+
"Volumes": {
|
100
|
+
"/fluentd/etc": "/Users/A658307/fluentd_docker_test/fluentd/etc",
|
101
|
+
"/fluentd/log": "/Users/A658307/fluentd_docker_test/fluentd/logs",
|
102
|
+
"/fluentd/plugins": "/Users/A658307/fluentd_docker_test/fluentd/plugins"
|
103
|
+
},
|
104
|
+
"VolumesRW": {
|
105
|
+
"/fluentd/etc": true,
|
106
|
+
"/fluentd/log": true,
|
107
|
+
"/fluentd/plugins": true
|
108
|
+
},
|
109
|
+
"Config": {
|
110
|
+
"Hostname": "110e3bd749e3",
|
111
|
+
"Domainname": "",
|
112
|
+
"User": "ubuntu",
|
113
|
+
"AttachStdin": false,
|
114
|
+
"AttachStdout": false,
|
115
|
+
"AttachStderr": false,
|
116
|
+
"Tty": false,
|
117
|
+
"OpenStdin": false,
|
118
|
+
"StdinOnce": false,
|
119
|
+
"Env": [
|
120
|
+
"FLUENTD_OPT=-vv",
|
121
|
+
"MESOS_TASK_ID=my-innovation-health-int-provider.14b0596d-93ea-11e5-a134-124eefe69197",
|
122
|
+
"MARATHON_APP_ID=/my-innovation-health-int-provider",
|
123
|
+
"FLUENTD_CONF=test.conf",
|
124
|
+
"PATH=/home/ubuntu/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
125
|
+
"FLUENTD_OPT="
|
126
|
+
],
|
127
|
+
"Cmd": [
|
128
|
+
"/bin/sh",
|
129
|
+
"-c",
|
130
|
+
"exec fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT"
|
131
|
+
],
|
132
|
+
"Image": "fluent/fluentd:latest",
|
133
|
+
"Volumes": {
|
134
|
+
"/fluentd/etc": {},
|
135
|
+
"/fluentd/log": {},
|
136
|
+
"/fluentd/plugins": {}
|
137
|
+
},
|
138
|
+
"WorkingDir": "/home/ubuntu",
|
139
|
+
"Entrypoint": null,
|
140
|
+
"OnBuild": null,
|
141
|
+
"Labels": {
|
142
|
+
"Description": "Fluentd docker image",
|
143
|
+
"Vendor": "Fluent Organization",
|
144
|
+
"Version": "1.0",
|
145
|
+
"com.docker.compose.config-hash": "7a03ce1e88388255c166fa62dcad89a43d43034ce605265094cf9c9951dcc9f0",
|
146
|
+
"com.docker.compose.container-number": "1",
|
147
|
+
"com.docker.compose.oneoff": "False",
|
148
|
+
"com.docker.compose.project": "fluentddockertest",
|
149
|
+
"com.docker.compose.service": "fluentd_server",
|
150
|
+
"com.docker.compose.version": "1.5.1"
|
151
|
+
},
|
152
|
+
"MacAddress": "",
|
153
|
+
"NetworkDisabled": false,
|
154
|
+
"ExposedPorts": {
|
155
|
+
"24224/tcp": {}
|
156
|
+
},
|
157
|
+
"VolumeDriver": "",
|
158
|
+
"Memory": 0,
|
159
|
+
"MemorySwap": 0,
|
160
|
+
"CpuShares": 0,
|
161
|
+
"Cpuset": ""
|
162
|
+
},
|
163
|
+
"NetworkSettings": {
|
164
|
+
"Bridge": "",
|
165
|
+
"SandboxID": "f304aa3b0e20fe1e0edb5984aedd03b7d5df999ff5ff9bd3ef8f831923e5f96a",
|
166
|
+
"HairpinMode": false,
|
167
|
+
"LinkLocalIPv6Address": "",
|
168
|
+
"LinkLocalIPv6PrefixLen": 0,
|
169
|
+
"Ports": {
|
170
|
+
"24224/tcp": [{
|
171
|
+
"HostIp": "0.0.0.0",
|
172
|
+
"HostPort": "24224"
|
173
|
+
}]
|
174
|
+
},
|
175
|
+
"SandboxKey": "/var/run/docker/netns/f304aa3b0e20",
|
176
|
+
"SecondaryIPAddresses": null,
|
177
|
+
"SecondaryIPv6Addresses": null,
|
178
|
+
"EndpointID": "7c6889977686db7c2b2042798b021a03df61c4273dcfd84fb2a9e5830fcb71a9",
|
179
|
+
"Gateway": "172.17.0.1",
|
180
|
+
"GlobalIPv6Address": "",
|
181
|
+
"GlobalIPv6PrefixLen": 0,
|
182
|
+
"IPAddress": "172.17.0.2",
|
183
|
+
"IPPrefixLen": 16,
|
184
|
+
"IPv6Gateway": "",
|
185
|
+
"MacAddress": "02:42:ac:11:00:02"
|
186
|
+
}
|
187
|
+
}
|
data/test/helper.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
SimpleCov.start
|
3
|
+
require "codeclimate-test-reporter"
|
4
|
+
CodeClimate::TestReporter.start
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler'
|
8
|
+
require 'docker'
|
9
|
+
require 'timecop'
|
10
|
+
begin
|
11
|
+
Bundler.setup(:default, :development)
|
12
|
+
rescue Bundler::BundlerError => e
|
13
|
+
$stderr.puts e.message
|
14
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
15
|
+
exit e.status_code
|
16
|
+
end
|
17
|
+
require 'test/unit'
|
18
|
+
require 'pry'
|
19
|
+
|
20
|
+
|
21
|
+
require "simplecov"
|
22
|
+
require "codeclimate-test-reporter"
|
23
|
+
if ENV['CIRCLE_ARTIFACTS']
|
24
|
+
dir = File.join("..", "..", "..", ENV['CIRCLE_ARTIFACTS'], "coverage")
|
25
|
+
SimpleCov.coverage_dir(dir)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
31
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
32
|
+
require 'fluent/test'
|
33
|
+
require 'webmock/test_unit'
|
34
|
+
WebMock.disable_net_connect!(:allow => "codeclimate.com")
|
35
|
+
|
36
|
+
if ENV.has_key?('VERBOSE')
|
37
|
+
$log = Fluent::Log.new(Fluent::Test::DummyLogDevice.new, Fluent::Log::LEVEL_TRACE)
|
38
|
+
else
|
39
|
+
nulllogger = Object.new
|
40
|
+
nulllogger.instance_eval {|obj|
|
41
|
+
def method_missing(method, *args)
|
42
|
+
# pass
|
43
|
+
end
|
44
|
+
}
|
45
|
+
$log = nulllogger
|
46
|
+
end
|
47
|
+
Docker.url = 'tcp://example.com:5422'
|
48
|
+
require 'fluent/plugin/mesosphere'
|
49
|
+
|
50
|
+
class Test::Unit::TestCase
|
51
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class AmplifierFilterTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
unless defined?(Fluent::Filter)
|
6
|
+
omit('Fluent::Filter is not defined. Use fluentd 0.12 or later.')
|
7
|
+
end
|
8
|
+
|
9
|
+
Fluent::Test.setup
|
10
|
+
end
|
11
|
+
|
12
|
+
# config_param :ratio, :float
|
13
|
+
# config_param :key_names, :string, :default => nil
|
14
|
+
# config_param :key_pattern, :string, :default => nil
|
15
|
+
# config_param :floor, :bool, :default => false
|
16
|
+
# config_param :remove_prefix, :string, :default => nil
|
17
|
+
# config_param :add_prefix, :string, :default => nil
|
18
|
+
|
19
|
+
CONFIG = %[]
|
20
|
+
CONFIG2 = %[
|
21
|
+
cache_size 2000
|
22
|
+
cache_ttl 300
|
23
|
+
]
|
24
|
+
|
25
|
+
def create_driver(conf = CONFIG, tag = 'test')
|
26
|
+
Fluent::Test::FilterTestDriver.new(Fluent::MesosphereFilter, tag).configure(conf)
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_docker_stub(file, docker_api_url)
|
30
|
+
stub_request(:get, docker_api_url)
|
31
|
+
.to_return(status: 200, body: file, headers: {})
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup_marathon_container
|
35
|
+
docker_api_url = 'http://tcp//example.com:5422/v1.16/containers/foobar123/json'
|
36
|
+
file = File.open('test/containers/marathon.json', 'rb')
|
37
|
+
setup_docker_stub(file, docker_api_url)
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup_chronos_container
|
41
|
+
docker_api_url = 'http://tcp//example.com:5422/v1.16/containers/foobar124/json'
|
42
|
+
file = File.open('test/containers/chronos.json', 'rb')
|
43
|
+
setup_docker_stub(file, docker_api_url)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_marathon_filter
|
47
|
+
setup_marathon_container
|
48
|
+
|
49
|
+
d1 = create_driver(CONFIG, 'docker.foobar123')
|
50
|
+
d1.run do
|
51
|
+
d1.filter('log' => 'Hello World 1')
|
52
|
+
end
|
53
|
+
filtered = d1.filtered_as_array
|
54
|
+
|
55
|
+
task_id = 'my-innovation-health-int-provider.14b0596d-93ea-11e5-a134-124eefe69197'
|
56
|
+
|
57
|
+
log_entry = filtered[0][2]
|
58
|
+
|
59
|
+
assert_equal 'marathon', log_entry['mesos_framework']
|
60
|
+
assert_equal '/my-innovation-health-int-provider', log_entry['app']
|
61
|
+
assert_equal task_id, log_entry['mesos_task_id']
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_container_cache
|
65
|
+
setup_marathon_container
|
66
|
+
|
67
|
+
d1 = create_driver(CONFIG, 'docker.foobar123')
|
68
|
+
d1.run do
|
69
|
+
1000.times do
|
70
|
+
d1.filter('log' => 'Hello World 4')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
docker_api_url = 'http://tcp//example.com:5422/v1.16/containers/foobar123/json'
|
74
|
+
|
75
|
+
assert_equal 1000, d1.filtered_as_array.length
|
76
|
+
assert_requested(:get, docker_api_url, times: 2)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_container_cache_expiration
|
80
|
+
setup_marathon_container
|
81
|
+
|
82
|
+
d1 = create_driver(CONFIG2, 'docker.foobar123')
|
83
|
+
d1.run do
|
84
|
+
d1.filter('log' => 'Hello World 4')
|
85
|
+
end
|
86
|
+
|
87
|
+
Timecop.travel(Time.now + 10 * 60)
|
88
|
+
|
89
|
+
d1.run do
|
90
|
+
d1.filter('log' => 'Hello World 4')
|
91
|
+
end
|
92
|
+
|
93
|
+
Timecop.return
|
94
|
+
|
95
|
+
docker_api_url = 'http://tcp//example.com:5422/v1.16/containers/foobar123/json'
|
96
|
+
|
97
|
+
assert_requested(:get, docker_api_url, times: 4)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_chronos_filter
|
101
|
+
setup_chronos_container
|
102
|
+
|
103
|
+
d1 = create_driver(CONFIG, 'docker.foobar124')
|
104
|
+
d1.run do
|
105
|
+
d1.filter('log' => 'Hello World 1')
|
106
|
+
end
|
107
|
+
filtered = d1.filtered_as_array
|
108
|
+
|
109
|
+
task_id = 'ct:1448508194000:0:recurring-transaction2:task'
|
110
|
+
log_entry = filtered[0][2]
|
111
|
+
|
112
|
+
assert_equal 'chronos', log_entry['mesos_framework']
|
113
|
+
assert_equal 'some-task-app2', log_entry['app']
|
114
|
+
assert_equal task_id, log_entry['mesos_task_id']
|
115
|
+
assert_equal 'deployTasks', log_entry['chronos_task_type']
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_merge_json
|
119
|
+
setup_chronos_container
|
120
|
+
|
121
|
+
d1 = create_driver(CONFIG, 'docker.foobar124')
|
122
|
+
d1.run do
|
123
|
+
d1.filter('log' => '{"test_key":"Hello World"}')
|
124
|
+
end
|
125
|
+
filtered = d1.filtered_as_array
|
126
|
+
log_entry = filtered[0][2]
|
127
|
+
|
128
|
+
assert_equal 'Hello World', log_entry['test_key']
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_bad_merge_json
|
132
|
+
setup_chronos_container
|
133
|
+
bad_json1 = '{"test_key":"Hello World"'
|
134
|
+
bad_json2 = '{"test_key":"Hello World", "badnews"}'
|
135
|
+
|
136
|
+
d1 = create_driver(CONFIG, 'docker.foobar124')
|
137
|
+
d1.run do
|
138
|
+
d1.filter('log' => bad_json1)
|
139
|
+
d1.filter('log' => bad_json2)
|
140
|
+
end
|
141
|
+
filtered = d1.filtered_as_array
|
142
|
+
|
143
|
+
assert_equal bad_json1, filtered[0][2]['log']
|
144
|
+
assert_equal bad_json2, filtered[1][2]['log']
|
145
|
+
end
|
146
|
+
end
|
metadata
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-mesosphere-filter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joseph Hughes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-26 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'
|
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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: lru_redux
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: docker-api
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.23'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.23'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: oj
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: timecop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: minitest
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '4.0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ~>
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '4.0'
|
181
|
+
description: Filter plugin to add Mesosphere metadata
|
182
|
+
email:
|
183
|
+
- jjhughes57@gmail.com
|
184
|
+
executables: []
|
185
|
+
extensions: []
|
186
|
+
extra_rdoc_files: []
|
187
|
+
files:
|
188
|
+
- .gitignore
|
189
|
+
- .ruby-version
|
190
|
+
- .travis.yml
|
191
|
+
- Gemfile
|
192
|
+
- LICENSE.txt
|
193
|
+
- README.md
|
194
|
+
- Rakefile
|
195
|
+
- fluent-plugin-mesosphere-filter.gemspec
|
196
|
+
- lib/fluent/plugin/mesosphere.rb
|
197
|
+
- test/containers/chronos.json
|
198
|
+
- test/containers/marathon.json
|
199
|
+
- test/helper.rb
|
200
|
+
- test/plugin/test_mesosphere.rb
|
201
|
+
homepage: https://github.com/joshughes/fluent-plugin-mesosphere-filter
|
202
|
+
licenses:
|
203
|
+
- ASL2
|
204
|
+
metadata: {}
|
205
|
+
post_install_message:
|
206
|
+
rdoc_options: []
|
207
|
+
require_paths:
|
208
|
+
- lib
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: 2.0.0
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ! '>='
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
requirements: []
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 2.4.5
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: Filter plugin to add Mesosphere metadata to fluentd from Chronos and Marathon
|
225
|
+
test_files:
|
226
|
+
- test/containers/chronos.json
|
227
|
+
- test/containers/marathon.json
|
228
|
+
- test/helper.rb
|
229
|
+
- test/plugin/test_mesosphere.rb
|