fluent-plugin-wodby 0.3.0 → 0.4.0
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 +25 -15
- data/test/plugin/test_filter_wodby.rb +17 -4
- 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: e2c0a42ae8e68d022cea68274dec675e8e22b181e1b1ab0a257ece331166eca0
|
4
|
+
data.tar.gz: 4b740c774e644e04201abab355f79312a9f5a25652c6026c7fe55547c65e50d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e36b6cde7a8ca346a9e2343ceeeb32a0b6b1ceb028e9b2481c797d17352fe3eeb6336bd96e94649a27fb1410210c8f07e3d3be10f2217af50a9450bc32142970
|
7
|
+
data.tar.gz: c17560e1f313d485a5dd79048dc4deeea97aa6f1045d0ad8b0715c5972ed84ab41ecf4b8985841983f75a22410680a47fe469099aa85226e085e4f4928805805
|
data/fluent-plugin-wodby.gemspec
CHANGED
@@ -36,28 +36,38 @@ module Fluent
|
|
36
36
|
'filter' => true
|
37
37
|
}
|
38
38
|
|
39
|
+
if record.has_key?('wodby.node_name')
|
40
|
+
record['wodby']['node_name'] = record['wodby.node_name']
|
41
|
+
record.delete('wodby.node_name')
|
42
|
+
end
|
43
|
+
|
39
44
|
if record.has_key?('kubernetes') && record['kubernetes'].has_key?('namespace_name')
|
40
45
|
namespace = record['kubernetes']['namespace_name']
|
41
46
|
unless @instance_map.has_key?(namespace)
|
42
47
|
record['wodby']['instance_query'] = namespace
|
43
48
|
instance = get_instance(namespace)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
|
50
|
+
if instance.empty?
|
51
|
+
@instance_map[namespace] = {
|
52
|
+
'found' => false
|
53
|
+
}
|
54
|
+
|
55
|
+
else
|
56
|
+
app = get_app(instance['app_id'])
|
57
|
+
org = get_org(app['org_id'])
|
58
|
+
|
59
|
+
@instance_map[namespace] = {
|
60
|
+
'found' => true,
|
61
|
+
'instance' => "#{app['name']}.#{instance['name']}",
|
62
|
+
'instance_title' => "#{app['title']} - #{instance['title']}",
|
63
|
+
'instance_type' => instance['type'],
|
64
|
+
'organization' => org['name'],
|
65
|
+
'organization_title' => org['title'],
|
66
|
+
}
|
67
|
+
end
|
54
68
|
end
|
55
69
|
|
56
|
-
record['wodby']
|
57
|
-
record['wodby']['instance_title'] = @instance_map[namespace]['title']
|
58
|
-
record['wodby']['instance_type'] = @instance_map[namespace]['type']
|
59
|
-
record['wodby']['organization'] = @instance_map[namespace]['organization']
|
60
|
-
record['wodby']['organization_title'] = @instance_map[namespace]['organization_title']
|
70
|
+
record['wodby'].merge!(@instance_map[namespace])
|
61
71
|
else
|
62
72
|
log.info "No namespace found"
|
63
73
|
log.info record
|
@@ -16,18 +16,31 @@ 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' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo' })
|
20
|
-
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '7ee5d15f-7c3c-4ce8-873e-34b75154f0f4'}, 'message' => 'hullo' })
|
21
|
-
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo' })
|
19
|
+
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo', 'wodby.node_name' => 'node' })
|
20
|
+
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '7ee5d15f-7c3c-4ce8-873e-34b75154f0f4'}, 'message' => 'hullo', 'wodby.node_name' => 'node' })
|
21
|
+
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo', 'wodby.node_name' => 'node' })
|
22
|
+
d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => 'renovate'}, 'message' => 'hullo', 'wodby.node_name' => 'node' })
|
22
23
|
end
|
23
24
|
|
24
|
-
assert_equal(
|
25
|
+
assert_equal(4, d.filtered_records.size)
|
26
|
+
assert_true(d.filtered_records[0]['wodby']['found'])
|
27
|
+
assert_true(d.filtered_records[1]['wodby']['found'])
|
28
|
+
assert_true(d.filtered_records[2]['wodby']['found'])
|
29
|
+
assert_false(d.filtered_records[3]['wodby']['found'])
|
30
|
+
|
25
31
|
assert_equal('dfono.staging', d.filtered_records[0]['wodby']['instance'])
|
26
32
|
assert_equal('dfono.prod', d.filtered_records[1]['wodby']['instance'])
|
27
33
|
assert_equal('dfono.staging', d.filtered_records[2]['wodby']['instance'])
|
28
34
|
assert_equal('dfo.no - Staging', d.filtered_records[0]['wodby']['instance_title'])
|
29
35
|
assert_equal('dfo.no - Prod', d.filtered_records[1]['wodby']['instance_title'])
|
36
|
+
assert_equal('node', d.filtered_records[0]['wodby']['node_name'])
|
37
|
+
assert_equal('node', d.filtered_records[1]['wodby']['node_name'])
|
38
|
+
assert_equal('dfo', d.filtered_records[0]['wodby']['organization'])
|
39
|
+
assert_equal('DFØ', d.filtered_records[1]['wodby']['organization_title'])
|
40
|
+
|
30
41
|
assert_nil(d.filtered_records[2]['wodby']['instance_query'])
|
42
|
+
assert_nil(d.filtered_records[2]['wodby.node_name'])
|
43
|
+
|
31
44
|
assert_true(d.filtered_records[0]['wodby']['filter'])
|
32
45
|
assert_true(d.filtered_records[1]['wodby']['filter'])
|
33
46
|
assert_true(d.filtered_records[2]['wodby']['filter'])
|