fluent-plugin-kubernetes_metadata_filter 2.9.3 → 2.10.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: b6344b1f6ff0602b9d78a5cf317ba5b44e54d0040d6172d102edd002a364d1e7
4
- data.tar.gz: 421689d196ae7a0c307ac7e8d4d066755464b76357921e7f6c55ad122ca744b0
3
+ metadata.gz: 8dcf9979d36d0b08161765e73d3ae244efba378ac3dd0d4d10f582be6abcc488
4
+ data.tar.gz: 9ea29129e636535052a9183119b61647ae419773e8174ca86adb9a9ebbbdebd8
5
5
  SHA512:
6
- metadata.gz: 63b03d82fec8888d13f4f752b1ea2519a7c3e594ac45eb0363109d323a35a56174fdd0fa401b787069e5bae84168878ff08baefa899810776b0d710bd55d3c04
7
- data.tar.gz: 6368f491a96f30482ded9e12bdc0e80232aebfc26a3a98be75133312c96b1311ff04ce2de5d818a06ba67d2d75274b658471668bfa846db2251202ea92f4b96e
6
+ metadata.gz: 1dc73fe9ef457fdd9bf424fe935ac99060df59d7c67273dc2c1320ae891cb70c98483c427613a675603557a7bc675d48029d4eefa69eb29b8c2b1f9536cccad2
7
+ data.tar.gz: fb160f1bc82037cc0ed3ddd7fae884aeab816c8d246256a40d7e5831b5ff64ee93512955709830028180017df4889421c9920f9364d9282029e8ceda5fe000c6
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
@@ -20,9 +21,6 @@ test: &test
20
21
  command: bundle exec rake test --trace
21
22
 
22
23
  executors:
23
- ruby-2-5:
24
- docker:
25
- - image: circleci/ruby:2.5.5
26
24
  ruby-2-6:
27
25
  docker:
28
26
  - image: circleci/ruby:2.6.3
@@ -49,8 +47,6 @@ jobs:
49
47
  workflows:
50
48
  "test_multiple_ruby_versions":
51
49
  jobs:
52
- - ruby-test:
53
- ruby-version: ruby-2-5
54
50
  - ruby-test:
55
51
  ruby-version: ruby-2-6
56
52
  - ruby-test:
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.3)
4
+ fluent-plugin-kubernetes_metadata_filter (2.10.0)
5
5
  fluentd (>= 0.14.0, < 1.15)
6
6
  kubeclient (>= 4.0.0, < 5.0.0)
7
7
  lru_redux
@@ -16,7 +16,7 @@ GEM
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.9)
19
+ concurrent-ruby (1.1.10)
20
20
  cool.io (1.7.1)
21
21
  copyright-header (1.0.22)
22
22
  github-linguist
@@ -26,16 +26,16 @@ GEM
26
26
  domain_name (0.5.20190701)
27
27
  unf (>= 0.0.5, < 1.0.0)
28
28
  escape_utils (1.2.1)
29
- ffi (1.15.4)
29
+ ffi (1.15.5)
30
30
  ffi-compiler (1.0.1)
31
31
  ffi (>= 1.0.0)
32
32
  rake
33
- fluentd (1.14.3)
33
+ fluentd (1.14.6)
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
- serverengine (>= 2.2.2, < 3.0.0)
38
+ serverengine (>= 2.2.5, < 3.0.0)
39
39
  sigdump (~> 0.2.2)
40
40
  strptime (>= 0.2.4, < 1.0.0)
41
41
  tzinfo (>= 1.0, < 3.0)
@@ -62,7 +62,7 @@ GEM
62
62
  http_parser.rb (0.8.0)
63
63
  jsonpath (1.1.0)
64
64
  multi_json
65
- kubeclient (4.9.2)
65
+ kubeclient (4.9.3)
66
66
  http (>= 3.0, < 5.0)
67
67
  jsonpath (~> 1.0)
68
68
  recursive-open-struct (~> 1.1, >= 1.1.1)
@@ -70,10 +70,10 @@ GEM
70
70
  lru_redux (1.1.0)
71
71
  mime-types (3.4.1)
72
72
  mime-types-data (~> 3.2015)
73
- mime-types-data (3.2021.1115)
73
+ mime-types-data (3.2022.0105)
74
74
  mini_mime (1.1.2)
75
75
  minitest (4.7.5)
76
- msgpack (1.4.2)
76
+ msgpack (1.5.1)
77
77
  multi_json (1.15.0)
78
78
  netrc (0.11.0)
79
79
  parallel (1.21.0)
@@ -105,7 +105,7 @@ GEM
105
105
  parser (>= 3.0.1.1)
106
106
  ruby-progressbar (1.11.0)
107
107
  rugged (1.2.0)
108
- serverengine (2.2.4)
108
+ serverengine (2.2.5)
109
109
  sigdump (~> 0.2.2)
110
110
  sigdump (0.2.4)
111
111
  simplecov (0.21.2)
@@ -122,11 +122,11 @@ 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.5)
125
+ tzinfo-data (1.2022.1)
126
126
  tzinfo (>= 1.0.0)
127
127
  unf (0.1.4)
128
128
  unf_ext
129
- unf_ext (0.0.8)
129
+ unf_ext (0.0.8.1)
130
130
  unicode-display_width (2.1.0)
131
131
  vcr (6.0.0)
132
132
  webmock (3.14.0)
@@ -134,7 +134,7 @@ GEM
134
134
  crack (>= 0.3.2)
135
135
  hashdiff (>= 0.4.0, < 2.0.0)
136
136
  webrick (1.7.0)
137
- yajl-ruby (1.4.1)
137
+ yajl-ruby (1.4.2)
138
138
 
139
139
  PLATFORMS
140
140
  ruby
@@ -155,4 +155,4 @@ DEPENDENCIES
155
155
  yajl-ruby
156
156
 
157
157
  BUNDLED WITH
158
- 2.2.19
158
+ 2.3.4
data/README.md CHANGED
@@ -17,6 +17,7 @@ that rely on the authenticity of the namespace for proper log isolation.
17
17
 
18
18
  | fluent-plugin-kubernetes_metadata_filter | fluentd | ruby |
19
19
  |-------------------|---------|------|
20
+ | >= 2.10.0 | >= v1.10.0 | >= 2.6 |
20
21
  | >= 2.5.0 | >= v1.10.0 | >= 2.5 |
21
22
  | >= 2.0.0 | >= v0.14.20 | >= 2.1 |
22
23
  | < 2.0.0 | >= v0.12.0 | >= 1.9 |
@@ -41,14 +42,14 @@ Configuration options for fluent.conf are:
41
42
  * `client_key` - path to a client key file to authenticate to the API server
42
43
  * `bearer_token_file` - path to a file containing the bearer token to use for authentication
43
44
  * `tag_to_kubernetes_name_regexp` - the regular expression used to extract kubernetes metadata (pod name, container name, namespace) from the current fluentd tag.
44
- This must used named capture groups for `container_name`, `pod_name` & `namespace` default: See [code](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/blob/master/lib/fluent/plugin/filter_kubernetes_metadata.rb#L52)
45
+ 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)`
45
46
  * `cache_size` - size of the cache of Kubernetes metadata to reduce requests to the API server (default: `1000`)
46
47
  * `cache_ttl` - TTL in seconds of each cached element. Set to negative value to disable TTL eviction (default: `3600` - 1 hour)
47
48
  * `watch` - set up a watch on pods on the API server for updates to metadata (default: `true`)
48
- * `de_dot` - replace dots in labels and annotations with configured `de_dot_separator`, required for Datadog and ElasticSearch 2.x compatibility (default: `true`)
49
- * `de_dot_separator` - separator to use if `de_dot` is enabled (default: `_`)
50
- * `de_slash` - replace slashes in labels and annotations with configured `de_slash_separator`, required for Datadog compatibility (default: `false`)
51
- * `de_slash_separator` - separator to use if `de_slash` is enabled (default: `__`)
49
+ * *DEPRECATED*`de_dot` - replace dots in labels and annotations with configured `de_dot_separator`, required for Datadog and ElasticSearch 2.x compatibility (default: `true`)
50
+ * *DEPRECATED*`de_dot_separator` - separator to use if `de_dot` is enabled (default: `_`)
51
+ * *DEPRECATED*`de_slash` - replace slashes in labels and annotations with configured `de_slash_separator`, required for Datadog compatibility (default: `false`)
52
+ * *DEPRECATED*`de_slash_separator` - separator to use if `de_slash` is enabled (default: `__`)
52
53
  * *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
53
54
  if available, otherwise, will use the tag in the `tag_to_kubernetes_name_regexp` format.
54
55
  * `container_name_to_kubernetes_regexp` - The regular expression used to extract the k8s metadata encoded in the journal `CONTAINER_NAME` field default: See [code](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/blob/master/lib/fluent/plugin/filter_kubernetes_metadata.rb#L68)
@@ -68,23 +69,6 @@ when true (default: `true`)
68
69
  * `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.
69
70
  * `watch_retry_interval` - The time interval in seconds for retry backoffs when watch connections fail. (default: `10`)
70
71
 
71
- **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
72
- payload. The following configuration options are removed:
73
-
74
- * `merge_json_log`
75
- * `preserve_json_log`
76
-
77
- One way of preserving JSON logs can be through the [parser plugin](https://docs.fluentd.org/filter/parser)
78
-
79
- **NOTE** As of release v2.1.4, the use of `use_journal` is **DEPRECATED**. If this setting is not present, the plugin will
80
- attempt to figure out the source of the metadata fields from the following:
81
- - If `lookup_from_k8s_field true` (the default) and the following fields are present in the record:
82
- `docker.container_id`, `kubernetes.namespace_name`, `kubernetes.pod_name`, `kubernetes.container_name`,
83
- then the plugin will use those values as the source to use to lookup the metadata
84
- - If `use_journal true`, or `use_journal` is unset, and the fields `CONTAINER_NAME` and `CONTAINER_ID_FULL` are present in the record,
85
- then the plugin will parse those values using `container_name_to_kubernetes_regexp` and use those as the source to lookup the metadata
86
- - Otherwise, if the tag matches `tag_to_kubernetes_name_regexp`, the plugin will parse the tag and use those values to
87
- lookup the metdata
88
72
 
89
73
  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":
90
74
 
@@ -154,22 +138,7 @@ Reading from the systemd journal (requires the fluentd `fluent-plugin-systemd` a
154
138
  @type stdout
155
139
  </match>
156
140
  ```
157
- ## Log content as JSON
158
- 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:
159
- ```
160
- <filter kubernetes.**>
161
- @type parser
162
- key_name log
163
- <parse>
164
- @type json
165
- json_parser json
166
- </parse>
167
- replace_invalid_sequence true
168
- reserve_data true # this preserves unparsable log lines
169
- emit_invalid_record_to_error false # In case of unparsable log lines keep the error log clean
170
- reserve_time # the time was already parsed in the source, we don't want to overwrite it with current time.
171
- </filter>
172
- ```
141
+
173
142
 
174
143
  ## Environment variables for Kubernetes
175
144
 
@@ -5,9 +5,9 @@ $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.3'
9
- gem.authors = ['Jimmi Dyson']
10
- gem.email = ['jimmidyson@gmail.com']
8
+ gem.version = '2.10.0'
9
+ gem.authors = ['OpenShift Cluster Logging','Jimmi Dyson']
10
+ gem.email = ['team-logging@redhat.com','jimmidyson@gmail.com']
11
11
  gem.description = 'Filter plugin to add Kubernetes metadata'
12
12
  gem.summary = 'Fluentd filter plugin to add Kubernetes metadata'
13
13
  gem.homepage = 'https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter'
@@ -52,8 +52,8 @@ module Fluent::Plugin
52
52
  config_param :ca_file, :string, default: nil
53
53
  config_param :verify_ssl, :bool, default: true
54
54
 
55
- REGEX_VAR_LOG_PODS = '(?<prefix>var\.log\.pods)\.(?<namespace>[^_]+)_(?<pod_name>[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<pod_uuid>[a-z0-9-]*)\.(?<container_name>.+)\..*\.log$'
56
- REGEX_VAR_LOG_CONTAINERS = '(?<prefix>var\.log\.containers)\.(?<pod_name>[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace>[^_]+)_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\.log$'
55
+ REGEX_VAR_LOG_PODS = '(var\.log\.pods)\.(?<namespace>[^_]+)_(?<pod_name>[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<pod_uuid>[a-z0-9-]*)\.(?<container_name>.+)\..*\.log$'
56
+ REGEX_VAR_LOG_CONTAINERS = '(var\.log\.containers)\.(?<pod_name>[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace>[^_]+)_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\.log$'
57
57
 
58
58
  #tag_to_kubernetes_name_regexp which must include named capture groups:
59
59
  # namespace - The namespace in which the pod is deployed
@@ -305,7 +305,7 @@ module Fluent::Plugin
305
305
  end
306
306
  end
307
307
 
308
- def get_metadata_for_record(source, namespace_name, pod_name, container_name, cache_key, create_time, batch_miss_cache)
308
+ def get_metadata_for_record(namespace_name, pod_name, container_name, cache_key, create_time, batch_miss_cache, docker_id)
309
309
  metadata = {
310
310
  'docker' => { 'container_id' => "" },
311
311
  'kubernetes' => {
@@ -314,7 +314,7 @@ module Fluent::Plugin
314
314
  'pod_name' => pod_name
315
315
  }
316
316
  }
317
- metadata['docker']['container_id'] = cache_key unless source == 'var.log.pods'
317
+ metadata['docker']['container_id'] = docker_id unless docker_id.nil?
318
318
  container_cache_key = container_name
319
319
  if present?(@kubernetes_url)
320
320
  pod_metadata = get_pod_metadata(cache_key, namespace_name, pod_name, create_time, batch_miss_cache)
@@ -344,8 +344,9 @@ module Fluent::Plugin
344
344
  else
345
345
  tag_match_data['docker_id']
346
346
  end
347
- tag_metadata = get_metadata_for_record(tag_match_data['prefix'], tag_match_data['namespace'], tag_match_data['pod_name'], tag_match_data['container_name'],
348
- cache_key, create_time_from_record(record, time), batch_miss_cache)
347
+ docker_id = tag_match_data.names.include?('docker_id') ? tag_match_data['docker_id'] : nil
348
+ tag_metadata = get_metadata_for_record(tag_match_data['namespace'], tag_match_data['pod_name'], tag_match_data['container_name'],
349
+ cache_key, create_time_from_record(record, time), batch_miss_cache, docker_id)
349
350
  end
350
351
  metadata = Marshal.load(Marshal.dump(tag_metadata)) if tag_metadata
351
352
  if (@use_journal || @use_journal.nil?) &&
@@ -358,9 +359,9 @@ module Fluent::Plugin
358
359
  record['kubernetes'].key?('pod_name') &&
359
360
  record['kubernetes'].key?('container_name') &&
360
361
  record['docker'].key?('container_id') &&
361
- (k_metadata = get_metadata_for_record(tag_match_data['prefix'], record['kubernetes']['namespace_name'], record['kubernetes']['pod_name'],
362
+ (k_metadata = get_metadata_for_record(record['kubernetes']['namespace_name'], record['kubernetes']['pod_name'],
362
363
  record['kubernetes']['container_name'], record['docker']['container_id'],
363
- create_time_from_record(record, time), batch_miss_cache))
364
+ create_time_from_record(record, time), batch_miss_cache, record['docker']['container_id']))
364
365
  metadata = k_metadata
365
366
  end
366
367
  record = record.merge(metadata) if metadata
@@ -374,8 +375,8 @@ module Fluent::Plugin
374
375
  metadata = nil
375
376
  if record.key?('CONTAINER_NAME') && record.key?('CONTAINER_ID_FULL')
376
377
  metadata = record['CONTAINER_NAME'].match(@container_name_to_kubernetes_regexp_compiled) do |match_data|
377
- get_metadata_for_record(match_data['name_prefix'], match_data['namespace'], match_data['pod_name'], match_data['container_name'],
378
- record['CONTAINER_ID_FULL'], create_time_from_record(record, time), batch_miss_cache)
378
+ get_metadata_for_record(match_data['namespace'], match_data['pod_name'], match_data['container_name'],
379
+ record['CONTAINER_ID_FULL'], create_time_from_record(record, time), batch_miss_cache, record['CONTAINER_ID_FULL'])
379
380
  end
380
381
  unless metadata
381
382
  log.debug "Error: could not match CONTAINER_NAME from record #{record}"
@@ -26,7 +26,7 @@ module KubernetesMetadata
26
26
  def api_valid?
27
27
  true
28
28
  end
29
- def get_namespace(namespace_name)
29
+ def get_namespace(namespace_name, unused, options)
30
30
  return {
31
31
  metadata: {
32
32
  name: namespace_name,
@@ -38,7 +38,7 @@ module KubernetesMetadata
38
38
  }
39
39
  end
40
40
 
41
- def get_pod(pod_name, namespace_name)
41
+ def get_pod(pod_name, namespace_name, options)
42
42
  return {
43
43
  metadata: {
44
44
  name: pod_name,
data/release_notes.md ADDED
@@ -0,0 +1,42 @@
1
+ # Release Notes
2
+
3
+ ## 2.9.4
4
+ As of this release, the 'de_dot' functionality is depricated and will be removed in future releases.
5
+ Ref: https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/issues/320
6
+
7
+ ## v2.1.4
8
+ The use of `use_journal` is **DEPRECATED**. If this setting is not present, the plugin will
9
+ attempt to figure out the source of the metadata fields from the following:
10
+ - If `lookup_from_k8s_field true` (the default) and the following fields are present in the record:
11
+ `docker.container_id`, `kubernetes.namespace_name`, `kubernetes.pod_name`, `kubernetes.container_name`,
12
+ then the plugin will use those values as the source to use to lookup the metadata
13
+ - If `use_journal true`, or `use_journal` is unset, and the fields `CONTAINER_NAME` and `CONTAINER_ID_FULL` are present in the record,
14
+ then the plugin will parse those values using `container_name_to_kubernetes_regexp` and use those as the source to lookup the metadata
15
+ - Otherwise, if the tag matches `tag_to_kubernetes_name_regexp`, the plugin will parse the tag and use those values to
16
+ lookup the metdata
17
+
18
+ ## v2.1.x
19
+
20
+ 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
21
+ payload. The following configuration options are removed:
22
+
23
+ * `merge_json_log`
24
+ * `preserve_json_log`
25
+
26
+ One way of preserving JSON logs can be through the [parser plugin](https://docs.fluentd.org/filter/parser).
27
+ It can parsed with the parser plugin like this:
28
+
29
+ ```
30
+ <filter kubernetes.**>
31
+ @type parser
32
+ key_name log
33
+ <parse>
34
+ @type json
35
+ json_parser json
36
+ </parse>
37
+ replace_invalid_sequence true
38
+ reserve_data true # this preserves unparsable log lines
39
+ emit_invalid_record_to_error false # In case of unparsable log lines keep the error log clean
40
+ reserve_time # the time was already parsed in the source, we don't want to overwrite it with current time.
41
+ </filter>
42
+ ```
metadata CHANGED
@@ -1,14 +1,15 @@
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.3
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
+ - OpenShift Cluster Logging
7
8
  - Jimmi Dyson
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2021-12-06 00:00:00.000000000 Z
12
+ date: 2022-04-12 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: fluentd
@@ -206,6 +207,7 @@ dependencies:
206
207
  version: '0'
207
208
  description: Filter plugin to add Kubernetes metadata
208
209
  email:
210
+ - team-logging@redhat.com
209
211
  - jimmidyson@gmail.com
210
212
  executables: []
211
213
  extensions: []
@@ -228,6 +230,7 @@ files:
228
230
  - lib/fluent/plugin/kubernetes_metadata_util.rb
229
231
  - lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb
230
232
  - lib/fluent/plugin/kubernetes_metadata_watch_pods.rb
233
+ - release_notes.md
231
234
  - test/cassettes/invalid_api_server_config.yml
232
235
  - test/cassettes/kubernetes_docker_metadata_annotations.yml
233
236
  - test/cassettes/kubernetes_docker_metadata_dotted_slashed_labels.yml