fluent-plugin-label-router 0.2.10 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +58 -0
- data/README.md +8 -7
- data/fluent-plugin-label-router.gemspec +1 -1
- data/lib/fluent/plugin/out_label_router.rb +9 -1
- data/test/plugin/test_out_label_router.rb +34 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd979b17d11338356a4aba41b453da815b59abac9169b4df7ec6aba97f60adf0
|
4
|
+
data.tar.gz: ed8c5dd1a8129582eaafb2ac8e93afc9b0be487b9b89a4dc44d8b90bc0bf0402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4031c23b18c50f72953be1d20264c19bd62feea1de49c55bdb479e180f72814bfc064756156b1b4a5d10e2ebe1e1e72339f103e423874d82a01c089da44e1cff
|
7
|
+
data.tar.gz: 0fa73c96e20e9ffb0da8442f2deafb27853434b78c665437a47f42646df2b3c5ba92c406792012d3cdfb41216916198728c45a46d0fca87b3f236ebbda18a74a
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fluent-plugin-label-router (0.3.0)
|
5
|
+
fluentd (>= 0.14.10, < 2)
|
6
|
+
prometheus-client (>= 2.1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
base64 (0.2.0)
|
12
|
+
concurrent-ruby (1.3.1)
|
13
|
+
cool.io (1.8.1)
|
14
|
+
csv (3.3.0)
|
15
|
+
drb (2.2.1)
|
16
|
+
fluentd (1.17.0)
|
17
|
+
base64 (~> 0.2)
|
18
|
+
bundler
|
19
|
+
cool.io (>= 1.4.5, < 2.0.0)
|
20
|
+
csv (~> 3.2)
|
21
|
+
drb (~> 2.2)
|
22
|
+
http_parser.rb (>= 0.5.1, < 0.9.0)
|
23
|
+
msgpack (>= 1.3.1, < 2.0.0)
|
24
|
+
serverengine (>= 2.3.2, < 3.0.0)
|
25
|
+
sigdump (~> 0.2.5)
|
26
|
+
strptime (>= 0.2.4, < 1.0.0)
|
27
|
+
tzinfo (>= 1.0, < 3.0)
|
28
|
+
tzinfo-data (~> 1.0)
|
29
|
+
webrick (~> 1.4)
|
30
|
+
yajl-ruby (~> 1.0)
|
31
|
+
http_parser.rb (0.8.0)
|
32
|
+
msgpack (1.7.2)
|
33
|
+
power_assert (2.0.3)
|
34
|
+
prometheus-client (4.2.2)
|
35
|
+
rake (12.3.3)
|
36
|
+
serverengine (2.3.2)
|
37
|
+
sigdump (~> 0.2.2)
|
38
|
+
sigdump (0.2.5)
|
39
|
+
strptime (0.2.5)
|
40
|
+
test-unit (3.6.2)
|
41
|
+
power_assert
|
42
|
+
tzinfo (2.0.6)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
tzinfo-data (1.2024.1)
|
45
|
+
tzinfo (>= 1.0.0)
|
46
|
+
webrick (1.8.1)
|
47
|
+
yajl-ruby (1.4.3)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
fluent-plugin-label-router!
|
54
|
+
rake (~> 12.0)
|
55
|
+
test-unit (~> 3.0)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
2.1.4
|
data/README.md
CHANGED
@@ -74,13 +74,14 @@ Configuration reference
|
|
74
74
|
|
75
75
|
|
76
76
|
#### \<match\>
|
77
|
-
| Parameter
|
78
|
-
|
79
|
-
| labels
|
80
|
-
| namespaces
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
| Parameter | Description | Type | Default |
|
78
|
+
|------------------|-------------------------------------------------------------------------------------------------------|----------|----------|
|
79
|
+
| labels | Label definition to match record. Example: `app:nginx` | Hash | nil |
|
80
|
+
| namespaces | Comma separated list of namespaces. Ignored if left empty. | []string | nil |
|
81
|
+
| namespace_labels | Label definition of the namespace a record originates. Example: `kubernetes.io/metadata.name=default` | Hash | nil |
|
82
|
+
| hosts | Comma separated list of hosts. Ignored if left empty. | []string | nil |
|
83
|
+
| container_names | Comma separated list of container names. Ignored if left empty. | []string | nil |
|
84
|
+
| negate | Negate the selector meaning to exclude matches | bool | false |
|
84
85
|
|
85
86
|
## Rules of thumb
|
86
87
|
|
@@ -53,6 +53,8 @@ module Fluent
|
|
53
53
|
config_param :labels, :hash, :default => {}
|
54
54
|
desc "List of namespace definition to filter the record. Ignored if left empty."
|
55
55
|
config_param :namespaces, :array, :default => [], value_type: :string
|
56
|
+
desc "List of namespace labels to filter the record based on where it came from. Ignored if left empty."
|
57
|
+
config_param :namespace_labels, :hash, :default => {}
|
56
58
|
desc "List of hosts definition to filter the record. Ignored if left empty."
|
57
59
|
config_param :hosts, :array, :default => [], value_type: :string
|
58
60
|
desc "List of container names definition to filter the record. Ignored if left empty."
|
@@ -117,6 +119,10 @@ module Fluent
|
|
117
119
|
unless match.namespaces.empty? || match.namespaces.include?(metadata[:namespace])
|
118
120
|
return false
|
119
121
|
end
|
122
|
+
# Break if list of namespace_labels is not empty and does not match actual namespace labels
|
123
|
+
if !match.namespace_labels.empty? && !match_labels(metadata[:namespace_labels], match.namespace_labels)
|
124
|
+
return false
|
125
|
+
end
|
120
126
|
|
121
127
|
match_labels(metadata[:labels], match.labels)
|
122
128
|
end
|
@@ -161,6 +167,7 @@ module Fluent
|
|
161
167
|
es.each do |time, record|
|
162
168
|
input_metadata = { labels: @access_to_labels.call(record).to_h,
|
163
169
|
namespace: @access_to_namespace.call(record).to_s,
|
170
|
+
namespace_labels: @access_to_namespace_labels.call(record).to_h,
|
164
171
|
container: @access_to_container_name.call(record).to_s,
|
165
172
|
host: @access_to_host.call(record).to_s}
|
166
173
|
orphan_record = true
|
@@ -217,6 +224,7 @@ module Fluent
|
|
217
224
|
end
|
218
225
|
|
219
226
|
@access_to_labels = record_accessor_create("$.kubernetes.labels")
|
227
|
+
@access_to_namespace_labels = record_accessor_create("$.kubernetes.namespace_labels")
|
220
228
|
@access_to_namespace = record_accessor_create("$.kubernetes.namespace_name")
|
221
229
|
@access_to_host = record_accessor_create("$.kubernetes.host")
|
222
230
|
@access_to_container_name = record_accessor_create("$.kubernetes.container_name")
|
@@ -225,4 +233,4 @@ module Fluent
|
|
225
233
|
end
|
226
234
|
end
|
227
235
|
end
|
228
|
-
end
|
236
|
+
end
|
@@ -72,6 +72,11 @@ class LabelRouterOutputTest < Test::Unit::TestCase
|
|
72
72
|
container_names mycontainer
|
73
73
|
</match>
|
74
74
|
</route>
|
75
|
+
<route>
|
76
|
+
<match>
|
77
|
+
namespaces_labels name:default
|
78
|
+
</match>
|
79
|
+
</route>
|
75
80
|
)
|
76
81
|
d = Fluent::Test::Driver::BaseOwner.new(Fluent::Plugin::LabelRouterOutput)
|
77
82
|
d.configure(routing_conf)
|
@@ -106,6 +111,10 @@ class LabelRouterOutputTest < Test::Unit::TestCase
|
|
106
111
|
assert_equal(false, r4.match?(labels: { 'app' => 'nginx' }, namespace: 'dev', container: 'mycontainer2'))
|
107
112
|
# Wrong label but good namespace and container_name
|
108
113
|
assert_equal(false, r4.match?(labels: { 'app' => 'nginx2' }, namespace: 'sandbox', container_name: 'mycontainer2'))
|
114
|
+
|
115
|
+
r4 = Fluent::Plugin::LabelRouterOutput::Route.new(d.instance.routes[4], nil,nil)
|
116
|
+
# Matching namespaces_labels
|
117
|
+
assert_equal(true, r4.match?(namespaces_labels: { 'name' => 'default' }))
|
109
118
|
end
|
110
119
|
end
|
111
120
|
|
@@ -134,6 +143,31 @@ class LabelRouterOutputTest < Test::Unit::TestCase
|
|
134
143
|
end
|
135
144
|
end
|
136
145
|
|
146
|
+
sub_test_case 'test_namespaces_labels' do
|
147
|
+
test 'normal' do
|
148
|
+
CONFIG = %[
|
149
|
+
<route>
|
150
|
+
<match>
|
151
|
+
namespace_labels matching:yes
|
152
|
+
</match>
|
153
|
+
tag matching
|
154
|
+
</route>
|
155
|
+
]
|
156
|
+
event_time = event_time("2019-07-17 11:11:11 UTC")
|
157
|
+
d = create_driver(CONFIG)
|
158
|
+
d.run(default_tag: 'test') do
|
159
|
+
d.feed(event_time, {"kubernetes" => {"namespace_labels" => {"matching" => "no"} } } )
|
160
|
+
end
|
161
|
+
d.run(default_tag: 'test2') do
|
162
|
+
d.feed(event_time, {"kubernetes" => {"namespace_labels" => {"matching" => "yes"} } } )
|
163
|
+
end
|
164
|
+
events = d.events
|
165
|
+
|
166
|
+
assert_equal(1, events.size)
|
167
|
+
assert_equal ["matching", event_time, {"kubernetes" => {"namespace_labels" => {"matching" => "yes"} } }], events[0]
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
137
171
|
|
138
172
|
sub_test_case 'test_multiple_events_batched' do
|
139
173
|
test 'normal' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-label-router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Banzai Cloud
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,7 +80,9 @@ executables: []
|
|
80
80
|
extensions: []
|
81
81
|
extra_rdoc_files: []
|
82
82
|
files:
|
83
|
+
- ".gitignore"
|
83
84
|
- Gemfile
|
85
|
+
- Gemfile.lock
|
84
86
|
- LICENSE
|
85
87
|
- README.md
|
86
88
|
- Rakefile
|
@@ -92,7 +94,7 @@ homepage: https://github.com/banzaicloud/fluent-plugin-label-router
|
|
92
94
|
licenses:
|
93
95
|
- Apache-2.0
|
94
96
|
metadata: {}
|
95
|
-
post_install_message:
|
97
|
+
post_install_message:
|
96
98
|
rdoc_options: []
|
97
99
|
require_paths:
|
98
100
|
- lib
|
@@ -107,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
109
|
- !ruby/object:Gem::Version
|
108
110
|
version: '0'
|
109
111
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
-
signing_key:
|
112
|
+
rubygems_version: 3.5.9
|
113
|
+
signing_key:
|
112
114
|
specification_version: 4
|
113
115
|
summary: Routing records based on Kubernetes labels.
|
114
116
|
test_files:
|