fluent-plugin-mesosphere-filter 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGU0MDQyMzUwNzIyZGE0NWQ4OTdmMzgzYWY0OWM3N2NhMDA5YmRhNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWNhYTJmNDk4NjcwZmZkMDlkYmMwNDBlOWFkNjAyNzRkN2RhYjczNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzlhYTBhZjAwMjBlM2Y3N2Q4MjM0MjM1ZmZhNmZjMDlhZDdiMTRiNTk5NDAx
|
10
|
+
Yjg4MmQ2NTZiNGI1Njc2OTcwMjhjYzM4MmM4ZDA2M2JjNmE0MjE2ZWI5NjYy
|
11
|
+
NTgwYmVjMjdjZmZkYjNjODEzMDhjZjgyMDc3MzczYzgxNDM1YmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDU5YmIxYjNmMTNkNmQyYjk4MDQyNWYyYjY4MTczZDg2YmI5OWYxODI3YzU4
|
14
|
+
ODI1MmMxZDM0M2E2MzdhMzFlOThlODkyNzEyNTZlMmFkMGE4MzViZTlkNzBl
|
15
|
+
NGQzZGUyNjYwM2VhZjg3ZTk1MDk5ZGQ1NmRiMzZlZWZlZDViNDM=
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'fluent-plugin-mesosphere-filter'
|
7
|
-
gem.version = '0.1.
|
7
|
+
gem.version = '0.1.10'
|
8
8
|
gem.authors = ['Joseph Hughes']
|
9
9
|
gem.email = ['jjhughes57@gmail.com']
|
10
10
|
gem.description = 'Filter plugin to add Mesosphere metadata'
|
@@ -25,6 +25,7 @@ module Fluent
|
|
25
25
|
config_param :cache_ttl, :integer, default: 60 * 60
|
26
26
|
config_param :get_container_id_tag, :bool, default: true
|
27
27
|
config_param :container_id_attr, :string, default: 'container_id'
|
28
|
+
config_param :namespace_env_var, :string, default: nil
|
28
29
|
|
29
30
|
config_param :merge_json_log, :bool, default: true
|
30
31
|
config_param :cronos_task_regex,
|
@@ -122,6 +123,8 @@ module Fluent
|
|
122
123
|
task_data['mesos_framework'] = 'chronos'
|
123
124
|
task_data['app'] = match_data['app'] if match_data
|
124
125
|
task_data['chronos_task_type'] = match_data['task_type'] if match_data
|
126
|
+
elsif @namespace_env_var && env.include?(@namespace_env_var)
|
127
|
+
task_data['namespace'] = parse_env(env)
|
125
128
|
end
|
126
129
|
end
|
127
130
|
end
|
@@ -165,7 +168,8 @@ module Fluent
|
|
165
168
|
end
|
166
169
|
|
167
170
|
# Look at the log value and if it is valid json then we will parse the json
|
168
|
-
# and merge it into the log record.
|
171
|
+
# and merge it into the log record. If a namespace is present then the log
|
172
|
+
# record is placed under that key.
|
169
173
|
# ==== Attributes:
|
170
174
|
# * +record+ - The record we are transforming in the fluentd event stream.
|
171
175
|
# ==== Examples
|
@@ -177,9 +181,15 @@ module Fluent
|
|
177
181
|
def merge_json_log(record)
|
178
182
|
if record.key?('log')
|
179
183
|
log = record['log'].strip
|
184
|
+
namespace = record['namespace']
|
180
185
|
if log[0].eql?('{') && log[-1].eql?('}')
|
181
186
|
begin
|
182
|
-
|
187
|
+
log_json = Oj.load(log)
|
188
|
+
if namespace
|
189
|
+
record[namespace] = log_json
|
190
|
+
else
|
191
|
+
record = log_json.merge(record)
|
192
|
+
end
|
183
193
|
rescue Oj::ParseError
|
184
194
|
end
|
185
195
|
end
|
@@ -29,7 +29,8 @@
|
|
29
29
|
"YEAR=2016",
|
30
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
31
|
"MESOS_SANDBOX=/mnt/mesos/sandbox",
|
32
|
-
"PORT=80"
|
32
|
+
"PORT=80",
|
33
|
+
"NAMESPACE=ns"
|
33
34
|
],
|
34
35
|
"ExposedPorts": {
|
35
36
|
"80/tcp": {}
|
@@ -122,7 +122,8 @@
|
|
122
122
|
"MARATHON_APP_ID=/hello-world",
|
123
123
|
"FLUENTD_CONF=test.conf",
|
124
124
|
"PATH=/home/ubuntu/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
125
|
-
"FLUENTD_OPT="
|
125
|
+
"FLUENTD_OPT=",
|
126
|
+
"NAMESPACE=ns"
|
126
127
|
],
|
127
128
|
"Cmd": [
|
128
129
|
"/bin/sh",
|
@@ -25,6 +25,9 @@ class AmplifierFilterTest < Test::Unit::TestCase
|
|
25
25
|
get_container_id_tag false
|
26
26
|
container_id_attr container_id
|
27
27
|
]
|
28
|
+
CONFIG4 = %[
|
29
|
+
namespace_env_var NAMESPACE
|
30
|
+
]
|
28
31
|
|
29
32
|
def create_driver(conf = CONFIG, tag = 'test')
|
30
33
|
Fluent::Test::FilterTestDriver.new(Fluent::MesosphereFilter, tag).configure(conf)
|
@@ -152,6 +155,20 @@ class AmplifierFilterTest < Test::Unit::TestCase
|
|
152
155
|
assert_equal 'Hello World', log_entry['test_key']
|
153
156
|
end
|
154
157
|
|
158
|
+
def test_merge_json_with_namespace
|
159
|
+
setup_chronos_container
|
160
|
+
|
161
|
+
d1 = create_driver(CONFIG4, 'docker.foobar124')
|
162
|
+
d1.run do
|
163
|
+
d1.filter('log' => '{"test_key":"Hello World"}')
|
164
|
+
end
|
165
|
+
filtered = d1.filtered_as_array
|
166
|
+
log_entry = filtered[0][2]
|
167
|
+
|
168
|
+
assert_equal 'ns', log_entry['namespace']
|
169
|
+
assert_equal 'Hello World', log_entry['ns']['test_key']
|
170
|
+
end
|
171
|
+
|
155
172
|
def test_bad_merge_json
|
156
173
|
setup_chronos_container
|
157
174
|
bad_json1 = '{"test_key":"Hello World"'
|
@@ -168,6 +185,24 @@ class AmplifierFilterTest < Test::Unit::TestCase
|
|
168
185
|
assert_equal bad_json2, filtered[1][2]['log']
|
169
186
|
end
|
170
187
|
|
188
|
+
def test_bad_merge_json_with_namespace
|
189
|
+
setup_chronos_container
|
190
|
+
bad_json1 = '{"test_key":"Hello World"'
|
191
|
+
bad_json2 = '{"test_key":"Hello World", "badnews"}'
|
192
|
+
|
193
|
+
d1 = create_driver(CONFIG4, 'docker.foobar124')
|
194
|
+
d1.run do
|
195
|
+
d1.filter('log' => bad_json1)
|
196
|
+
d1.filter('log' => bad_json2)
|
197
|
+
end
|
198
|
+
filtered = d1.filtered_as_array
|
199
|
+
|
200
|
+
assert_equal bad_json1, filtered[0][2]['log']
|
201
|
+
assert_equal bad_json2, filtered[1][2]['log']
|
202
|
+
assert_equal false, filtered[0][2].key?('ns')
|
203
|
+
assert_equal false, filtered[1][2].key?('ns')
|
204
|
+
end
|
205
|
+
|
171
206
|
def test_container_id_from_record
|
172
207
|
setup_marathon_container('somecontainer123', 'marathon2')
|
173
208
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mesosphere-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Hughes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|