fluent-plugin-kubernetes_metadata_filter 2.9.0 → 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/Gemfile.lock +3 -3
- data/fluent-plugin-kubernetes_metadata_filter.gemspec +1 -1
- data/lib/fluent/plugin/kubernetes_metadata_common.rb +2 -2
- data/test/cassettes/kubernetes_get_pod_container_init.yml +145 -0
- data/test/plugin/test_filter_kubernetes_metadata.rb +37 -0
- 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: 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/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-kubernetes_metadata_filter (2.9.
|
4
|
+
fluent-plugin-kubernetes_metadata_filter (2.9.1)
|
5
5
|
fluentd (>= 0.14.0, < 1.15)
|
6
6
|
kubeclient (>= 4.0.0, < 5.0.0)
|
7
7
|
lru_redux
|
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
ffi-compiler (1.0.1)
|
31
31
|
ffi (>= 1.0.0)
|
32
32
|
rake
|
33
|
-
fluentd (1.14.
|
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)
|
@@ -122,7 +122,7 @@ 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
|
@@ -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.9.
|
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'
|
@@ -79,7 +79,7 @@ module KubernetesMetadata
|
|
79
79
|
begin
|
80
80
|
pod_object[:status][:containerStatuses].each do |container_status|
|
81
81
|
# get plain container id (eg. docker://hash -> hash)
|
82
|
-
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]
|
83
83
|
container_meta[container_id] = if @skip_container_metadata
|
84
84
|
{
|
85
85
|
'name' => container_status[:name]
|
@@ -91,7 +91,7 @@ module KubernetesMetadata
|
|
91
91
|
'image_id' => container_status[:imageID]
|
92
92
|
}
|
93
93
|
end
|
94
|
-
end
|
94
|
+
end if pod_object[:status] && pod_object[:status][:containerStatuses]
|
95
95
|
rescue StandardError=>e
|
96
96
|
log.warn("parsing container meta information failed for: #{pod_object[:metadata][:namespace]}/#{pod_object[:metadata][:name]}: #{e}")
|
97
97
|
end
|
@@ -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('
|
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.9.
|
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
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- test/cassettes/kubernetes_get_namespace_default.yml
|
237
237
|
- test/cassettes/kubernetes_get_namespace_default_using_token.yml
|
238
238
|
- test/cassettes/kubernetes_get_pod.yml
|
239
|
+
- test/cassettes/kubernetes_get_pod_container_init.yml
|
239
240
|
- test/cassettes/kubernetes_get_pod_using_token.yml
|
240
241
|
- test/cassettes/metadata_from_tag_and_journald_fields.yml
|
241
242
|
- test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml
|