fluent-plugin-kubernetes_metadata_filter 0.32.0 → 0.33.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
  SHA1:
3
- metadata.gz: 989125c79b1bd4fa6f72d872f11d0fd439e18a0c
4
- data.tar.gz: 624665a54645b53019d3e328ec9a37f5c68472d2
3
+ metadata.gz: a5a3f2f0bcabc1a6f56b3edf41aa6ca50475eac2
4
+ data.tar.gz: d20a1f8f5e75366fffab4cb256540c8241afc2d7
5
5
  SHA512:
6
- metadata.gz: 37a5dac8e9f2b76f30c610d9636559e026820ba2ca75e2c8e4c640237c3b5e72c1cde67ca4692d5b19763362b1b56c5f63af0a4e664316c7f28401faf80ab28d
7
- data.tar.gz: 998b7939864d1ef76898511f5c8656d3f84695a2e804ca7fbb5738e5404dcbe5f74db22b44473e36fa26cdc41dfdc41d5d1c2c27f021cf0438473ee271fe8be8
6
+ metadata.gz: f9733a0745ac08b92ea4ec8b6af1c414bdab974608b66ffffe5478c2a7171a37cd91dcbf4bea309aa4000d1bb4516d7169e69d7906635a333342ea6ba622f582
7
+ data.tar.gz: 75e087d65d6a28039ae945d7fa11196aa93f337269dfa0c368fd07e8d35953f8abd1e1bbdb6d50b66c6a9669fa30818949471c766d06069ef1f7a59041efdeb1
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "fluent-plugin-kubernetes_metadata_filter"
7
- gem.version = "0.32.0"
7
+ gem.version = "0.33.0"
8
8
  gem.authors = ["Jimmi Dyson"]
9
9
  gem.email = ["jimmidyson@gmail.com"]
10
10
  gem.description = %q{Filter plugin to add Kubernetes metadata}
@@ -343,7 +343,6 @@ module Fluent
343
343
 
344
344
  es.each { |time, record|
345
345
  record = merge_json_log(record) if @merge_json_log
346
-
347
346
  metadata = nil
348
347
  if record.has_key?('CONTAINER_NAME') && record.has_key?('CONTAINER_ID_FULL')
349
348
  metadata = record['CONTAINER_NAME'].match(@container_name_to_kubernetes_regexp_compiled) do |match_data|
@@ -362,11 +361,11 @@ module Fluent
362
361
  end
363
362
  unless metadata
364
363
  log.debug "Error: could not match CONTAINER_NAME from record #{record}"
365
- @stats.dump(:container_name_match_failed)
364
+ @stats.bump(:container_name_match_failed)
366
365
  end
367
366
  elsif record.has_key?('CONTAINER_NAME') && record['CONTAINER_NAME'].start_with?('k8s_')
368
367
  log.debug "Error: no container name and id in record #{record}"
369
- @stats.dump(:container_name_id_missing)
368
+ @stats.bump(:container_name_id_missing)
370
369
  end
371
370
 
372
371
  if metadata
@@ -36,7 +36,7 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
36
36
 
37
37
  sub_test_case 'dump_stats' do
38
38
 
39
- test 'dump stats with indclude_namespace_metadata' do
39
+ test 'dump stats with include_namespace_metadata' do
40
40
  VCR.use_cassette('kubernetes_docker_metadata') do
41
41
  d = create_driver('
42
42
  kubernetes_url https://localhost:8443
@@ -672,6 +672,49 @@ use_journal true
672
672
  assert_equal(expected_kube_metadata, es.instance_variable_get(:@record_array)[0])
673
673
  end
674
674
  end
675
-
675
+ test 'with CONTAINER_NAME that does not match' do
676
+ tag = 'var.log.containers.junk4_junk5_junk6-49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed450.log'
677
+ msg = {
678
+ 'CONTAINER_NAME' => 'does_not_match',
679
+ 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459',
680
+ 'randomfield' => 'randomvalue'
681
+ }
682
+ VCR.use_cassette('kubernetes_docker_metadata_annotations') do
683
+ es = emit_with_tag(tag, msg, '
684
+ kubernetes_url https://localhost:8443
685
+ watch false
686
+ cache_size 1
687
+ use_journal true
688
+ ')
689
+ expected_kube_metadata = {
690
+ 'CONTAINER_NAME' => 'does_not_match',
691
+ 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459',
692
+ 'randomfield' => 'randomvalue'
693
+ }
694
+ assert_equal(expected_kube_metadata, es.instance_variable_get(:@record_array)[0])
695
+ end
696
+ end
697
+ test 'with CONTAINER_NAME starts with k8s_ that does not match' do
698
+ tag = 'var.log.containers.junk4_junk5_junk6-49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed450.log'
699
+ msg = {
700
+ 'CONTAINER_NAME' => 'k8s_doesnotmatch',
701
+ 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459',
702
+ 'randomfield' => 'randomvalue'
703
+ }
704
+ VCR.use_cassette('kubernetes_docker_metadata_annotations') do
705
+ es = emit_with_tag(tag, msg, '
706
+ kubernetes_url https://localhost:8443
707
+ watch false
708
+ cache_size 1
709
+ use_journal true
710
+ ')
711
+ expected_kube_metadata = {
712
+ 'CONTAINER_NAME' => 'k8s_doesnotmatch',
713
+ 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459',
714
+ 'randomfield' => 'randomvalue'
715
+ }
716
+ assert_equal(expected_kube_metadata, es.instance_variable_get(:@record_array)[0])
717
+ end
718
+ end
676
719
  end
677
720
  end
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: 0.32.0
4
+ version: 0.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmi Dyson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-10 00:00:00.000000000 Z
11
+ date: 2017-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd