fluent-plugin-kubernetes_metadata_filter 2.7.2 → 2.9.1
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/.circleci/config.yml +1 -1
- data/Gemfile.lock +8 -8
- data/README.md +3 -1
- data/fluent-plugin-kubernetes_metadata_filter.gemspec +3 -3
- data/lib/fluent/plugin/filter_kubernetes_metadata.rb +16 -0
- data/lib/fluent/plugin/kubernetes_metadata_common.rb +12 -4
- data/test/cassettes/{kubernetes_docker_metadata_dotted_labels.yml → kubernetes_docker_metadata_dotted_slashed_labels.yml} +0 -0
- data/test/cassettes/kubernetes_get_pod_container_init.yml +145 -0
- data/test/plugin/test_filter_kubernetes_metadata.rb +56 -6
- data/test/plugin/watch_test.rb +2 -0
- metadata +15 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db4f0f5b097c04e8f958729fcd3946a08cff0629d38aa0844c062c511a318cf6
|
|
4
|
+
data.tar.gz: c828b3a3979a151d6fdabc73f0dd576c3e0e599e7fb9bb47ec4fe194daa63efa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 93aa9bfb3f313a035f5e00d8e82d8c898714058e6e591eb2b42a417f4c2ad58e8b4058d77b9a8943172231e936404d5d4cd5239f30e57f39eb629fd36bf973ca
|
|
7
|
+
data.tar.gz: a2615917cede625dda017f0b722999d3771dc8ce78f54b685d557884ad8bc13909899b34d8264e6f1d0a0b028f611c5635832f28f8198536837317f40064c157
|
data/.circleci/config.yml
CHANGED
|
@@ -12,7 +12,7 @@ missingdeps: &missingdeps
|
|
|
12
12
|
cat /etc/os-release
|
|
13
13
|
printf "deb http://deb.debian.org/debian buster main\ndeb http://security.debian.org buster/updates main\ndeb-src http://security.debian.org buster/updates main" > /tmp/sources.list
|
|
14
14
|
sudo cp /tmp/sources.list /etc/apt/sources.list
|
|
15
|
-
sudo apt-get update
|
|
15
|
+
sudo apt-get --allow-releaseinfo-change update
|
|
16
16
|
sudo apt-get install cmake libicu-dev libssl-dev
|
|
17
17
|
|
|
18
18
|
test: &test
|
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
fluent-plugin-kubernetes_metadata_filter (2.
|
|
5
|
-
fluentd (>= 0.14.0, < 1.
|
|
6
|
-
kubeclient (< 5)
|
|
4
|
+
fluent-plugin-kubernetes_metadata_filter (2.9.1)
|
|
5
|
+
fluentd (>= 0.14.0, < 1.15)
|
|
6
|
+
kubeclient (>= 4.0.0, < 5.0.0)
|
|
7
7
|
lru_redux
|
|
8
8
|
|
|
9
9
|
GEM
|
|
@@ -26,11 +26,11 @@ GEM
|
|
|
26
26
|
domain_name (0.5.20190701)
|
|
27
27
|
unf (>= 0.0.5, < 1.0.0)
|
|
28
28
|
escape_utils (1.2.1)
|
|
29
|
-
ffi (1.15.
|
|
29
|
+
ffi (1.15.4)
|
|
30
30
|
ffi-compiler (1.0.1)
|
|
31
31
|
ffi (>= 1.0.0)
|
|
32
32
|
rake
|
|
33
|
-
fluentd (1.
|
|
33
|
+
fluentd (1.14.1)
|
|
34
34
|
bundler
|
|
35
35
|
cool.io (>= 1.4.5, < 2.0.0)
|
|
36
36
|
http_parser.rb (>= 0.5.1, < 0.8.0)
|
|
@@ -70,7 +70,7 @@ GEM
|
|
|
70
70
|
lru_redux (1.1.0)
|
|
71
71
|
mime-types (3.3.1)
|
|
72
72
|
mime-types-data (~> 3.2015)
|
|
73
|
-
mime-types-data (3.2021.
|
|
73
|
+
mime-types-data (3.2021.0901)
|
|
74
74
|
mini_mime (1.0.2)
|
|
75
75
|
minitest (4.7.5)
|
|
76
76
|
msgpack (1.4.2)
|
|
@@ -122,11 +122,11 @@ GEM
|
|
|
122
122
|
test-unit (>= 2.5.2)
|
|
123
123
|
tzinfo (2.0.4)
|
|
124
124
|
concurrent-ruby (~> 1.0)
|
|
125
|
-
tzinfo-data (1.2021.
|
|
125
|
+
tzinfo-data (1.2021.3)
|
|
126
126
|
tzinfo (>= 1.0.0)
|
|
127
127
|
unf (0.1.4)
|
|
128
128
|
unf_ext
|
|
129
|
-
unf_ext (0.0.
|
|
129
|
+
unf_ext (0.0.8)
|
|
130
130
|
unicode-display_width (2.0.0)
|
|
131
131
|
vcr (6.0.0)
|
|
132
132
|
webmock (3.11.1)
|
data/README.md
CHANGED
|
@@ -45,8 +45,10 @@ This must used named capture groups for `container_name`, `pod_name` & `namespac
|
|
|
45
45
|
* `cache_size` - size of the cache of Kubernetes metadata to reduce requests to the API server (default: `1000`)
|
|
46
46
|
* `cache_ttl` - TTL in seconds of each cached element. Set to negative value to disable TTL eviction (default: `3600` - 1 hour)
|
|
47
47
|
* `watch` - set up a watch on pods on the API server for updates to metadata (default: `true`)
|
|
48
|
-
* `de_dot` - replace dots in labels and annotations with configured `de_dot_separator`, required for ElasticSearch 2.x compatibility (default: `true`)
|
|
48
|
+
* `de_dot` - replace dots in labels and annotations with configured `de_dot_separator`, required for Datadog and ElasticSearch 2.x compatibility (default: `true`)
|
|
49
49
|
* `de_dot_separator` - separator to use if `de_dot` is enabled (default: `_`)
|
|
50
|
+
* `de_slash` - replace slashes in labels and annotations with configured `de_slash_separator`, required for Datadog compatibility (default: `false`)
|
|
51
|
+
* `de_slash_separator` - separator to use if `de_slash` is enabled (default: `__`)
|
|
50
52
|
* *DEPRECATED* `use_journal` - If false, messages are expected to be formatted and tagged as if read by the fluentd in\_tail plugin with wildcard filename. If true, messages are expected to be formatted as if read from the systemd journal. The `MESSAGE` field has the full message. The `CONTAINER_NAME` field has the encoded k8s metadata (see below). The `CONTAINER_ID_FULL` field has the full container uuid. This requires docker to use the `--log-driver=journald` log driver. If unset (the default), the plugin will use the `CONTAINER_NAME` and `CONTAINER_ID_FULL` fields
|
|
51
53
|
if available, otherwise, will use the tag in the `tag_to_kubernetes_name_regexp` format.
|
|
52
54
|
* `container_name_to_kubernetes_regexp` - The regular expression used to extract the k8s metadata encoded in the journal `CONTAINER_NAME` field default: See [code](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/blob/master/lib/fluent/plugin/filter_kubernetes_metadata.rb#L68)
|
|
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = 'fluent-plugin-kubernetes_metadata_filter'
|
|
8
|
-
gem.version = '2.
|
|
8
|
+
gem.version = '2.9.1'
|
|
9
9
|
gem.authors = ['Jimmi Dyson']
|
|
10
10
|
gem.email = ['jimmidyson@gmail.com']
|
|
11
11
|
gem.description = 'Filter plugin to add Kubernetes metadata'
|
|
@@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
|
|
|
17
17
|
|
|
18
18
|
gem.required_ruby_version = '>= 2.5.0'
|
|
19
19
|
|
|
20
|
-
gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '< 1.
|
|
21
|
-
gem.add_runtime_dependency 'kubeclient', '< 5'
|
|
20
|
+
gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '< 1.15']
|
|
21
|
+
gem.add_runtime_dependency 'kubeclient', ['>= 4.0.0', '< 5.0.0']
|
|
22
22
|
gem.add_runtime_dependency 'lru_redux'
|
|
23
23
|
|
|
24
24
|
gem.add_development_dependency 'bump'
|
|
@@ -58,6 +58,8 @@ module Fluent::Plugin
|
|
|
58
58
|
config_param :secret_dir, :string, default: '/var/run/secrets/kubernetes.io/serviceaccount'
|
|
59
59
|
config_param :de_dot, :bool, default: true
|
|
60
60
|
config_param :de_dot_separator, :string, default: '_'
|
|
61
|
+
config_param :de_slash, :bool, default: false
|
|
62
|
+
config_param :de_slash_separator, :string, default: '__'
|
|
61
63
|
# if reading from the journal, the record will contain the following fields in the following
|
|
62
64
|
# format:
|
|
63
65
|
# CONTAINER_NAME=k8s_$containername.$containerhash_$podname_$namespacename_$poduuid_$rand32bitashex
|
|
@@ -166,6 +168,10 @@ module Fluent::Plugin
|
|
|
166
168
|
raise Fluent::ConfigError, "Invalid de_dot_separator: cannot be or contain '.'"
|
|
167
169
|
end
|
|
168
170
|
|
|
171
|
+
if @de_slash && @de_slash_separator.include?('/')
|
|
172
|
+
raise Fluent::ConfigError, "Invalid de_slash_separator: cannot be or contain '/'"
|
|
173
|
+
end
|
|
174
|
+
|
|
169
175
|
if @cache_ttl < 0
|
|
170
176
|
log.info 'Setting the cache TTL to :none because it was <= 0'
|
|
171
177
|
@cache_ttl = :none
|
|
@@ -381,6 +387,16 @@ module Fluent::Plugin
|
|
|
381
387
|
end
|
|
382
388
|
end
|
|
383
389
|
|
|
390
|
+
def de_slash!(h)
|
|
391
|
+
h.keys.each do |ref|
|
|
392
|
+
next unless h[ref] && ref =~ /\//
|
|
393
|
+
|
|
394
|
+
v = h.delete(ref)
|
|
395
|
+
newref = ref.to_s.gsub('/', @de_slash_separator)
|
|
396
|
+
h[newref] = v
|
|
397
|
+
end
|
|
398
|
+
end
|
|
399
|
+
|
|
384
400
|
# copied from activesupport
|
|
385
401
|
def present?(object)
|
|
386
402
|
object.respond_to?(:empty?) ? !object.empty? : !!object
|
|
@@ -47,6 +47,10 @@ module KubernetesMetadata
|
|
|
47
47
|
de_dot!(labels) unless @skip_labels
|
|
48
48
|
de_dot!(annotations)
|
|
49
49
|
end
|
|
50
|
+
if @de_slash
|
|
51
|
+
de_slash!(labels) unless @skip_labels
|
|
52
|
+
de_slash!(annotations)
|
|
53
|
+
end
|
|
50
54
|
kubernetes_metadata = {
|
|
51
55
|
'namespace_id' => namespace_object[:metadata][:uid],
|
|
52
56
|
'creation_timestamp' => namespace_object[:metadata][:creationTimestamp]
|
|
@@ -65,13 +69,17 @@ module KubernetesMetadata
|
|
|
65
69
|
de_dot!(labels) unless @skip_labels
|
|
66
70
|
de_dot!(annotations)
|
|
67
71
|
end
|
|
72
|
+
if @de_slash
|
|
73
|
+
de_slash!(labels) unless @skip_labels
|
|
74
|
+
de_slash!(annotations)
|
|
75
|
+
end
|
|
68
76
|
|
|
69
77
|
# collect container information
|
|
70
78
|
container_meta = {}
|
|
71
79
|
begin
|
|
72
80
|
pod_object[:status][:containerStatuses].each do |container_status|
|
|
73
81
|
# get plain container id (eg. docker://hash -> hash)
|
|
74
|
-
container_id = container_status[:containerID].sub(%r{^[-_a-zA-Z0-9]+://}, '')
|
|
82
|
+
container_id = container_status[:containerID] ? container_status[:containerID].sub(%r{^[-_a-zA-Z0-9]+://}, '') : container_status[:name]
|
|
75
83
|
container_meta[container_id] = if @skip_container_metadata
|
|
76
84
|
{
|
|
77
85
|
'name' => container_status[:name]
|
|
@@ -83,9 +91,9 @@ module KubernetesMetadata
|
|
|
83
91
|
'image_id' => container_status[:imageID]
|
|
84
92
|
}
|
|
85
93
|
end
|
|
86
|
-
end
|
|
87
|
-
rescue StandardError
|
|
88
|
-
log.
|
|
94
|
+
end if pod_object[:status] && pod_object[:status][:containerStatuses]
|
|
95
|
+
rescue StandardError=>e
|
|
96
|
+
log.warn("parsing container meta information failed for: #{pod_object[:metadata][:namespace]}/#{pod_object[:metadata][:name]}: #{e}")
|
|
89
97
|
end
|
|
90
98
|
|
|
91
99
|
kubernetes_metadata = {
|
|
File without changes
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Fluentd Kubernetes Metadata Filter Plugin - Enrich Fluentd events with
|
|
3
|
+
# Kubernetes metadata
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2015 Red Hat, Inc.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
---
|
|
20
|
+
http_interactions:
|
|
21
|
+
- request:
|
|
22
|
+
method: get
|
|
23
|
+
uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc
|
|
24
|
+
body:
|
|
25
|
+
encoding: US-ASCII
|
|
26
|
+
string: ''
|
|
27
|
+
headers:
|
|
28
|
+
Accept:
|
|
29
|
+
- "*/*; q=0.5, application/xml"
|
|
30
|
+
Accept-Encoding:
|
|
31
|
+
- gzip, deflate
|
|
32
|
+
User-Agent:
|
|
33
|
+
- Ruby
|
|
34
|
+
response:
|
|
35
|
+
status:
|
|
36
|
+
code: 200
|
|
37
|
+
message: OK
|
|
38
|
+
headers:
|
|
39
|
+
Content-Type:
|
|
40
|
+
- application/json
|
|
41
|
+
Date:
|
|
42
|
+
- Fri, 08 May 2015 10:35:37 GMT
|
|
43
|
+
Transfer-Encoding:
|
|
44
|
+
- chunked
|
|
45
|
+
body:
|
|
46
|
+
encoding: UTF-8
|
|
47
|
+
string: |-
|
|
48
|
+
{
|
|
49
|
+
"kind": "Pod",
|
|
50
|
+
"apiVersion": "v1",
|
|
51
|
+
"metadata": {
|
|
52
|
+
"name": "fabric8-console-controller-98rqc",
|
|
53
|
+
"generateName": "fabric8-console-controller-",
|
|
54
|
+
"namespace": "default",
|
|
55
|
+
"selfLink": "/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc",
|
|
56
|
+
"uid": "c76927af-f563-11e4-b32d-54ee7527188d",
|
|
57
|
+
"resourceVersion": "122",
|
|
58
|
+
"creationTimestamp": "2015-05-08T09:22:42Z",
|
|
59
|
+
"labels": {
|
|
60
|
+
"component": "fabric8Console"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"spec": {
|
|
64
|
+
"volumes": [
|
|
65
|
+
{
|
|
66
|
+
"name": "openshift-cert-secrets",
|
|
67
|
+
"hostPath": null,
|
|
68
|
+
"emptyDir": null,
|
|
69
|
+
"gcePersistentDisk": null,
|
|
70
|
+
"gitRepo": null,
|
|
71
|
+
"secret": {
|
|
72
|
+
"secretName": "openshift-cert-secrets"
|
|
73
|
+
},
|
|
74
|
+
"nfs": null,
|
|
75
|
+
"iscsi": null,
|
|
76
|
+
"glusterfs": null
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"containers": [
|
|
80
|
+
{
|
|
81
|
+
"name": "fabric8-console-container",
|
|
82
|
+
"image": "fabric8/hawtio-kubernetes:latest",
|
|
83
|
+
"ports": [
|
|
84
|
+
{
|
|
85
|
+
"containerPort": 9090,
|
|
86
|
+
"protocol": "TCP"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"env": [
|
|
90
|
+
{
|
|
91
|
+
"name": "OAUTH_CLIENT_ID",
|
|
92
|
+
"value": "fabric8-console"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "OAUTH_AUTHORIZE_URI",
|
|
96
|
+
"value": "https://localhost:8443/oauth/authorize"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"resources": {},
|
|
100
|
+
"volumeMounts": [
|
|
101
|
+
{
|
|
102
|
+
"name": "openshift-cert-secrets",
|
|
103
|
+
"readOnly": true,
|
|
104
|
+
"mountPath": "/etc/secret-volume"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"terminationMessagePath": "/dev/termination-log",
|
|
108
|
+
"imagePullPolicy": "IfNotPresent",
|
|
109
|
+
"capabilities": {}
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"restartPolicy": "Always",
|
|
113
|
+
"dnsPolicy": "ClusterFirst",
|
|
114
|
+
"nodeName": "jimmi-redhat.localnet"
|
|
115
|
+
},
|
|
116
|
+
"status": {
|
|
117
|
+
"phase": "Running",
|
|
118
|
+
"Condition": [
|
|
119
|
+
{
|
|
120
|
+
"type": "Ready",
|
|
121
|
+
"status": "True"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"hostIP": "172.17.42.1",
|
|
125
|
+
"podIP": "172.17.0.8",
|
|
126
|
+
"containerStatuses": [
|
|
127
|
+
{
|
|
128
|
+
"name": "fabric8-console-container",
|
|
129
|
+
"state": {
|
|
130
|
+
"waiting": {
|
|
131
|
+
"reason": "ContainerCreating"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"lastState": {},
|
|
135
|
+
"ready": true,
|
|
136
|
+
"restartCount": 0,
|
|
137
|
+
"image": "fabric8/hawtio-kubernetes:latest",
|
|
138
|
+
"imageID": ""
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
http_version:
|
|
144
|
+
recorded_at: Fri, 08 May 2015 10:35:37 GMT
|
|
145
|
+
recorded_with: VCR 2.9.3
|
|
@@ -165,6 +165,43 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
|
|
|
165
165
|
plugin.filter_stream('tag', Fluent::MultiEventStream.new)
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
+
sub_test_case 'parsing_pod_metadata' do
|
|
169
|
+
test 'when container_status is missing from the pod status' do
|
|
170
|
+
VCR.use_cassettes(
|
|
171
|
+
[
|
|
172
|
+
{ name: 'valid_kubernetes_api_server' },
|
|
173
|
+
{ name: 'kubernetes_get_api_v1' },
|
|
174
|
+
{ name: 'kubernetes_get_namespace_default' },
|
|
175
|
+
{ name: 'kubernetes_get_pod_container_init' }
|
|
176
|
+
]) do
|
|
177
|
+
filtered = emit({}, '
|
|
178
|
+
kubernetes_url https://localhost:8443
|
|
179
|
+
watch false
|
|
180
|
+
cache_size 1
|
|
181
|
+
')
|
|
182
|
+
expected_kube_metadata = {
|
|
183
|
+
'docker' => {
|
|
184
|
+
'container_id' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459'
|
|
185
|
+
},
|
|
186
|
+
'kubernetes' => {
|
|
187
|
+
'container_name'=>'fabric8-console-container',
|
|
188
|
+
'host' => 'jimmi-redhat.localnet',
|
|
189
|
+
'pod_name' => 'fabric8-console-controller-98rqc',
|
|
190
|
+
'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
|
|
191
|
+
'namespace_name' => 'default',
|
|
192
|
+
'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
|
|
193
|
+
'pod_ip' => '172.17.0.8',
|
|
194
|
+
'master_url' => 'https://localhost:8443',
|
|
195
|
+
'labels' => {
|
|
196
|
+
'component' => 'fabric8Console'
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
assert_equal(expected_kube_metadata, filtered[0])
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
168
205
|
test 'inability to connect to the api server handles exception and doensnt block pipeline' do
|
|
169
206
|
VCR.use_cassettes([{ name: 'valid_kubernetes_api_server' }, { name: 'kubernetes_get_api_v1' }]) do
|
|
170
207
|
driver = create_driver('
|
|
@@ -432,13 +469,15 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
|
|
|
432
469
|
assert_equal(msg, filtered[0])
|
|
433
470
|
end
|
|
434
471
|
|
|
435
|
-
test 'with kubernetes dotted labels, de_dot enabled' do
|
|
472
|
+
test 'with kubernetes dotted and slashed labels, de_dot and de_slash enabled' do
|
|
436
473
|
VCR.use_cassettes([{ name: 'valid_kubernetes_api_server' }, { name: 'kubernetes_get_api_v1' },
|
|
437
|
-
{ name: '
|
|
474
|
+
{ name: 'kubernetes_docker_metadata_dotted_slashed_labels' }]) do
|
|
438
475
|
filtered = emit({}, '
|
|
439
476
|
kubernetes_url https://localhost:8443
|
|
440
477
|
watch false
|
|
441
478
|
cache_size 1
|
|
479
|
+
de_dot true
|
|
480
|
+
de_slash true
|
|
442
481
|
')
|
|
443
482
|
expected_kube_metadata = {
|
|
444
483
|
'docker' => {
|
|
@@ -452,14 +491,14 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
|
|
|
452
491
|
'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
|
|
453
492
|
'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
|
|
454
493
|
'namespace_labels' => {
|
|
455
|
-
'
|
|
494
|
+
'kubernetes_io__namespacetest' => 'somevalue'
|
|
456
495
|
},
|
|
457
496
|
'namespace_name' => 'default',
|
|
458
497
|
'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
|
|
459
498
|
'pod_ip' => '172.17.0.8',
|
|
460
499
|
'master_url' => 'https://localhost:8443',
|
|
461
500
|
'labels' => {
|
|
462
|
-
'
|
|
501
|
+
'kubernetes_io__test' => 'somevalue'
|
|
463
502
|
}
|
|
464
503
|
}
|
|
465
504
|
}
|
|
@@ -467,14 +506,15 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
|
|
|
467
506
|
end
|
|
468
507
|
end
|
|
469
508
|
|
|
470
|
-
test 'with kubernetes dotted labels, de_dot disabled' do
|
|
509
|
+
test 'with kubernetes dotted and slashed labels, de_dot and de_slash disabled' do
|
|
471
510
|
VCR.use_cassettes([{ name: 'valid_kubernetes_api_server' }, { name: 'kubernetes_get_api_v1' },
|
|
472
|
-
{ name: '
|
|
511
|
+
{ name: 'kubernetes_docker_metadata_dotted_slashed_labels' }]) do
|
|
473
512
|
filtered = emit({}, '
|
|
474
513
|
kubernetes_url https://localhost:8443
|
|
475
514
|
watch false
|
|
476
515
|
cache_size 1
|
|
477
516
|
de_dot false
|
|
517
|
+
de_slash false
|
|
478
518
|
')
|
|
479
519
|
expected_kube_metadata = {
|
|
480
520
|
'docker' => {
|
|
@@ -506,11 +546,21 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
|
|
|
506
546
|
test 'invalid de_dot_separator config' do
|
|
507
547
|
assert_raise Fluent::ConfigError do
|
|
508
548
|
create_driver('
|
|
549
|
+
de_dot true
|
|
509
550
|
de_dot_separator contains.
|
|
510
551
|
')
|
|
511
552
|
end
|
|
512
553
|
end
|
|
513
554
|
|
|
555
|
+
test 'invalid de_slash_separator config' do
|
|
556
|
+
assert_raise Fluent::ConfigError do
|
|
557
|
+
create_driver('
|
|
558
|
+
de_slash true
|
|
559
|
+
de_slash_separator contains/
|
|
560
|
+
')
|
|
561
|
+
end
|
|
562
|
+
end
|
|
563
|
+
|
|
514
564
|
test 'with records from journald and docker & kubernetes metadata' do
|
|
515
565
|
# with use_journal true should ignore tags and use CONTAINER_NAME and CONTAINER_ID_FULL
|
|
516
566
|
tag = 'var.log.containers.junk1_junk2_junk3-49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed450.log'
|
data/test/plugin/watch_test.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-kubernetes_metadata_filter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jimmi Dyson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-10-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fluentd
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: 0.14.0
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '1.
|
|
22
|
+
version: '1.15'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,21 +29,27 @@ dependencies:
|
|
|
29
29
|
version: 0.14.0
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '1.
|
|
32
|
+
version: '1.15'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: kubeclient
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 4.0.0
|
|
37
40
|
- - "<"
|
|
38
41
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
42
|
+
version: 5.0.0
|
|
40
43
|
type: :runtime
|
|
41
44
|
prerelease: false
|
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
46
|
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: 4.0.0
|
|
44
50
|
- - "<"
|
|
45
51
|
- !ruby/object:Gem::Version
|
|
46
|
-
version:
|
|
52
|
+
version: 5.0.0
|
|
47
53
|
- !ruby/object:Gem::Dependency
|
|
48
54
|
name: lru_redux
|
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -224,12 +230,13 @@ files:
|
|
|
224
230
|
- lib/fluent/plugin/kubernetes_metadata_watch_pods.rb
|
|
225
231
|
- test/cassettes/invalid_api_server_config.yml
|
|
226
232
|
- test/cassettes/kubernetes_docker_metadata_annotations.yml
|
|
227
|
-
- test/cassettes/
|
|
233
|
+
- test/cassettes/kubernetes_docker_metadata_dotted_slashed_labels.yml
|
|
228
234
|
- test/cassettes/kubernetes_get_api_v1.yml
|
|
229
235
|
- test/cassettes/kubernetes_get_api_v1_using_token.yml
|
|
230
236
|
- test/cassettes/kubernetes_get_namespace_default.yml
|
|
231
237
|
- test/cassettes/kubernetes_get_namespace_default_using_token.yml
|
|
232
238
|
- test/cassettes/kubernetes_get_pod.yml
|
|
239
|
+
- test/cassettes/kubernetes_get_pod_container_init.yml
|
|
233
240
|
- test/cassettes/kubernetes_get_pod_using_token.yml
|
|
234
241
|
- test/cassettes/metadata_from_tag_and_journald_fields.yml
|
|
235
242
|
- test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml
|
|
@@ -263,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
263
270
|
- !ruby/object:Gem::Version
|
|
264
271
|
version: '0'
|
|
265
272
|
requirements: []
|
|
266
|
-
rubygems_version: 3.
|
|
273
|
+
rubygems_version: 3.0.9
|
|
267
274
|
signing_key:
|
|
268
275
|
specification_version: 4
|
|
269
276
|
summary: Fluentd filter plugin to add Kubernetes metadata
|