fluent-plugin-wodby 0.1.5 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-wodby.gemspec +1 -1
- data/lib/fluent/plugin/filter_wodby.rb +14 -6
- data/test/plugin/test_filter_wodby.rb +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57ac4a430d1c7d6f5ff0be056648e3a1cf139a7964a2e2ef7bc86350412f9b19
|
4
|
+
data.tar.gz: 9adf5941a2fa080534b3f878e329cc5e81501c2025c180ef2cf3b511f34adf51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7490189d97937b66a21d8f6d391547d6d2aca6f010ac3861cfd825666c5db819c257186792057f54f32f8a26cf3647da321d91dd0b35177d5484a98de5a6d94b
|
7
|
+
data.tar.gz: acea16faaf6d820cb71394f47e6abc8e39a43d015d2fbf011a4c56ff0b7919c5b622465b14b2795090e5b05b9811f3e0819de37c876f28ece2498d80e17d7dd0
|
data/fluent-plugin-wodby.gemspec
CHANGED
@@ -34,16 +34,24 @@ module Fluent
|
|
34
34
|
def filter(tag, time, record)
|
35
35
|
record['wodby.filter'] = true
|
36
36
|
|
37
|
-
if record.has_key?('kubernetes.namespace_name')
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
if record.has_key?('kubernetes') && record['kubernetes'].has_key?('namespace_name')
|
38
|
+
namespace = record['kubernetes']['namespace_name']
|
39
|
+
unless @instance_map.has_key?(namespace)
|
40
|
+
record['wodby.instance_query'] = namespace
|
41
|
+
instance = get_instance(namespace)
|
41
42
|
app = get_app(instance['app_id'])
|
42
43
|
|
43
|
-
@instance_map[
|
44
|
+
@instance_map[namespace] = {
|
45
|
+
'name' => "#{app['name']}.#{instance['name']}",
|
46
|
+
'title' => "#{app['title']} - #{instance['title']}",
|
47
|
+
}
|
44
48
|
end
|
45
49
|
|
46
|
-
record['wodby.instance'] = @instance_map[
|
50
|
+
record['wodby.instance'] = @instance_map[namespace]['name']
|
51
|
+
record['wodby.instance_title'] = @instance_map[namespace]['title']
|
52
|
+
else
|
53
|
+
log.info "No namespace found"
|
54
|
+
log.info record
|
47
55
|
end
|
48
56
|
|
49
57
|
record
|
@@ -16,15 +16,17 @@ class WodbyFilterTest < Test::Unit::TestCase
|
|
16
16
|
d = create_driver("api_key #{ENV['WODBY_API_KEY']}")
|
17
17
|
time = event_time
|
18
18
|
d.run do
|
19
|
-
d.feed('filter.test', time, { 'kubernetes
|
20
|
-
d.feed('filter.test', time, { 'kubernetes
|
21
|
-
d.feed('filter.test', time, { 'kubernetes
|
19
|
+
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo' })
|
20
|
+
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => 'a3d67f12-8341-4245-87db-ed7a6c856e70'}, 'message' => 'hullo' })
|
21
|
+
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo' })
|
22
22
|
end
|
23
23
|
|
24
24
|
assert_equal(3, d.filtered_records.size)
|
25
|
-
assert_equal('
|
26
|
-
assert_equal('
|
27
|
-
assert_equal('
|
25
|
+
assert_equal('dfono.staging', d.filtered_records[0]['wodby.instance'])
|
26
|
+
assert_equal('dfono.prod', d.filtered_records[1]['wodby.instance'])
|
27
|
+
assert_equal('dfono.staging', d.filtered_records[2]['wodby.instance'])
|
28
|
+
assert_equal('dfo.no - Staging', d.filtered_records[0]['wodby.instance_title'])
|
29
|
+
assert_equal('dfo.no - Prod', d.filtered_records[1]['wodby.instance_title'])
|
28
30
|
assert_nil(d.filtered_records[2]['wodby.instance_query'])
|
29
31
|
assert_true(d.filtered_records[0]['wodby.filter'])
|
30
32
|
assert_true(d.filtered_records[1]['wodby.filter'])
|