fluent-plugin-wodby 0.2.2 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd53b2bc16d8fca2ff749985b2dccccdf783616aca438f4fe8c5d947064dbc80
4
- data.tar.gz: e96d52f0a9c9887abc0c3a01c95cac5e698b0a873417fa0dfdfc3bd9531d36d7
3
+ metadata.gz: 45c8c562d96d1ccf43a9ec81aa7771ac8fd05ed071282119c62581ae4d45f5db
4
+ data.tar.gz: 43e377e23fe30e3af5df48ee6f3c144278339b3c5c18d662705e09ee9e50ce2c
5
5
  SHA512:
6
- metadata.gz: 163226e98013e63f4536daa1d6db67f64d6b71a347a94ecf80afa0ce3600e559afc6d3fd8ba4b5e622a33ac6fa141c6122e8409b4964e6162f1855a288bec9f9
7
- data.tar.gz: 7237c58a7a76709f51e6cd3238a5d76de6c40d0341a781e9d7a91c1ed3489289d784c4a5ccc6cdc203ae35f06b78566443aa5eb14af4d01fba46fa6688289bfa
6
+ metadata.gz: c1f702cfa38258a6a4cacafbe33d94e4fd9dc3bac2334b8ca7eff3ce5f7e1a9622a76533019f1f69b5da8b2abba8a7e33c2912a9963c8eb399467217dc367eee
7
+ data.tar.gz: 2b42ea373f5daebc31f7fac557d6d45f9939bc93ceb0dd8c3e0e50e127aa17431345a80639d9b07719d1f88c59045fa01d1958f7a8649f63d18b206ff50ce98e
@@ -16,10 +16,10 @@ jobs:
16
16
 
17
17
  steps:
18
18
  - uses: actions/checkout@v3
19
- - name: Set up Ruby 3.1
19
+ - name: Set up Ruby 3.3
20
20
  uses: ruby/setup-ruby@v1
21
21
  with:
22
- ruby-version: '3.1'
22
+ ruby-version: '3.3'
23
23
  bundler-cache: true
24
24
 
25
25
  - name: Publish to GPR
data/Makefile CHANGED
@@ -2,8 +2,8 @@ PWD=$(shell pwd)
2
2
 
3
3
  .PHONY: docker-test
4
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"
5
+ docker run --rm -it -v $(PWD):/build -e WODBY_API_KEY=${WODBY_API_KEY} ruby:3.3 /bin/bash -c "cd build && bundle install && bundle exec rake test"
6
6
 
7
7
  .PHONY: docker-tester
8
8
  docker-tester:
9
- docker run --rm -it -v $(PWD):/build -e WODBY_API_KEY=${WODBY_API_KEY} ruby /bin/bash
9
+ docker run --rm -it -v $(PWD):/build -e WODBY_API_KEY=${WODBY_API_KEY} ruby:3.3 /bin/bash
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # fluent-plugin-wodby
2
2
 
3
- [Fluentd](https://fluentd.org/) filter plugin to do something.
3
+ [Fluentd](https://fluentd.org/) filter plugin to enrich logging data with Wodby instance information.
4
4
 
5
- TODO: write description for you plugin.
5
+ This plugin will query the [Wodby](https://wodby.com) API to retrieve information about the
6
+ Wodby instance producing the logs.
6
7
 
7
8
  ## Installation
8
9
 
@@ -38,6 +39,6 @@ You can copy and paste generated documents here.
38
39
 
39
40
  ## Copyright
40
41
 
41
- * Copyright(c) 2022- TODO: Write your name
42
+ * Copyright(c) 2022-2024: Ramsalt Lab
42
43
  * License
43
44
  * Apache License, Version 2.0
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-wodby"
6
- spec.version = "0.2.2"
6
+ spec.version = "0.3.1"
7
7
  spec.authors = ["Robert Wunderer"]
8
8
  spec.email = ["robert@ramsalt.com"]
9
9
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = test_files
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 2.3.7"
22
+ spec.add_development_dependency "bundler", "~> 2.5.0"
23
23
  spec.add_development_dependency "rake", "~> 13.0.6"
24
24
  spec.add_development_dependency "test-unit", "~> 3.5.3"
25
25
  spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2022- TODO: Write your name
2
+ # Copyright 2022-2024: Ramsalt Lab
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -32,12 +32,19 @@ module Fluent
32
32
  end
33
33
 
34
34
  def filter(tag, time, record)
35
- record['wodby.filter'] = true
35
+ record['wodby'] = {
36
+ 'filter' => true
37
+ }
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
36
43
 
37
44
  if record.has_key?('kubernetes') && record['kubernetes'].has_key?('namespace_name')
38
45
  namespace = record['kubernetes']['namespace_name']
39
46
  unless @instance_map.has_key?(namespace)
40
- record['wodby.instance_query'] = namespace
47
+ record['wodby']['instance_query'] = namespace
41
48
  instance = get_instance(namespace)
42
49
  app = get_app(instance['app_id'])
43
50
  org = get_org(app['org_id'])
@@ -51,11 +58,11 @@ module Fluent
51
58
  }
52
59
  end
53
60
 
54
- record['wodby.instance'] = @instance_map[namespace]['name']
55
- record['wodby.instance_title'] = @instance_map[namespace]['title']
56
- record['wodby.instance_type'] = @instance_map[namespace]['type']
57
- record['wodby.organization'] = @instance_map[namespace]['organization']
58
- record['wodby.organization_title'] = @instance_map[namespace]['organization_title']
61
+ record['wodby']['instance'] = @instance_map[namespace]['name']
62
+ record['wodby']['instance_title'] = @instance_map[namespace]['title']
63
+ record['wodby']['instance_type'] = @instance_map[namespace]['type']
64
+ record['wodby']['organization'] = @instance_map[namespace]['organization']
65
+ record['wodby']['organization_title'] = @instance_map[namespace]['organization_title']
59
66
  else
60
67
  log.info "No namespace found"
61
68
  log.info record
@@ -16,20 +16,23 @@ 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' => 'a3d67f12-8341-4245-87db-ed7a6c856e70'}, '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
22
  end
23
23
 
24
24
  assert_equal(3, d.filtered_records.size)
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'])
30
- assert_nil(d.filtered_records[2]['wodby.instance_query'])
31
- assert_true(d.filtered_records[0]['wodby.filter'])
32
- assert_true(d.filtered_records[1]['wodby.filter'])
33
- assert_true(d.filtered_records[2]['wodby.filter'])
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'])
30
+ assert_equal('node', d.filtered_records[0]['wodby']['node_name'])
31
+ assert_equal('node', d.filtered_records[1]['wodby']['node_name'])
32
+ assert_nil(d.filtered_records[2]['wodby']['instance_query'])
33
+ assert_nil(d.filtered_records[2]['wodby.node_name'])
34
+ assert_true(d.filtered_records[0]['wodby']['filter'])
35
+ assert_true(d.filtered_records[1]['wodby']['filter'])
36
+ assert_true(d.filtered_records[2]['wodby']['filter'])
34
37
  end
35
38
  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.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Wunderer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-07 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.7
19
+ version: 2.5.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.7
26
+ version: 2.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
- rubygems_version: 3.3.26
140
+ rubygems_version: 3.5.22
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Tranlates Wodbys instance UUIDs into instance names