fluent-plugin-kubernetes_metadata_filter 3.2.0 → 3.3.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: b386e5a9f06d9356809efffdf54c368b21a6cdda6a8b1687ce9e60b2352e38c7
4
- data.tar.gz: a9cd4f1169c0318ee418943614ba6c80fd8ae99837605d0597e4964ff3dc1dfb
3
+ metadata.gz: 1425638a4efbcc9ed55bee88eb1563ba071c6d7afc9ca0b9f556a4528bfb6f05
4
+ data.tar.gz: 531e074b6271d05fade448979dc11cd7d2d075bd2941587cb2341fd8e3f7076f
5
5
  SHA512:
6
- metadata.gz: 144b68bc69c03c9d4812b2ff6897dcc5b3f56152e396ff1b2d75217369bb5cf7c94882767b25793a84604e62f62dd98f212d79e03ca7c52942e21d03623b441f
7
- data.tar.gz: 2bddc63b3576adfe0a6d0052f8727b3b88635c47dec586f6e5fbaf9785b498564d67205b4c4b0247023ebfe50fa0efec0ad3de6dd6b803aff60a66ae7bdc56ff
6
+ metadata.gz: 78aca0f62942579b5c1be309857a920ee623ff71903e9d00cc6415b7b8dcc37e7a23d4be8baa024c54959963fb4c356a352e42229c08b7257bd65281bf987faf
7
+ data.tar.gz: 5dda7ace28a80bf02c28ac7f2dc016ad83f056e1d85c95bc6b599554d8ef9145dc4643c490776ce7deaf1f8e968caa720cf024a27236e45cd844cbd88538d661
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-kubernetes_metadata_filter (3.2.0)
4
+ fluent-plugin-kubernetes_metadata_filter (3.3.0)
5
5
  fluentd (>= 0.14.0, < 1.17)
6
6
  kubeclient (>= 4.0.0, < 5.0.0)
7
7
  lru_redux
@@ -17,7 +17,7 @@ GEM
17
17
  codeclimate-test-reporter (0.6.0)
18
18
  simplecov (>= 0.7.1, < 1.0.0)
19
19
  concurrent-ruby (1.2.2)
20
- cool.io (1.7.1)
20
+ cool.io (1.8.0)
21
21
  copyright-header (1.0.22)
22
22
  github-linguist
23
23
  crack (0.4.5)
@@ -30,13 +30,13 @@ GEM
30
30
  ffi-compiler (1.0.1)
31
31
  ffi (>= 1.0.0)
32
32
  rake
33
- fluentd (1.16.0)
33
+ fluentd (1.16.2)
34
34
  bundler
35
35
  cool.io (>= 1.4.5, < 2.0.0)
36
36
  http_parser.rb (>= 0.5.1, < 0.9.0)
37
37
  msgpack (>= 1.3.1, < 2.0.0)
38
38
  serverengine (>= 2.3.2, < 3.0.0)
39
- sigdump (~> 0.2.2)
39
+ sigdump (~> 0.2.5)
40
40
  strptime (>= 0.2.4, < 1.0.0)
41
41
  tzinfo (>= 1.0, < 3.0)
42
42
  tzinfo-data (~> 1.0)
@@ -58,7 +58,7 @@ GEM
58
58
  domain_name (~> 0.5)
59
59
  http-form_data (2.3.0)
60
60
  http_parser.rb (0.8.0)
61
- jsonpath (1.1.2)
61
+ jsonpath (1.1.3)
62
62
  multi_json
63
63
  kubeclient (4.11.0)
64
64
  http (>= 3.0, < 6.0)
@@ -69,12 +69,12 @@ GEM
69
69
  ffi-compiler (~> 1.0)
70
70
  rake (~> 13.0)
71
71
  lru_redux (1.1.0)
72
- mime-types (3.4.1)
72
+ mime-types (3.5.0)
73
73
  mime-types-data (~> 3.2015)
74
- mime-types-data (3.2023.0218.1)
74
+ mime-types-data (3.2023.0808)
75
75
  mini_mime (1.1.2)
76
76
  minitest (4.7.5)
77
- msgpack (1.7.0)
77
+ msgpack (1.7.2)
78
78
  multi_json (1.15.0)
79
79
  netrc (0.11.0)
80
80
  parallel (1.22.1)
@@ -108,7 +108,7 @@ GEM
108
108
  rugged (1.4.3)
109
109
  serverengine (2.3.2)
110
110
  sigdump (~> 0.2.2)
111
- sigdump (0.2.4)
111
+ sigdump (0.2.5)
112
112
  simplecov (0.21.2)
113
113
  docile (~> 1.1)
114
114
  simplecov-html (~> 0.11)
data/README.md CHANGED
@@ -55,6 +55,8 @@ when true (default: `true`)
55
55
  to trust the intermediate CA certs we do have, set this to `true` - this corresponds to
56
56
  the `openssl s_client -partial_chain` flag and `X509_V_FLAG_PARTIAL_CHAIN` (default: `false`)
57
57
  * `skip_labels` - Skip all label fields from the metadata.
58
+ * `skip_pod_labels` - Skip only pod label fields from the metadata.
59
+ * `skip_namespace_labels` - Skip only namespace label fields from the metadata.
58
60
  * `skip_container_metadata` - Skip some of the container data of the metadata. The metadata will not contain the container_image and container_image_id fields.
59
61
  * `skip_master_url` - Skip the master_url field from the metadata.
60
62
  * `skip_namespace_metadata` - Skip the namespace_id field from the metadata. The fetch_namespace_metadata function will be skipped. The plugin will be faster and cpu consumption will be less.
@@ -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.2.0'
8
+ gem.version = '3.3.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'
@@ -77,6 +77,8 @@ module Fluent::Plugin
77
77
  # the openssl s_client -partial_chain flag and X509_V_FLAG_PARTIAL_CHAIN
78
78
  config_param :ssl_partial_chain, :bool, default: false
79
79
  config_param :skip_labels, :bool, default: false
80
+ config_param :skip_pod_labels, :bool, default: false
81
+ config_param :skip_namespace_labels, :bool, default: false
80
82
  config_param :skip_container_metadata, :bool, default: false
81
83
  config_param :skip_master_url, :bool, default: false
82
84
  config_param :skip_namespace_metadata, :bool, default: false
@@ -198,7 +200,7 @@ module Fluent::Plugin
198
200
  @namespace_cache = LruRedux::TTL::ThreadSafeCache.new(@cache_size, @cache_ttl)
199
201
 
200
202
  @tag_to_kubernetes_name_regexp_compiled = Regexp.compile(@tag_to_kubernetes_name_regexp)
201
-
203
+
202
204
  # Use Kubernetes default service account if we're in a pod.
203
205
  if @kubernetes_url.nil?
204
206
  log.debug 'Kubernetes URL is not set - inspecting environ'
@@ -351,7 +353,7 @@ module Fluent::Plugin
351
353
  tag_match_data['pod_uuid']
352
354
  else
353
355
  tag_match_data['docker_id']
354
- end
356
+ end
355
357
  docker_id = tag_match_data.names.include?('docker_id') ? tag_match_data['docker_id'] : nil
356
358
  metadata = get_metadata_for_record(tag_match_data['namespace'], tag_match_data['pod_name'], tag_match_data['container_name'],
357
359
  cache_key, time, batch_miss_cache, docker_id)
@@ -40,7 +40,7 @@ module KubernetesMetadata
40
40
 
41
41
  def parse_namespace_metadata(namespace_object)
42
42
  labels = ''
43
- labels = syms_to_strs(namespace_object[:metadata][:labels].to_h) unless @skip_labels
43
+ labels = syms_to_strs(namespace_object[:metadata][:labels].to_h) unless (@skip_labels || @skip_namespace_labels)
44
44
 
45
45
  annotations = match_annotations(syms_to_strs(namespace_object[:metadata][:annotations].to_h))
46
46
 
@@ -55,7 +55,7 @@ module KubernetesMetadata
55
55
 
56
56
  def parse_pod_metadata(pod_object)
57
57
  labels = ''
58
- labels = syms_to_strs(pod_object[:metadata][:labels].to_h) unless @skip_labels
58
+ labels = syms_to_strs(pod_object[:metadata][:labels].to_h) unless (@skip_labels || @skip_pod_labels)
59
59
 
60
60
  annotations = match_annotations(syms_to_strs(pod_object[:metadata][:annotations].to_h))
61
61
 
@@ -53,7 +53,10 @@ http_interactions:
53
53
  "selfLink": "/api/v1/namespaces/default",
54
54
  "uid": "898268c8-4a36-11e5-9d81-42010af0194c",
55
55
  "resourceVersion": "6",
56
- "creationTimestamp": "2015-05-08T09:22:01Z"
56
+ "creationTimestamp": "2015-05-08T09:22:01Z",
57
+ "labels": {
58
+ "tenant": "test"
59
+ }
57
60
  },
58
61
  "spec": {
59
62
  "finalizers": [
@@ -49,7 +49,7 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
49
49
  d.instance.dump_stats
50
50
  assert_false(d.instance.instance_variable_get("@curr_time").nil?)
51
51
  end
52
-
52
+
53
53
  test 'disables stats when <= zero' do
54
54
  d = create_driver('stats_interval 0')
55
55
  assert_equal(0, d.instance.stats_interval)
@@ -199,6 +199,9 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
199
199
  'pod_name' => 'fabric8-console-controller-98rqc',
200
200
  'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
201
201
  'namespace_name' => 'default',
202
+ 'namespace_labels' => {
203
+ 'tenant' => 'test'
204
+ },
202
205
  'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
203
206
  'pod_ip' => '172.17.0.8',
204
207
  'master_url' => 'https://localhost:8443',
@@ -231,6 +234,9 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
231
234
  'pod_name' => 'fabric8-console-controller-98rqc',
232
235
  'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
233
236
  'namespace_name' => 'default',
237
+ 'namespace_labels' => {
238
+ 'tenant' => 'test'
239
+ },
234
240
  'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
235
241
  'pod_ip' => '172.17.0.8',
236
242
  'master_url' => 'https://localhost:8443',
@@ -330,6 +336,9 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
330
336
  'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
331
337
  'namespace_name' => 'default',
332
338
  'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
339
+ 'namespace_labels' => {
340
+ 'tenant' => 'test'
341
+ },
333
342
  'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
334
343
  'pod_ip' => '172.17.0.8',
335
344
  'master_url' => 'https://localhost:8443',
@@ -360,6 +369,9 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
360
369
  'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
361
370
  'namespace_name' => 'default',
362
371
  'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
372
+ 'namespace_labels' => {
373
+ 'tenant' => 'test'
374
+ },
363
375
  'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
364
376
  'pod_ip' => '172.17.0.8',
365
377
  'master_url' => 'https://localhost:8443',
@@ -410,6 +422,9 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
410
422
  'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
411
423
  'namespace_name' => 'default',
412
424
  'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
425
+ 'namespace_labels' => {
426
+ 'tenant' => 'test'
427
+ },
413
428
  'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
414
429
  'pod_ip' => '172.17.0.8',
415
430
  'master_url' => 'https://localhost:8443',
@@ -585,8 +600,8 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
585
600
  'host' => 'jimmi-redhat.localnet',
586
601
  'pod_name' => 'fabric8-console-controller-98rqc',
587
602
  'container_name' => 'fabric8-console-container',
588
- 'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
589
603
  'namespace_name' => 'default',
604
+ 'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
590
605
  'container_image' => 'fabric8/hawtio-kubernetes:latest',
591
606
  'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
592
607
  'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
@@ -628,8 +643,8 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
628
643
  'container_name' => 'fabric8-console-container',
629
644
  'container_image' => 'fabric8/hawtio-kubernetes:latest',
630
645
  'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
631
- 'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
632
646
  'namespace_name' => 'default',
647
+ 'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
633
648
  'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
634
649
  'pod_ip' => '172.17.0.8',
635
650
  'master_url' => 'https://localhost:8443',
@@ -643,7 +658,7 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
643
658
  end
644
659
 
645
660
  test 'processes all events when reading from MessagePackEventStream' do
646
- VCR.use_cassettes([{ name: 'valid_kubernetes_api_server' },
661
+ VCR.use_cassettes([{ name: 'valid_kubernetes_api_server' },
647
662
  { name: 'kubernetes_get_api_v1' },
648
663
  { name: 'kubernetes_get_pod' },
649
664
  { name: 'kubernetes_get_namespace_default' }]) do
@@ -675,6 +690,9 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
675
690
  'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
676
691
  'namespace_name' => 'default',
677
692
  'namespace_id' => '898268c8-4a36-11e5-9d81-42010af0194c',
693
+ 'namespace_labels' => {
694
+ 'tenant' => 'test'
695
+ },
678
696
  'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
679
697
  'pod_ip' => '172.17.0.8',
680
698
  'master_url' => 'https://localhost:8443',
@@ -718,5 +736,75 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
718
736
  assert_equal(expected_kube_metadata, filtered[0])
719
737
  end
720
738
  end
739
+
740
+ test 'with docker & kubernetes metadata using skip namespace labels config param' do
741
+ VCR.use_cassettes([{ name: 'valid_kubernetes_api_server' }, { name: 'kubernetes_get_api_v1' }, { name: 'kubernetes_get_pod' },
742
+ { name: 'kubernetes_get_namespace_default' }]) do
743
+ filtered = emit({}, '
744
+ kubernetes_url https://localhost:8443
745
+ watch false
746
+ cache_size 1
747
+ stats_interval 0
748
+ skip_namespace_labels true
749
+ skip_master_url true
750
+ ')
751
+ expected_kube_metadata = {
752
+ 'docker'=>{
753
+ 'container_id'=>'49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459'
754
+ },
755
+ 'kubernetes' => {
756
+ 'host' => 'jimmi-redhat.localnet',
757
+ 'pod_name' => 'fabric8-console-controller-98rqc',
758
+ 'container_name' => 'fabric8-console-container',
759
+ 'container_image' => 'fabric8/hawtio-kubernetes:latest',
760
+ 'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
761
+ 'namespace_name' => 'default',
762
+ "namespace_id"=>"898268c8-4a36-11e5-9d81-42010af0194c",
763
+ 'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
764
+ 'pod_ip' => '172.17.0.8',
765
+ 'labels' => {
766
+ 'component' => 'fabric8Console'
767
+ }
768
+ }
769
+ }
770
+
771
+ assert_equal(expected_kube_metadata, filtered[0])
772
+ end
773
+ end
774
+ test 'with docker & kubernetes metadata using skip pod labels config param' do
775
+ VCR.use_cassettes([{ name: 'valid_kubernetes_api_server' }, { name: 'kubernetes_get_api_v1' }, { name: 'kubernetes_get_pod' },
776
+ { name: 'kubernetes_get_namespace_default' }]) do
777
+ filtered = emit({}, '
778
+ kubernetes_url https://localhost:8443
779
+ watch false
780
+ cache_size 1
781
+ stats_interval 0
782
+ skip_pod_labels true
783
+ skip_master_url true
784
+ ')
785
+ expected_kube_metadata = {
786
+ 'docker'=>{
787
+ 'container_id'=>'49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459'
788
+ },
789
+ 'kubernetes' => {
790
+ 'host' => 'jimmi-redhat.localnet',
791
+ 'pod_name' => 'fabric8-console-controller-98rqc',
792
+ 'container_name' => 'fabric8-console-container',
793
+ 'container_image' => 'fabric8/hawtio-kubernetes:latest',
794
+ 'container_image_id' => 'docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303',
795
+ 'namespace_name' => 'default',
796
+ "namespace_id"=>"898268c8-4a36-11e5-9d81-42010af0194c",
797
+ 'namespace_labels' => {
798
+ 'tenant' => 'test'
799
+ },
800
+ 'pod_id' => 'c76927af-f563-11e4-b32d-54ee7527188d',
801
+ 'pod_ip' => '172.17.0.8',
802
+ }
803
+ }
804
+
805
+ assert_equal(expected_kube_metadata, filtered[0])
806
+ end
807
+ end
808
+
721
809
  end
722
810
  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.2.0
4
+ version: 3.3.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-04-13 00:00:00.000000000 Z
12
+ date: 2023-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd