fluent-plugin-kubernetes_metadata_filter 3.3.0 → 3.5.0

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: 1425638a4efbcc9ed55bee88eb1563ba071c6d7afc9ca0b9f556a4528bfb6f05
4
- data.tar.gz: 531e074b6271d05fade448979dc11cd7d2d075bd2941587cb2341fd8e3f7076f
3
+ metadata.gz: 57614dafa7cf3621cb5d3ade3bdfe3a72a37476d61bf2eb5ee5b371dd3174699
4
+ data.tar.gz: c4e298eca7e0049b747d92079d6a867d4e2d6fcce3f35dd44ed362a9eef33373
5
5
  SHA512:
6
- metadata.gz: 78aca0f62942579b5c1be309857a920ee623ff71903e9d00cc6415b7b8dcc37e7a23d4be8baa024c54959963fb4c356a352e42229c08b7257bd65281bf987faf
7
- data.tar.gz: 5dda7ace28a80bf02c28ac7f2dc016ad83f056e1d85c95bc6b599554d8ef9145dc4643c490776ce7deaf1f8e968caa720cf024a27236e45cd844cbd88538d661
6
+ metadata.gz: ddd8c41c2f3717b1c890b746bbc3cf0b80844162f79d54524565c3cac259ce0667ca73aaaeeaffc7e8ba6782e28eaeea5b7c4274b382ce564821a7cfb19c8cff
7
+ data.tar.gz: 05a5d2f83f666514dec72fa6946f260f48be0dec11a8a8ae2efe14028974d1ba2475b384423339a5763afa869d050767e74a504ae3c2c16064040e78e55f1d1e
data/.circleci/config.yml CHANGED
@@ -3,7 +3,7 @@ version: 2.1
3
3
  install: &install
4
4
  name: Install bundle
5
5
  command: |
6
- gem install bundler
6
+ gem install bundler -v 2.4.22
7
7
  bundle config set --local path vendor/bundle
8
8
  bundle install
9
9
 
@@ -11,7 +11,7 @@ missingdeps: &missingdeps
11
11
  name: Install missing dependecies
12
12
  command: |
13
13
  cat /etc/os-release
14
- 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
+ sed -e 's/^# deb-src/deb-src/g' /etc/apt/sources.list > /tmp/sources.list
15
15
  sudo cp /tmp/sources.list /etc/apt/sources.list
16
16
  sudo apt-get --allow-releaseinfo-change update
17
17
  sudo apt-get install cmake libicu-dev libssl-dev
@@ -21,12 +21,9 @@ test: &test
21
21
  command: bundle exec rake test --trace
22
22
 
23
23
  executors:
24
- ruby-2-6:
25
- docker:
26
- - image: circleci/ruby:2.6.3
27
24
  ruby-2-7:
28
25
  docker:
29
- - image: circleci/ruby:2.7.1
26
+ - image: cimg/ruby:2.7.8
30
27
  jobs:
31
28
  "ruby-test":
32
29
  parameters:
@@ -47,7 +44,5 @@ jobs:
47
44
  workflows:
48
45
  "test_multiple_ruby_versions":
49
46
  jobs:
50
- - ruby-test:
51
- ruby-version: ruby-2-6
52
47
  - ruby-test:
53
48
  ruby-version: ruby-2-7
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-kubernetes_metadata_filter (3.3.0)
5
- fluentd (>= 0.14.0, < 1.17)
4
+ fluent-plugin-kubernetes_metadata_filter (3.5.0)
5
+ fluentd (>= 0.14.0, < 1.18)
6
6
  kubeclient (>= 4.0.0, < 5.0.0)
7
7
  lru_redux
8
8
 
@@ -12,27 +12,32 @@ GEM
12
12
  addressable (2.8.0)
13
13
  public_suffix (>= 2.0.2, < 5.0)
14
14
  ast (2.4.2)
15
+ base64 (0.2.0)
15
16
  bump (0.10.0)
16
17
  charlock_holmes (0.7.7)
17
18
  codeclimate-test-reporter (0.6.0)
18
19
  simplecov (>= 0.7.1, < 1.0.0)
19
- concurrent-ruby (1.2.2)
20
- cool.io (1.8.0)
20
+ concurrent-ruby (1.3.3)
21
+ cool.io (1.8.1)
21
22
  copyright-header (1.0.22)
22
23
  github-linguist
23
24
  crack (0.4.5)
24
25
  rexml
26
+ csv (3.3.0)
25
27
  docile (1.4.0)
26
- domain_name (0.5.20190701)
27
- unf (>= 0.0.5, < 1.0.0)
28
+ domain_name (0.6.20240107)
29
+ drb (2.2.1)
28
30
  escape_utils (1.2.2)
29
- ffi (1.15.5)
30
- ffi-compiler (1.0.1)
31
- ffi (>= 1.0.0)
31
+ ffi (1.17.0)
32
+ ffi-compiler (1.3.2)
33
+ ffi (>= 1.15.5)
32
34
  rake
33
- fluentd (1.16.2)
35
+ fluentd (1.17.0)
36
+ base64 (~> 0.2)
34
37
  bundler
35
38
  cool.io (>= 1.4.5, < 2.0.0)
39
+ csv (~> 3.2)
40
+ drb (~> 2.2)
36
41
  http_parser.rb (>= 0.5.1, < 0.9.0)
37
42
  msgpack (>= 1.3.1, < 2.0.0)
38
43
  serverengine (>= 2.3.2, < 3.0.0)
@@ -48,30 +53,31 @@ GEM
48
53
  mini_mime (~> 1.0)
49
54
  rugged (~> 1.0)
50
55
  hashdiff (1.0.1)
51
- http (5.1.1)
56
+ http (5.2.0)
52
57
  addressable (~> 2.8)
58
+ base64 (~> 0.1)
53
59
  http-cookie (~> 1.0)
54
60
  http-form_data (~> 2.2)
55
- llhttp-ffi (~> 0.4.0)
61
+ llhttp-ffi (~> 0.5.0)
56
62
  http-accept (1.7.0)
57
- http-cookie (1.0.5)
63
+ http-cookie (1.0.6)
58
64
  domain_name (~> 0.5)
59
65
  http-form_data (2.3.0)
60
66
  http_parser.rb (0.8.0)
61
- jsonpath (1.1.3)
67
+ jsonpath (1.1.5)
62
68
  multi_json
63
69
  kubeclient (4.11.0)
64
70
  http (>= 3.0, < 6.0)
65
71
  jsonpath (~> 1.0)
66
72
  recursive-open-struct (~> 1.1, >= 1.1.1)
67
73
  rest-client (~> 2.0)
68
- llhttp-ffi (0.4.0)
74
+ llhttp-ffi (0.5.0)
69
75
  ffi-compiler (~> 1.0)
70
76
  rake (~> 13.0)
71
77
  lru_redux (1.1.0)
72
- mime-types (3.5.0)
78
+ mime-types (3.5.2)
73
79
  mime-types-data (~> 3.2015)
74
- mime-types-data (3.2023.0808)
80
+ mime-types-data (3.2024.0604)
75
81
  mini_mime (1.1.2)
76
82
  minitest (4.7.5)
77
83
  msgpack (1.7.2)
@@ -84,7 +90,7 @@ GEM
84
90
  public_suffix (4.0.7)
85
91
  rainbow (3.1.1)
86
92
  rake (13.0.6)
87
- recursive-open-struct (1.1.3)
93
+ recursive-open-struct (1.2.1)
88
94
  regexp_parser (2.5.0)
89
95
  rest-client (2.1.0)
90
96
  http-accept (>= 1.7.0, < 2.0)
@@ -123,11 +129,8 @@ GEM
123
129
  test-unit (>= 2.5.2)
124
130
  tzinfo (2.0.6)
125
131
  concurrent-ruby (~> 1.0)
126
- tzinfo-data (1.2023.3)
132
+ tzinfo-data (1.2024.1)
127
133
  tzinfo (>= 1.0.0)
128
- unf (0.1.4)
129
- unf_ext
130
- unf_ext (0.0.8.2)
131
134
  unicode-display_width (2.2.0)
132
135
  vcr (6.0.0)
133
136
  webmock (3.14.0)
data/README.md CHANGED
@@ -64,6 +64,7 @@ when true (default: `true`)
64
64
  * `watch_retry_interval` - The time interval in seconds for retry backoffs when watch connections fail. (default: `10`)
65
65
  * `open_timeout` - The time in seconds to wait for a connection to kubernetes service. (default: `3`)
66
66
  * `read_timeout` - The time in seconds to wait for a read from kubernetes service. (default: `10`)
67
+ * `include_ownerrefs_metadata` - If set to true, it will include metadata (`kind` & `name`) in `kubernetes.ownerrefs` about the controller that owns the pod. (default: `false`)
67
68
 
68
69
 
69
70
  Reading from a JSON formatted log files with `in_tail` and wildcard filenames while respecting the CRI-o log format with the same config you need the fluent-plugin "multi-format-parser":
@@ -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 = '3.3.0'
8
+ gem.version = '3.5.0'
9
9
  gem.authors = ['OpenShift Cluster Logging','Jimmi Dyson']
10
10
  gem.email = ['team-logging@redhat.com','jimmidyson@gmail.com']
11
11
  gem.description = 'Filter plugin to add Kubernetes metadata'
@@ -15,9 +15,9 @@ Gem::Specification.new do |gem|
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
17
 
18
- gem.required_ruby_version = '>= 2.6.0'
18
+ gem.required_ruby_version = '>= 2.7.0'
19
19
 
20
- gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '< 1.17']
20
+ gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '< 1.18']
21
21
  gem.add_runtime_dependency 'kubeclient', ['>= 4.0.0', '< 5.0.0']
22
22
  gem.add_runtime_dependency 'lru_redux'
23
23
 
@@ -82,6 +82,7 @@ module Fluent::Plugin
82
82
  config_param :skip_container_metadata, :bool, default: false
83
83
  config_param :skip_master_url, :bool, default: false
84
84
  config_param :skip_namespace_metadata, :bool, default: false
85
+ config_param :include_ownerrefs_metadata, :bool, default: false
85
86
 
86
87
  # A classname in the form of Test::APIAdapter which will try
87
88
  # to be resolved from a relative named file 'test_api_adapter'
@@ -82,14 +82,27 @@ module KubernetesMetadata
82
82
  log.warn("parsing container meta information failed for: #{pod_object[:metadata][:namespace]}/#{pod_object[:metadata][:name]}: #{e}")
83
83
  end
84
84
 
85
+ ownerrefs_meta = []
86
+ begin
87
+ pod_object[:metadata][:ownerReferences].each do |owner_reference|
88
+ ownerrefs_meta.append({
89
+ 'kind' => owner_reference[:kind],
90
+ 'name' => owner_reference[:name]
91
+ })
92
+ end
93
+ rescue StandardError => e
94
+ log.warn("parsing ownerrefs meta information failed for: #{pod_object[:metadata][:namespace]}/#{pod_object[:metadata][:name]}: #{e}")
95
+ end if @include_ownerrefs_metadata && pod_object[:metadata][:ownerReferences]
96
+
85
97
  kubernetes_metadata = {
86
98
  'namespace_name' => pod_object[:metadata][:namespace],
87
99
  'pod_id' => pod_object[:metadata][:uid],
88
100
  'pod_name' => pod_object[:metadata][:name],
89
101
  'pod_ip' => pod_object[:status][:podIP],
90
102
  'containers' => syms_to_strs(container_meta),
91
- 'host' => pod_object[:spec][:nodeName]
92
- }
103
+ 'host' => pod_object[:spec][:nodeName],
104
+ 'ownerrefs' => (ownerrefs_meta if @include_ownerrefs_metadata)
105
+ }.compact
93
106
  kubernetes_metadata['annotations'] = annotations unless annotations.empty?
94
107
  kubernetes_metadata['labels'] = labels unless labels.empty?
95
108
  kubernetes_metadata['master_url'] = @kubernetes_url unless @skip_master_url
@@ -0,0 +1,156 @@
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
+ "ownerReferences": [
63
+ {
64
+ "apiVersion": "apps/v1",
65
+ "blockOwnerDeletion": true,
66
+ "controller": true,
67
+ "kind": "ReplicaSet",
68
+ "name": "fabric8-console-controller",
69
+ "uid": "dd1ac3e1-bc88-4c54-be0f-26ac2406d884"
70
+ }
71
+ ]
72
+ },
73
+ "spec": {
74
+ "volumes": [
75
+ {
76
+ "name": "openshift-cert-secrets",
77
+ "hostPath": null,
78
+ "emptyDir": null,
79
+ "gcePersistentDisk": null,
80
+ "gitRepo": null,
81
+ "secret": {
82
+ "secretName": "openshift-cert-secrets"
83
+ },
84
+ "nfs": null,
85
+ "iscsi": null,
86
+ "glusterfs": null
87
+ }
88
+ ],
89
+ "containers": [
90
+ {
91
+ "name": "fabric8-console-container",
92
+ "image": "fabric8/hawtio-kubernetes:latest",
93
+ "ports": [
94
+ {
95
+ "containerPort": 9090,
96
+ "protocol": "TCP"
97
+ }
98
+ ],
99
+ "env": [
100
+ {
101
+ "name": "OAUTH_CLIENT_ID",
102
+ "value": "fabric8-console"
103
+ },
104
+ {
105
+ "name": "OAUTH_AUTHORIZE_URI",
106
+ "value": "https://localhost:8443/oauth/authorize"
107
+ }
108
+ ],
109
+ "resources": {},
110
+ "volumeMounts": [
111
+ {
112
+ "name": "openshift-cert-secrets",
113
+ "readOnly": true,
114
+ "mountPath": "/etc/secret-volume"
115
+ }
116
+ ],
117
+ "terminationMessagePath": "/dev/termination-log",
118
+ "imagePullPolicy": "IfNotPresent",
119
+ "capabilities": {}
120
+ }
121
+ ],
122
+ "restartPolicy": "Always",
123
+ "dnsPolicy": "ClusterFirst",
124
+ "nodeName": "jimmi-redhat.localnet"
125
+ },
126
+ "status": {
127
+ "phase": "Running",
128
+ "Condition": [
129
+ {
130
+ "type": "Ready",
131
+ "status": "True"
132
+ }
133
+ ],
134
+ "hostIP": "172.17.42.1",
135
+ "podIP": "172.17.0.8",
136
+ "containerStatuses": [
137
+ {
138
+ "name": "fabric8-console-container",
139
+ "state": {
140
+ "running": {
141
+ "startedAt": "2015-05-08T09:22:44Z"
142
+ }
143
+ },
144
+ "lastState": {},
145
+ "ready": true,
146
+ "restartCount": 0,
147
+ "image": "fabric8/hawtio-kubernetes:latest",
148
+ "imageID": "docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303",
149
+ "containerID": "docker://49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459"
150
+ }
151
+ ]
152
+ }
153
+ }
154
+ http_version:
155
+ recorded_at: Fri, 08 May 2015 10:35:37 GMT
156
+ recorded_with: VCR 2.9.3
@@ -805,6 +805,47 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
805
805
  assert_equal(expected_kube_metadata, filtered[0])
806
806
  end
807
807
  end
808
+ test 'with docker & kubernetes metadata using include ownerrefs metadata' do
809
+ VCR.use_cassettes([{ name: 'valid_kubernetes_api_server' },
810
+ { name: 'kubernetes_get_api_v1' },
811
+ { name: 'kubernetes_get_pod_with_ownerrefs' },
812
+ { name: 'kubernetes_get_namespace_default' }]) do
813
+ filtered = emit({}, '
814
+ kubernetes_url https://localhost:8443
815
+ watch false
816
+ cache_size 1
817
+ stats_interval 0
818
+ skip_pod_labels true
819
+ skip_master_url true
820
+ include_ownerrefs_metadata true
821
+ ')
822
+ expected_kube_metadata = {
823
+ 'docker'=>{
824
+ 'container_id'=>'49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459'
825
+ },
826
+ 'kubernetes' => {
827
+ 'host' => 'jimmi-redhat.localnet',
828
+ 'pod_name' => 'fabric8-console-controller-98rqc',
829
+ 'container_name' => 'fabric8-console-container',
830
+ 'container_image' => 'fabric8/hawtio-kubernetes:latest',
831
+ 'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
832
+ 'namespace_name' => 'default',
833
+ "namespace_id"=>"898268c8-4a36-11e5-9d81-42010af0194c",
834
+ 'namespace_labels' => {
835
+ 'tenant' => 'test'
836
+ },
837
+ 'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
838
+ 'pod_ip' => '172.17.0.8',
839
+ 'ownerrefs' => [{
840
+ 'kind' => 'ReplicaSet',
841
+ 'name' => 'fabric8-console-controller'
842
+ }]
843
+ }
844
+ }
845
+
846
+ assert_equal(expected_kube_metadata, filtered[0])
847
+ end
848
+ end
808
849
 
809
850
  end
810
851
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-kubernetes_metadata_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenShift Cluster Logging
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-08-14 00:00:00.000000000 Z
12
+ date: 2024-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: 0.14.0
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '1.17'
23
+ version: '1.18'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: 0.14.0
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.17'
33
+ version: '1.18'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: kubeclient
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -259,6 +259,7 @@ files:
259
259
  - test/cassettes/kubernetes_get_pod.yml
260
260
  - test/cassettes/kubernetes_get_pod_container_init.yml
261
261
  - test/cassettes/kubernetes_get_pod_using_token.yml
262
+ - test/cassettes/kubernetes_get_pod_with_ownerrefs.yml
262
263
  - test/cassettes/metadata_from_tag_and_journald_fields.yml
263
264
  - test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml
264
265
  - test/cassettes/valid_kubernetes_api_server.yml
@@ -283,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
283
284
  requirements:
284
285
  - - ">="
285
286
  - !ruby/object:Gem::Version
286
- version: 2.6.0
287
+ version: 2.7.0
287
288
  required_rubygems_version: !ruby/object:Gem::Requirement
288
289
  requirements:
289
290
  - - ">="