fluent-plugin-kubernetes_metadata_filter 2.5.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +10 -14
  3. data/.gitignore +0 -1
  4. data/.rubocop.yml +57 -0
  5. data/Gemfile +4 -2
  6. data/Gemfile.lock +76 -67
  7. data/README.md +9 -83
  8. data/Rakefile +15 -11
  9. data/doc/benchmark/5m-1-2500lps-256b-baseline-01/cpu.png +0 -0
  10. data/doc/benchmark/5m-1-2500lps-256b-baseline-01/latency.png +0 -0
  11. data/doc/benchmark/5m-1-2500lps-256b-baseline-01/loss.png +0 -0
  12. data/doc/benchmark/5m-1-2500lps-256b-baseline-01/mem.png +0 -0
  13. data/doc/benchmark/5m-1-2500lps-256b-baseline-01/readme.md +88 -0
  14. data/doc/benchmark/5m-1-2500lps-256b-baseline-01/results.html +127 -0
  15. data/doc/benchmark/5m-1-2500lps-256b-kube-01-01/cpu.png +0 -0
  16. data/doc/benchmark/5m-1-2500lps-256b-kube-01-01/latency.png +0 -0
  17. data/doc/benchmark/5m-1-2500lps-256b-kube-01-01/loss.png +0 -0
  18. data/doc/benchmark/5m-1-2500lps-256b-kube-01-01/mem.png +0 -0
  19. data/doc/benchmark/5m-1-2500lps-256b-kube-01-01/readme.md +97 -0
  20. data/doc/benchmark/5m-1-2500lps-256b-kube-01-01/results.html +136 -0
  21. data/doc/benchmark/5m-1-2500lps-256b-kube-01-marshal-02/cpu.png +0 -0
  22. data/doc/benchmark/5m-1-2500lps-256b-kube-01-marshal-02/latency.png +0 -0
  23. data/doc/benchmark/5m-1-2500lps-256b-kube-01-marshal-02/loss.png +0 -0
  24. data/doc/benchmark/5m-1-2500lps-256b-kube-01-marshal-02/mem.png +0 -0
  25. data/doc/benchmark/5m-1-2500lps-256b-kube-01-marshal-02/readme.md +97 -0
  26. data/doc/benchmark/5m-1-2500lps-256b-kube-01-marshal-02/results.html +136 -0
  27. data/fluent-plugin-kubernetes_metadata_filter.gemspec +25 -27
  28. data/lib/fluent/plugin/filter_kubernetes_metadata.rb +171 -192
  29. data/lib/fluent/plugin/kubernetes_metadata_cache_strategy.rb +25 -23
  30. data/lib/fluent/plugin/kubernetes_metadata_common.rb +44 -69
  31. data/lib/fluent/plugin/kubernetes_metadata_stats.rb +21 -5
  32. data/lib/fluent/plugin/kubernetes_metadata_test_api_adapter.rb +68 -0
  33. data/lib/fluent/plugin/kubernetes_metadata_util.rb +33 -0
  34. data/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb +91 -42
  35. data/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb +108 -47
  36. data/release_notes.md +42 -0
  37. data/test/cassettes/kubernetes_get_pod_container_init.yml +145 -0
  38. data/test/helper.rb +20 -2
  39. data/test/plugin/test_cache_stats.rb +10 -13
  40. data/test/plugin/test_cache_strategy.rb +158 -160
  41. data/test/plugin/test_filter_kubernetes_metadata.rb +340 -616
  42. data/test/plugin/test_watch_namespaces.rb +188 -125
  43. data/test/plugin/test_watch_pods.rb +282 -202
  44. data/test/plugin/watch_test.rb +16 -15
  45. metadata +77 -67
  46. /data/test/cassettes/{kubernetes_docker_metadata_dotted_labels.yml → kubernetes_docker_metadata_dotted_slashed_labels.yml} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1991a6b8cd09f65728588401e697dda36954b94cf75b625789c6e7773d50ccf
4
- data.tar.gz: df46f28a113c17aa3e2174d3ad23edb0b5b93fb6d65d5f02787d6ac83ac129a2
3
+ metadata.gz: b386e5a9f06d9356809efffdf54c368b21a6cdda6a8b1687ce9e60b2352e38c7
4
+ data.tar.gz: a9cd4f1169c0318ee418943614ba6c80fd8ae99837605d0597e4964ff3dc1dfb
5
5
  SHA512:
6
- metadata.gz: 1a41d498af8a2e92723c05679608294d07acf2cf7a87dfdf5921fe3a385df6369003eef939dd5aeabf970c67f31eb319ac1485d566ac110bcbe6b79f5acc392a
7
- data.tar.gz: e62c355dbdb0ac1e89e43534c5929c80e82b166f5c614b1967d6ff79658835881a9c6803d5072e85a41c83fbefc8db326ba95c6d2f1c5a20ca1b8a0f18ce3cf1
6
+ metadata.gz: 144b68bc69c03c9d4812b2ff6897dcc5b3f56152e396ff1b2d75217369bb5cf7c94882767b25793a84604e62f62dd98f212d79e03ca7c52942e21d03623b441f
7
+ data.tar.gz: 2bddc63b3576adfe0a6d0052f8727b3b88635c47dec586f6e5fbaf9785b498564d67205b4c4b0247023ebfe50fa0efec0ad3de6dd6b803aff60a66ae7bdc56ff
data/.circleci/config.yml CHANGED
@@ -4,7 +4,8 @@ install: &install
4
4
  name: Install bundle
5
5
  command: |
6
6
  gem install bundler
7
- bundle install --path vendor/bundle
7
+ bundle config set --local path vendor/bundle
8
+ bundle install
8
9
 
9
10
  missingdeps: &missingdeps
10
11
  name: Install missing dependecies
@@ -12,23 +13,20 @@ missingdeps: &missingdeps
12
13
  cat /etc/os-release
13
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
15
  sudo cp /tmp/sources.list /etc/apt/sources.list
15
- sudo apt-get update
16
+ sudo apt-get --allow-releaseinfo-change update
16
17
  sudo apt-get install cmake libicu-dev libssl-dev
17
-
18
+
18
19
  test: &test
19
20
  name: Test bundle
20
- command: bundle exec rake test
21
+ command: bundle exec rake test --trace
21
22
 
22
23
  executors:
23
- ruby-2-4:
24
- docker:
25
- - image: circleci/ruby:2.4.6
26
- ruby-2-5:
27
- docker:
28
- - image: circleci/ruby:2.5.5
29
24
  ruby-2-6:
30
25
  docker:
31
26
  - image: circleci/ruby:2.6.3
27
+ ruby-2-7:
28
+ docker:
29
+ - image: circleci/ruby:2.7.1
32
30
  jobs:
33
31
  "ruby-test":
34
32
  parameters:
@@ -49,9 +47,7 @@ jobs:
49
47
  workflows:
50
48
  "test_multiple_ruby_versions":
51
49
  jobs:
52
- - ruby-test:
53
- ruby-version: ruby-2-4
54
- - ruby-test:
55
- ruby-version: ruby-2-5
56
50
  - ruby-test:
57
51
  ruby-version: ruby-2-6
52
+ - ruby-test:
53
+ ruby-version: ruby-2-7
data/.gitignore CHANGED
@@ -7,7 +7,6 @@ vendor/
7
7
  InstalledFiles
8
8
  _yardoc
9
9
  coverage
10
- doc/
11
10
  lib/bundler/man
12
11
  pkg
13
12
  rdoc
data/.rubocop.yml ADDED
@@ -0,0 +1,57 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5 # keep in sync with .circleci/config.yml and gemspec
3
+ NewCops: enable
4
+
5
+ Style/EmptyMethod:
6
+ Enabled: false
7
+
8
+ Metrics:
9
+ Enabled: false
10
+
11
+ # not safe ... needs require 'English'
12
+ Style/SpecialGlobalVars:
13
+ Enabled: false
14
+
15
+ Layout/LineLength:
16
+ Max: 205 # TODO: lower
17
+
18
+ Style/Documentation:
19
+ Enabled: false
20
+
21
+ Naming/AccessorMethodName:
22
+ Enabled: false
23
+
24
+ Naming/MethodParameterName:
25
+ Enabled: false
26
+
27
+ Style/IfInsideElse:
28
+ Enabled: false
29
+
30
+ Style/GuardClause:
31
+ Enabled: false
32
+
33
+ Lint/NestedMethodDefinition:
34
+ Enabled: false
35
+
36
+ # TODO: fix
37
+ Style/StringConcatenation:
38
+ Enabled: false
39
+
40
+ Style/NumericPredicate:
41
+ EnforcedStyle: comparison
42
+
43
+ Style/IfUnlessModifier:
44
+ Enabled: false
45
+
46
+ Style/ClassAndModuleChildren:
47
+ Enabled: false
48
+
49
+ # TODO: enable ... somehow breaks tests
50
+ Style/HashEachMethods:
51
+ Enabled: false
52
+
53
+ Style/WordArray:
54
+ EnforcedStyle: brackets
55
+
56
+ Style/SymbolArray:
57
+ EnforcedStyle: brackets
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
- gem 'codeclimate-test-reporter', '<1.0.0', :group => :test, :require => nil
4
- gem 'rubocop', require: false
5
+ gem 'codeclimate-test-reporter', '<1.0.0', group: :test, require: nil
6
+ gem 'rubocop'
5
7
 
6
8
  # Specify your gem's dependencies in fluent-plugin-add.gemspec
7
9
  gemspec
data/Gemfile.lock CHANGED
@@ -1,132 +1,141 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-kubernetes_metadata_filter (2.5.0)
5
- fluentd (>= 0.14.0, < 1.12)
6
- kubeclient (< 5)
4
+ fluent-plugin-kubernetes_metadata_filter (3.2.0)
5
+ fluentd (>= 0.14.0, < 1.17)
6
+ kubeclient (>= 4.0.0, < 5.0.0)
7
7
  lru_redux
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.7.0)
12
+ addressable (2.8.0)
13
13
  public_suffix (>= 2.0.2, < 5.0)
14
- ast (2.4.1)
15
- bump (0.9.0)
14
+ ast (2.4.2)
15
+ bump (0.10.0)
16
16
  charlock_holmes (0.7.7)
17
17
  codeclimate-test-reporter (0.6.0)
18
18
  simplecov (>= 0.7.1, < 1.0.0)
19
- concurrent-ruby (1.1.6)
20
- cool.io (1.6.0)
19
+ concurrent-ruby (1.2.2)
20
+ cool.io (1.7.1)
21
21
  copyright-header (1.0.22)
22
22
  github-linguist
23
- crack (0.4.3)
24
- safe_yaml (~> 1.0.0)
25
- docile (1.3.2)
23
+ crack (0.4.5)
24
+ rexml
25
+ docile (1.4.0)
26
26
  domain_name (0.5.20190701)
27
27
  unf (>= 0.0.5, < 1.0.0)
28
- escape_utils (1.2.1)
29
- ffi (1.13.1)
28
+ escape_utils (1.2.2)
29
+ ffi (1.15.5)
30
30
  ffi-compiler (1.0.1)
31
31
  ffi (>= 1.0.0)
32
32
  rake
33
- fluentd (1.11.1)
33
+ fluentd (1.16.0)
34
+ bundler
34
35
  cool.io (>= 1.4.5, < 2.0.0)
35
- http_parser.rb (>= 0.5.1, < 0.7.0)
36
+ http_parser.rb (>= 0.5.1, < 0.9.0)
36
37
  msgpack (>= 1.3.1, < 2.0.0)
37
- serverengine (>= 2.0.4, < 3.0.0)
38
+ serverengine (>= 2.3.2, < 3.0.0)
38
39
  sigdump (~> 0.2.2)
39
- strptime (>= 0.2.2, < 1.0.0)
40
+ strptime (>= 0.2.4, < 1.0.0)
40
41
  tzinfo (>= 1.0, < 3.0)
41
42
  tzinfo-data (~> 1.0)
43
+ webrick (~> 1.4)
42
44
  yajl-ruby (~> 1.0)
43
- github-linguist (7.9.0)
44
- charlock_holmes (~> 0.7.6)
45
+ github-linguist (7.21.0)
46
+ charlock_holmes (~> 0.7.7)
45
47
  escape_utils (~> 1.2.0)
46
48
  mini_mime (~> 1.0)
47
- rugged (>= 0.25.1)
49
+ rugged (~> 1.0)
48
50
  hashdiff (1.0.1)
49
- http (4.4.1)
50
- addressable (~> 2.3)
51
+ http (5.1.1)
52
+ addressable (~> 2.8)
51
53
  http-cookie (~> 1.0)
52
54
  http-form_data (~> 2.2)
53
- http-parser (~> 1.2.0)
55
+ llhttp-ffi (~> 0.4.0)
54
56
  http-accept (1.7.0)
55
- http-cookie (1.0.3)
57
+ http-cookie (1.0.5)
56
58
  domain_name (~> 0.5)
57
59
  http-form_data (2.3.0)
58
- http-parser (1.2.1)
59
- ffi-compiler (>= 1.0, < 2.0)
60
- http_parser.rb (0.6.0)
61
- kubeclient (4.7.0)
62
- http (>= 3.0, < 5.0)
60
+ http_parser.rb (0.8.0)
61
+ jsonpath (1.1.2)
62
+ multi_json
63
+ kubeclient (4.11.0)
64
+ http (>= 3.0, < 6.0)
65
+ jsonpath (~> 1.0)
63
66
  recursive-open-struct (~> 1.1, >= 1.1.1)
64
67
  rest-client (~> 2.0)
68
+ llhttp-ffi (0.4.0)
69
+ ffi-compiler (~> 1.0)
70
+ rake (~> 13.0)
65
71
  lru_redux (1.1.0)
66
- mime-types (3.3.1)
72
+ mime-types (3.4.1)
67
73
  mime-types-data (~> 3.2015)
68
- mime-types-data (3.2020.0512)
69
- mini_mime (1.0.2)
74
+ mime-types-data (3.2023.0218.1)
75
+ mini_mime (1.1.2)
70
76
  minitest (4.7.5)
71
- msgpack (1.3.3)
77
+ msgpack (1.7.0)
78
+ multi_json (1.15.0)
72
79
  netrc (0.11.0)
73
- parallel (1.19.2)
74
- parser (2.7.1.4)
80
+ parallel (1.22.1)
81
+ parser (3.1.2.0)
75
82
  ast (~> 2.4.1)
76
- power_assert (1.2.0)
77
- public_suffix (4.0.5)
78
- rainbow (3.0.0)
79
- rake (13.0.1)
80
- recursive-open-struct (1.1.2)
81
- regexp_parser (1.7.1)
83
+ power_assert (2.0.2)
84
+ public_suffix (4.0.7)
85
+ rainbow (3.1.1)
86
+ rake (13.0.6)
87
+ recursive-open-struct (1.1.3)
88
+ regexp_parser (2.5.0)
82
89
  rest-client (2.1.0)
83
90
  http-accept (>= 1.7.0, < 2.0)
84
91
  http-cookie (>= 1.0.2, < 2.0)
85
92
  mime-types (>= 1.16, < 4.0)
86
93
  netrc (~> 0.8)
87
- rexml (3.2.4)
88
- rr (1.2.1)
89
- rubocop (0.86.0)
94
+ rexml (3.2.5)
95
+ rr (3.0.9)
96
+ rubocop (1.28.2)
90
97
  parallel (~> 1.10)
91
- parser (>= 2.7.0.1)
98
+ parser (>= 3.1.0.0)
92
99
  rainbow (>= 2.2.2, < 4.0)
93
- regexp_parser (>= 1.7)
100
+ regexp_parser (>= 1.8, < 3.0)
94
101
  rexml
95
- rubocop-ast (>= 0.0.3, < 1.0)
102
+ rubocop-ast (>= 1.17.0, < 2.0)
96
103
  ruby-progressbar (~> 1.7)
97
- unicode-display_width (>= 1.4.0, < 2.0)
98
- rubocop-ast (0.1.0)
99
- parser (>= 2.7.0.1)
100
- ruby-progressbar (1.10.1)
101
- rugged (1.0.1)
102
- safe_yaml (1.0.5)
103
- serverengine (2.2.1)
104
+ unicode-display_width (>= 1.4.0, < 3.0)
105
+ rubocop-ast (1.17.0)
106
+ parser (>= 3.1.1.0)
107
+ ruby-progressbar (1.11.0)
108
+ rugged (1.4.3)
109
+ serverengine (2.3.2)
104
110
  sigdump (~> 0.2.2)
105
111
  sigdump (0.2.4)
106
- simplecov (0.18.5)
112
+ simplecov (0.21.2)
107
113
  docile (~> 1.1)
108
114
  simplecov-html (~> 0.11)
109
- simplecov-html (0.12.2)
110
- strptime (0.2.4)
111
- test-unit (3.0.9)
115
+ simplecov_json_formatter (~> 0.1)
116
+ simplecov-html (0.12.3)
117
+ simplecov_json_formatter (0.1.4)
118
+ strptime (0.2.5)
119
+ test-unit (3.5.5)
112
120
  power_assert
113
121
  test-unit-rr (1.0.5)
114
122
  rr (>= 1.1.1)
115
123
  test-unit (>= 2.5.2)
116
- tzinfo (2.0.2)
124
+ tzinfo (2.0.6)
117
125
  concurrent-ruby (~> 1.0)
118
- tzinfo-data (1.2020.1)
126
+ tzinfo-data (1.2023.3)
119
127
  tzinfo (>= 1.0.0)
120
128
  unf (0.1.4)
121
129
  unf_ext
122
- unf_ext (0.0.7.7)
123
- unicode-display_width (1.7.0)
130
+ unf_ext (0.0.8.2)
131
+ unicode-display_width (2.2.0)
124
132
  vcr (6.0.0)
125
- webmock (3.8.3)
126
- addressable (>= 2.3.6)
133
+ webmock (3.14.0)
134
+ addressable (>= 2.8.0)
127
135
  crack (>= 0.3.2)
128
136
  hashdiff (>= 0.4.0, < 2.0.0)
129
- yajl-ruby (1.4.1)
137
+ webrick (1.8.1)
138
+ yajl-ruby (1.4.3)
130
139
 
131
140
  PLATFORMS
132
141
  ruby
@@ -140,11 +149,11 @@ DEPENDENCIES
140
149
  minitest (~> 4.0)
141
150
  rake
142
151
  rubocop
143
- test-unit (~> 3.0.2)
152
+ test-unit (~> 3.5.5)
144
153
  test-unit-rr (~> 1.0.3)
145
154
  vcr
146
155
  webmock
147
156
  yajl-ruby
148
157
 
149
158
  BUNDLED WITH
150
- 2.1.4
159
+ 2.3.16
data/README.md CHANGED
@@ -2,11 +2,12 @@
2
2
  [![Circle CI](https://circleci.com/gh/fabric8io/fluent-plugin-kubernetes_metadata_filter.svg?style=svg)](https://circleci.com/gh/fabric8io/fluent-plugin-kubernetes_metadata_filter)
3
3
  [![Code Climate](https://codeclimate.com/github/fabric8io/fluent-plugin-kubernetes_metadata_filter/badges/gpa.svg)](https://codeclimate.com/github/fabric8io/fluent-plugin-kubernetes_metadata_filter)
4
4
  [![Test Coverage](https://codeclimate.com/github/fabric8io/fluent-plugin-kubernetes_metadata_filter/badges/coverage.svg)](https://codeclimate.com/github/fabric8io/fluent-plugin-kubernetes_metadata_filter)
5
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
6
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
5
7
 
6
8
  The Kubernetes metadata plugin filter enriches container log records with pod and namespace metadata.
7
9
 
8
- This plugin derives basic metadata about the container that emitted a given log record using the source of the log record. Records from journald provide metadata about the
9
- container environment as named fields. Records from JSON files encode metadata about the container in the file name. The initial metadata derived from the source is used
10
+ This plugin derives basic metadata about the container that emitted a given log record using the source of the log record. Records from kubernetes containers encode metadata about the container in the file name. The initial metadata derived from the source is used
10
11
  to lookup additional metadata about the container's associated pod and namespace (e.g. UUIDs, labels, annotations) when the kubernetes_url is configured. If the plugin cannot
11
12
  authoritatively determine the namespace of the container emitting a log record, it will use an 'orphan' namespace ID in the metadata. This behaviors supports multi-tenant systems
12
13
  that rely on the authenticity of the namespace for proper log isolation.
@@ -15,6 +16,7 @@ that rely on the authenticity of the namespace for proper log isolation.
15
16
 
16
17
  | fluent-plugin-kubernetes_metadata_filter | fluentd | ruby |
17
18
  |-------------------|---------|------|
19
+ | >= 2.10.0 | >= v1.10.0 | >= 2.6 |
18
20
  | >= 2.5.0 | >= v1.10.0 | >= 2.5 |
19
21
  | >= 2.0.0 | >= v0.14.20 | >= 2.1 |
20
22
  | < 2.0.0 | >= v0.12.0 | >= 1.9 |
@@ -39,16 +41,10 @@ Configuration options for fluent.conf are:
39
41
  * `client_key` - path to a client key file to authenticate to the API server
40
42
  * `bearer_token_file` - path to a file containing the bearer token to use for authentication
41
43
  * `tag_to_kubernetes_name_regexp` - the regular expression used to extract kubernetes metadata (pod name, container name, namespace) from the current fluentd tag.
42
- This must used named capture groups for `container_name`, `pod_name` & `namespace` (default: `\.(?<pod_name>[^\._]+)_(?<namespace>[^_]+)_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\.log$</pod>)`)
44
+ This must use named capture groups for `container_name`, `pod_name`, `namespace`, and either `pod_uuid (/var/log/pods)` or `docker_id (/var/log/containers)`
43
45
  * `cache_size` - size of the cache of Kubernetes metadata to reduce requests to the API server (default: `1000`)
44
46
  * `cache_ttl` - TTL in seconds of each cached element. Set to negative value to disable TTL eviction (default: `3600` - 1 hour)
45
47
  * `watch` - set up a watch on pods on the API server for updates to metadata (default: `true`)
46
- * `de_dot` - replace dots in labels and annotations with configured `de_dot_separator`, required for ElasticSearch 2.x compatibility (default: `true`)
47
- * `de_dot_separator` - separator to use if `de_dot` is enabled (default: `_`)
48
- * *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
49
- if available, otherwise, will use the tag in the `tag_to_kubernetes_name_regexp` format.
50
- * `container_name_to_kubernetes_regexp` - The regular expression used to extract the k8s metadata encoded in the journal `CONTAINER_NAME` field (default: `'^(?<name_prefix>[^_]+)_(?<container_name>[^\._]+)(\.(?<container_hash>[^_]+))?_(?<pod_name>[^_]+)_(?<namespace>[^_]+)_[^_]+_[^_]+$'`
51
- * This corresponds to the definition [in the source](https://github.com/kubernetes/kubernetes/blob/release-1.6/pkg/kubelet/dockertools/docker.go#L317)
52
48
  * `annotation_match` - Array of regular expressions matching annotation field names. Matched annotations are added to a log record.
53
49
  * `allow_orphans` - Modify the namespace and namespace id to the values of `orphaned_namespace_name` and `orphaned_namespace_id`
54
50
  when true (default: `true`)
@@ -62,27 +58,13 @@ when true (default: `true`)
62
58
  * `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.
63
59
  * `skip_master_url` - Skip the master_url field from the metadata.
64
60
  * `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.
61
+ * `stats_interval` - The interval to display cache stats (default: 30s). Set to 0 to disable stats collection and logging
65
62
  * `watch_retry_interval` - The time interval in seconds for retry backoffs when watch connections fail. (default: `10`)
63
+ * `open_timeout` - The time in seconds to wait for a connection to kubernetes service. (default: `3`)
64
+ * `read_timeout` - The time in seconds to wait for a read from kubernetes service. (default: `10`)
66
65
 
67
- **NOTE:** As of the release 2.1.x of this plugin, it no longer supports parsing the source message into JSON and attaching it to the
68
- payload. The following configuration options are removed:
69
66
 
70
- * `merge_json_log`
71
- * `preserve_json_log`
72
-
73
- One way of preserving JSON logs can be through the [parser plugin](https://docs.fluentd.org/filter/parser)
74
-
75
- **NOTE** As of this release, the use of `use_journal` is **DEPRECATED**. If this setting is not present, the plugin will
76
- attempt to figure out the source of the metadata fields from the following:
77
- - If `lookup_from_k8s_field true` (the default) and the following fields are present in the record:
78
- `docker.container_id`, `kubernetes.namespace_name`, `kubernetes.pod_name`, `kubernetes.container_name`,
79
- then the plugin will use those values as the source to use to lookup the metadata
80
- - If `use_journal true`, or `use_journal` is unset, and the fields `CONTAINER_NAME` and `CONTAINER_ID_FULL` are present in the record,
81
- then the plugin will parse those values using `container_name_to_kubernetes_regexp` and use those as the source to lookup the metadata
82
- - Otherwise, if the tag matches `tag_to_kubernetes_name_regexp`, the plugin will parse the tag and use those values to
83
- lookup the metdata
84
-
85
- Reading from the 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":
67
+ 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":
86
68
 
87
69
  ```
88
70
  fluent-gem install fluent-plugin-multi-format-parser
@@ -123,50 +105,6 @@ The config block could look like this:
123
105
  </match>
124
106
  ```
125
107
 
126
- Reading from the systemd journal (requires the fluentd `fluent-plugin-systemd` and `systemd-journal` plugins, and requires docker to use the `--log-driver=journald` log driver):
127
- ```
128
- <source>
129
- @type systemd
130
- path /run/log/journal
131
- pos_file journal.pos
132
- tag journal
133
- read_from_head true
134
- </source>
135
-
136
- # probably want to use something like fluent-plugin-rewrite-tag-filter to
137
- # retag entries from k8s
138
- <match journal>
139
- @type rewrite_tag_filter
140
- rewriterule1 CONTAINER_NAME ^k8s_ kubernetes.journal.container
141
- ...
142
- </match>
143
-
144
- <filter kubernetes.**>
145
- @type kubernetes_metadata
146
- use_journal true
147
- </filter>
148
-
149
- <match **>
150
- @type stdout
151
- </match>
152
- ```
153
- ## Log content as JSON
154
- In former versions this plugin parsed the value of the key log as JSON. In the current version this feature was removed, to avoid duplicate features in the fluentd plugin ecosystem. It can parsed with the parser plugin like this:
155
- ```
156
- <filter kubernetes.**>
157
- @type parser
158
- key_name log
159
- <parse>
160
- @type json
161
- json_parser json
162
- </parse>
163
- replace_invalid_sequence true
164
- reserve_data true # this preserves unparsable log lines
165
- emit_invalid_record_to_error false # In case of unparsable log lines keep the error log clean
166
- reserve_time # the time was already parsed in the source, we don't want to overwrite it with current time.
167
- </filter>
168
- ```
169
-
170
108
  ## Environment variables for Kubernetes
171
109
 
172
110
  If the name of the Kubernetes node the plugin is running on is set as
@@ -226,18 +164,6 @@ Then output becomes as belows
226
164
  }
227
165
  ```
228
166
 
229
- If using journal input, from docker configured with `--log-driver=journald`, the input looks like the `journalctl -o export` format:
230
- ```
231
- # The stream identification is encoded into the PRIORITY field as an
232
- # integer: 6, or github.com/coreos/go-systemd/journal.Info, marks stdout,
233
- # while 3, or github.com/coreos/go-systemd/journal.Err, marks stderr.
234
- PRIORITY=6
235
- CONTAINER_ID=b6cbb6e73c0a
236
- CONTAINER_ID_FULL=b6cbb6e73c0ad63ab820e4baa97cdc77cec729930e38a714826764ac0491341a
237
- CONTAINER_NAME=k8s_registry.a49f5318_docker-registry-1-hhoj0_default_ae3a9bdc-1f66-11e6-80a2-fa163e2fff3a_799e4035
238
- MESSAGE=172.17.0.1 - - [21/May/2016:16:52:05 +0000] "GET /healthz HTTP/1.1" 200 0 "" "Go-http-client/1.1"
239
- ```
240
-
241
167
  ## Contributing
242
168
 
243
169
  1. Fork it
data/Rakefile CHANGED
@@ -1,10 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
1
4
  require 'bundler/gem_tasks'
2
5
  require 'rake/testtask'
3
6
  require 'bump/tasks'
7
+ require 'rubocop/rake_task'
4
8
 
5
- task :test => [:base_test]
9
+ task test: [:base_test]
10
+ task default: [:test, :build, :rubocop]
6
11
 
7
- task :default => [:test, :build]
12
+ RuboCop::RakeTask.new
8
13
 
9
14
  desc 'Run test_unit based test'
10
15
  Rake::TestTask.new(:base_test) do |t|
@@ -13,7 +18,6 @@ Rake::TestTask.new(:base_test) do |t|
13
18
  # $ bundle exec rake base_test TEST=test/test_*.rb
14
19
  t.libs << 'test'
15
20
  t.test_files = Dir['test/**/test_*.rb'].sort
16
- #t.verbose = true
17
21
  t.warning = false
18
22
  end
19
23
 
@@ -23,15 +27,15 @@ task :headers do
23
27
  require 'copyright_header'
24
28
 
25
29
  args = {
26
- :license => 'Apache-2.0',
27
- :copyright_software => 'Fluentd Kubernetes Metadata Filter Plugin',
28
- :copyright_software_description => 'Enrich Fluentd events with Kubernetes metadata',
29
- :copyright_holders => ['Red Hat, Inc.'],
30
- :copyright_years => ['2015-2017'],
31
- :add_path => 'lib:test',
32
- :output_dir => '.'
30
+ license: 'Apache-2.0',
31
+ copyright_software: 'Fluentd Kubernetes Metadata Filter Plugin',
32
+ copyright_software_description: 'Enrich Fluentd events with Kubernetes metadata',
33
+ copyright_holders: ['Red Hat, Inc.'],
34
+ copyright_years: ['2015-2021'],
35
+ add_path: 'lib:test',
36
+ output_dir: '.'
33
37
  }
34
38
 
35
- command_line = CopyrightHeader::CommandLine.new( args )
39
+ command_line = CopyrightHeader::CommandLine.new(args)
36
40
  command_line.execute
37
41
  end
@@ -0,0 +1,88 @@
1
+
2
+ # collector Functionl Benchmark Results
3
+ ## Options
4
+ * Image: quay.io/openshift-logging/fluentd:1.14.6
5
+ * Total Log Stressors: 1
6
+ * Lines Per Second: 2500
7
+ * Run Duration: 5m
8
+ * Payload Source: synthetic
9
+
10
+ ## Latency of logs collected based on the time the log was generated and ingested
11
+
12
+ Total Msg| Size | Elapsed (s) | Mean (s)| Min(s) | Max (s)| Median (s)
13
+ ---------|------|-------------|---------|--------|--------|---
14
+ 705733|256|5m0s|16.929|1.826|36.399|14.956
15
+
16
+ ![](cpu.png)
17
+
18
+ ![](mem.png)
19
+
20
+ ![](latency.png)
21
+
22
+ ![](loss.png)
23
+
24
+ ## Percent logs lost between first and last collected sequence ids
25
+ Stream | Min Seq | Max Seq | Purged | Collected | Percent Collected |
26
+ -------| ---------| --------| -------|-----------|--------------|
27
+ | functional.0.0000000000000000DBCED7977B8F643F|0|716850|0|705733|98.4%
28
+
29
+
30
+ ## Config
31
+
32
+ ```
33
+
34
+ <system>
35
+ log_level debug
36
+ </system>
37
+
38
+ <source>
39
+ @type tail
40
+ @id container-input
41
+ path /var/log/pods/testhack-clwn63sc_*/loader-*/*
42
+ exclude_path ["/var/log/pods/**/*/*.gz","/var/log/pods/**/*/*.tmp"]
43
+ pos_file "/var/lib/fluentd/pos/containers-app"
44
+ refresh_interval 5
45
+ rotate_wait 5
46
+ tag kubernetes.*
47
+ read_from_head "true"
48
+ <parse>
49
+ @type regexp
50
+ expression /^(?<@timestamp>[^\s]+) (?<stream>stdout|stderr) (?<logtag>[F|P]) (?<message>.*)$/
51
+ time_format '%Y-%m-%dT%H:%M:%S.%N%:z'
52
+ keep_time_key true
53
+ </parse>
54
+ </source>
55
+
56
+ <filter kubernetes.**>
57
+ @type concat
58
+ key message
59
+ partial_key logtag
60
+ partial_value P
61
+ separator ''
62
+ </filter>
63
+
64
+ <match **>
65
+ @type forward
66
+ heartbeat_type none
67
+ keepalive true
68
+
69
+ <buffer>
70
+ flush_mode interval
71
+ flush_interval 5s
72
+ flush_at_shutdown true
73
+ flush_thread_count 2
74
+ retry_type exponential_backoff
75
+ retry_wait 1s
76
+ retry_max_interval 60s
77
+ retry_forever true
78
+ overflow_action block
79
+ </buffer>
80
+
81
+ <server>
82
+ host 0.0.0.0
83
+ port 24224
84
+ </server>
85
+ </match>
86
+
87
+ ```
88
+