fluent-plugin-wodby 0.1.2 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +9 -0
- data/fluent-plugin-wodby.gemspec +1 -1
- data/lib/fluent/plugin/filter_wodby.rb +19 -5
- data/test/plugin/test_filter_wodby.rb +7 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec5aac4ba42f1eb469da3610fe5451181c59db36115ab2b2234fce6df99e8091
|
4
|
+
data.tar.gz: 298cde6628e7c10fb5ccaed095fb93847f9f713b6877b4a7a1b886c92e3821c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8872f83349b861730ccbb648a27a2c296f05bdf21685699248286474b352d70749e211354980efbd4cbf781696c8aa0f8406bf2ba92d9235aef86d7a22516867
|
7
|
+
data.tar.gz: 60577048aad3abcb8a3b51a80a481d865d279d41b35e8a2ce3e5475b8fb7e33d20c67c77f0709d89340ac26b2cb3f7016599a56fecea7d7f97168662b9fefa89
|
data/Makefile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
PWD=$(shell pwd)
|
2
|
+
|
3
|
+
.PHONY: docker-test
|
4
|
+
docker-test:
|
5
|
+
docker run --rm -it -v $(PWD):/build -e WODBY_API_KEY=${WODBY_API_KEY} ruby /bin/bash -c "cd build && bundle install && bundle exec rake test"
|
6
|
+
|
7
|
+
.PHONY: docker-tester
|
8
|
+
docker-tester:
|
9
|
+
docker run --rm -it -v $(PWD):/build -e WODBY_API_KEY=${WODBY_API_KEY} ruby /bin/bash
|
data/fluent-plugin-wodby.gemspec
CHANGED
@@ -24,12 +24,26 @@ module Fluent
|
|
24
24
|
|
25
25
|
config_param :api_key, :string, secret: true
|
26
26
|
|
27
|
+
def start
|
28
|
+
super
|
29
|
+
|
30
|
+
@instance_map = {}
|
31
|
+
log.info "Initialized wodby plugin"
|
32
|
+
end
|
33
|
+
|
27
34
|
def filter(tag, time, record)
|
35
|
+
record['wodby.filter'] = true
|
36
|
+
|
28
37
|
if record.has_key?('kubernetes.namespace_name')
|
29
|
-
|
30
|
-
|
38
|
+
unless @instance_map.has_key?(record['kubernetes.namespace_name'])
|
39
|
+
record['wodby.instance_query'] = record['kubernetes.namespace_name']
|
40
|
+
instance = get_instance(record['kubernetes.namespace_name'])
|
41
|
+
app = get_app(instance['app_id'])
|
42
|
+
|
43
|
+
@instance_map[record['kubernetes.namespace_name']] = "#{app['title']}-#{instance['name']}"
|
44
|
+
end
|
31
45
|
|
32
|
-
record['wodby.instance'] =
|
46
|
+
record['wodby.instance'] = @instance_map[record['kubernetes.namespace_name']]
|
33
47
|
end
|
34
48
|
|
35
49
|
record
|
@@ -44,7 +58,7 @@ module Fluent
|
|
44
58
|
headers={'X-API-KEY': @api_key}
|
45
59
|
)
|
46
60
|
instance = JSON.parse(response)
|
47
|
-
rescue RestClient::ExceptionWithResponse
|
61
|
+
rescue RestClient::ExceptionWithResponse
|
48
62
|
instance = {}
|
49
63
|
end
|
50
64
|
|
@@ -58,7 +72,7 @@ module Fluent
|
|
58
72
|
headers={'X-API-KEY': @api_key}
|
59
73
|
)
|
60
74
|
app = JSON.parse(response)
|
61
|
-
rescue RestClient::ExceptionWithResponse
|
75
|
+
rescue RestClient::ExceptionWithResponse
|
62
76
|
app = {}
|
63
77
|
end
|
64
78
|
|
@@ -18,10 +18,16 @@ class WodbyFilterTest < Test::Unit::TestCase
|
|
18
18
|
d.run do
|
19
19
|
d.feed('filter.test', time, { 'kubernetes.namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a', 'message' => 'hullo' })
|
20
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' })
|
21
22
|
end
|
22
23
|
|
23
|
-
assert_equal(
|
24
|
+
assert_equal(3, d.filtered_records.size)
|
24
25
|
assert_equal('dfo.no-staging', d.filtered_records[0]['wodby.instance'])
|
25
26
|
assert_equal('dfo.no-prod', d.filtered_records[1]['wodby.instance'])
|
27
|
+
assert_equal('dfo.no-staging', d.filtered_records[2]['wodby.instance'])
|
28
|
+
assert_nil(d.filtered_records[2]['wodby.instance_query'])
|
29
|
+
assert_true(d.filtered_records[0]['wodby.filter'])
|
30
|
+
assert_true(d.filtered_records[1]['wodby.filter'])
|
31
|
+
assert_true(d.filtered_records[2]['wodby.filter'])
|
26
32
|
end
|
27
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-wodby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Wunderer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- ".gitignore"
|
112
112
|
- Gemfile
|
113
113
|
- LICENSE
|
114
|
+
- Makefile
|
114
115
|
- README.md
|
115
116
|
- Rakefile
|
116
117
|
- fluent-plugin-wodby.gemspec
|