fluent-plugin-kubernetes_metadata_filter 2.4.1 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +13 -16
- data/.gitignore +0 -1
- data/.rubocop.yml +57 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +158 -0
- data/README.md +36 -24
- data/Rakefile +15 -11
- data/fluent-plugin-kubernetes_metadata_filter.gemspec +25 -27
- data/lib/fluent/plugin/filter_kubernetes_metadata.rb +164 -137
- data/lib/fluent/plugin/kubernetes_metadata_cache_strategy.rb +23 -21
- data/lib/fluent/plugin/kubernetes_metadata_common.rb +55 -65
- data/lib/fluent/plugin/kubernetes_metadata_stats.rb +6 -6
- data/lib/fluent/plugin/kubernetes_metadata_test_api_adapter.rb +68 -0
- data/lib/fluent/plugin/kubernetes_metadata_util.rb +53 -0
- data/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb +121 -27
- data/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb +133 -36
- data/release_notes.md +42 -0
- data/test/cassettes/{kubernetes_docker_metadata_dotted_labels.yml → kubernetes_docker_metadata_dotted_slashed_labels.yml} +0 -0
- data/test/cassettes/kubernetes_get_pod_container_init.yml +145 -0
- data/test/helper.rb +20 -2
- data/test/plugin/test_cache_stats.rb +10 -13
- data/test/plugin/test_cache_strategy.rb +158 -160
- data/test/plugin/test_filter_kubernetes_metadata.rb +464 -360
- data/test/plugin/test_utils.rb +56 -0
- data/test/plugin/test_watch_namespaces.rb +209 -55
- data/test/plugin/test_watch_pods.rb +297 -166
- data/test/plugin/watch_test.rb +52 -33
- metadata +63 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dcf9979d36d0b08161765e73d3ae244efba378ac3dd0d4d10f582be6abcc488
|
4
|
+
data.tar.gz: 9ea29129e636535052a9183119b61647ae419773e8174ca86adb9a9ebbbdebd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dc73fe9ef457fdd9bf424fe935ac99060df59d7c67273dc2c1320ae891cb70c98483c427613a675603557a7bc675d48029d4eefa69eb29b8c2b1f9536cccad2
|
7
|
+
data.tar.gz: fb160f1bc82037cc0ed3ddd7fae884aeab816c8d246256a40d7e5831b5ff64ee93512955709830028180017df4889421c9920f9364d9282029e8ceda5fe000c6
|
data/.circleci/config.yml
CHANGED
@@ -2,31 +2,31 @@ version: 2.1
|
|
2
2
|
|
3
3
|
install: &install
|
4
4
|
name: Install bundle
|
5
|
-
command:
|
5
|
+
command: |
|
6
|
+
gem install bundler
|
7
|
+
bundle config set --local path vendor/bundle
|
8
|
+
bundle install
|
6
9
|
|
7
10
|
missingdeps: &missingdeps
|
8
11
|
name: Install missing dependecies
|
9
12
|
command: |
|
10
13
|
cat /etc/os-release
|
11
|
-
printf "deb http://
|
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
|
12
15
|
sudo cp /tmp/sources.list /etc/apt/sources.list
|
13
|
-
sudo apt-get update
|
16
|
+
sudo apt-get --allow-releaseinfo-change update
|
14
17
|
sudo apt-get install cmake libicu-dev libssl-dev
|
15
|
-
|
18
|
+
|
16
19
|
test: &test
|
17
20
|
name: Test bundle
|
18
|
-
command: bundle exec rake test
|
21
|
+
command: bundle exec rake test --trace
|
19
22
|
|
20
23
|
executors:
|
21
|
-
ruby-2-4:
|
22
|
-
docker:
|
23
|
-
- image: circleci/ruby:2.4.6
|
24
|
-
ruby-2-5:
|
25
|
-
docker:
|
26
|
-
- image: circleci/ruby:2.5.5
|
27
24
|
ruby-2-6:
|
28
25
|
docker:
|
29
26
|
- image: circleci/ruby:2.6.3
|
27
|
+
ruby-2-7:
|
28
|
+
docker:
|
29
|
+
- image: circleci/ruby:2.7.1
|
30
30
|
jobs:
|
31
31
|
"ruby-test":
|
32
32
|
parameters:
|
@@ -47,10 +47,7 @@ jobs:
|
|
47
47
|
workflows:
|
48
48
|
"test_multiple_ruby_versions":
|
49
49
|
jobs:
|
50
|
-
- ruby-test:
|
51
|
-
ruby-version: ruby-2-4
|
52
|
-
- ruby-test:
|
53
|
-
ruby-version: ruby-2-5
|
54
50
|
- ruby-test:
|
55
51
|
ruby-version: ruby-2-6
|
56
|
-
|
52
|
+
- ruby-test:
|
53
|
+
ruby-version: ruby-2-7
|
data/.gitignore
CHANGED
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', :
|
4
|
-
gem 'rubocop'
|
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
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fluent-plugin-kubernetes_metadata_filter (2.10.0)
|
5
|
+
fluentd (>= 0.14.0, < 1.15)
|
6
|
+
kubeclient (>= 4.0.0, < 5.0.0)
|
7
|
+
lru_redux
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.8.0)
|
13
|
+
public_suffix (>= 2.0.2, < 5.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
bump (0.10.0)
|
16
|
+
charlock_holmes (0.7.7)
|
17
|
+
codeclimate-test-reporter (0.6.0)
|
18
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
19
|
+
concurrent-ruby (1.1.10)
|
20
|
+
cool.io (1.7.1)
|
21
|
+
copyright-header (1.0.22)
|
22
|
+
github-linguist
|
23
|
+
crack (0.4.5)
|
24
|
+
rexml
|
25
|
+
docile (1.4.0)
|
26
|
+
domain_name (0.5.20190701)
|
27
|
+
unf (>= 0.0.5, < 1.0.0)
|
28
|
+
escape_utils (1.2.1)
|
29
|
+
ffi (1.15.5)
|
30
|
+
ffi-compiler (1.0.1)
|
31
|
+
ffi (>= 1.0.0)
|
32
|
+
rake
|
33
|
+
fluentd (1.14.6)
|
34
|
+
bundler
|
35
|
+
cool.io (>= 1.4.5, < 2.0.0)
|
36
|
+
http_parser.rb (>= 0.5.1, < 0.9.0)
|
37
|
+
msgpack (>= 1.3.1, < 2.0.0)
|
38
|
+
serverengine (>= 2.2.5, < 3.0.0)
|
39
|
+
sigdump (~> 0.2.2)
|
40
|
+
strptime (>= 0.2.4, < 1.0.0)
|
41
|
+
tzinfo (>= 1.0, < 3.0)
|
42
|
+
tzinfo-data (~> 1.0)
|
43
|
+
webrick (>= 1.4.2, < 1.8.0)
|
44
|
+
yajl-ruby (~> 1.0)
|
45
|
+
github-linguist (7.17.0)
|
46
|
+
charlock_holmes (~> 0.7.7)
|
47
|
+
escape_utils (~> 1.2.0)
|
48
|
+
mini_mime (~> 1.0)
|
49
|
+
rugged (>= 0.25.1)
|
50
|
+
hashdiff (1.0.1)
|
51
|
+
http (4.4.1)
|
52
|
+
addressable (~> 2.3)
|
53
|
+
http-cookie (~> 1.0)
|
54
|
+
http-form_data (~> 2.2)
|
55
|
+
http-parser (~> 1.2.0)
|
56
|
+
http-accept (1.7.0)
|
57
|
+
http-cookie (1.0.4)
|
58
|
+
domain_name (~> 0.5)
|
59
|
+
http-form_data (2.3.0)
|
60
|
+
http-parser (1.2.3)
|
61
|
+
ffi-compiler (>= 1.0, < 2.0)
|
62
|
+
http_parser.rb (0.8.0)
|
63
|
+
jsonpath (1.1.0)
|
64
|
+
multi_json
|
65
|
+
kubeclient (4.9.3)
|
66
|
+
http (>= 3.0, < 5.0)
|
67
|
+
jsonpath (~> 1.0)
|
68
|
+
recursive-open-struct (~> 1.1, >= 1.1.1)
|
69
|
+
rest-client (~> 2.0)
|
70
|
+
lru_redux (1.1.0)
|
71
|
+
mime-types (3.4.1)
|
72
|
+
mime-types-data (~> 3.2015)
|
73
|
+
mime-types-data (3.2022.0105)
|
74
|
+
mini_mime (1.1.2)
|
75
|
+
minitest (4.7.5)
|
76
|
+
msgpack (1.5.1)
|
77
|
+
multi_json (1.15.0)
|
78
|
+
netrc (0.11.0)
|
79
|
+
parallel (1.21.0)
|
80
|
+
parser (3.0.2.0)
|
81
|
+
ast (~> 2.4.1)
|
82
|
+
power_assert (2.0.1)
|
83
|
+
public_suffix (4.0.6)
|
84
|
+
rainbow (3.0.0)
|
85
|
+
rake (13.0.6)
|
86
|
+
recursive-open-struct (1.1.3)
|
87
|
+
regexp_parser (2.1.1)
|
88
|
+
rest-client (2.1.0)
|
89
|
+
http-accept (>= 1.7.0, < 2.0)
|
90
|
+
http-cookie (>= 1.0.2, < 2.0)
|
91
|
+
mime-types (>= 1.16, < 4.0)
|
92
|
+
netrc (~> 0.8)
|
93
|
+
rexml (3.2.5)
|
94
|
+
rr (3.0.8)
|
95
|
+
rubocop (1.22.3)
|
96
|
+
parallel (~> 1.10)
|
97
|
+
parser (>= 3.0.0.0)
|
98
|
+
rainbow (>= 2.2.2, < 4.0)
|
99
|
+
regexp_parser (>= 1.8, < 3.0)
|
100
|
+
rexml
|
101
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
102
|
+
ruby-progressbar (~> 1.7)
|
103
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
104
|
+
rubocop-ast (1.12.0)
|
105
|
+
parser (>= 3.0.1.1)
|
106
|
+
ruby-progressbar (1.11.0)
|
107
|
+
rugged (1.2.0)
|
108
|
+
serverengine (2.2.5)
|
109
|
+
sigdump (~> 0.2.2)
|
110
|
+
sigdump (0.2.4)
|
111
|
+
simplecov (0.21.2)
|
112
|
+
docile (~> 1.1)
|
113
|
+
simplecov-html (~> 0.11)
|
114
|
+
simplecov_json_formatter (~> 0.1)
|
115
|
+
simplecov-html (0.12.3)
|
116
|
+
simplecov_json_formatter (0.1.3)
|
117
|
+
strptime (0.2.5)
|
118
|
+
test-unit (3.0.9)
|
119
|
+
power_assert
|
120
|
+
test-unit-rr (1.0.5)
|
121
|
+
rr (>= 1.1.1)
|
122
|
+
test-unit (>= 2.5.2)
|
123
|
+
tzinfo (2.0.4)
|
124
|
+
concurrent-ruby (~> 1.0)
|
125
|
+
tzinfo-data (1.2022.1)
|
126
|
+
tzinfo (>= 1.0.0)
|
127
|
+
unf (0.1.4)
|
128
|
+
unf_ext
|
129
|
+
unf_ext (0.0.8.1)
|
130
|
+
unicode-display_width (2.1.0)
|
131
|
+
vcr (6.0.0)
|
132
|
+
webmock (3.14.0)
|
133
|
+
addressable (>= 2.8.0)
|
134
|
+
crack (>= 0.3.2)
|
135
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
136
|
+
webrick (1.7.0)
|
137
|
+
yajl-ruby (1.4.2)
|
138
|
+
|
139
|
+
PLATFORMS
|
140
|
+
ruby
|
141
|
+
|
142
|
+
DEPENDENCIES
|
143
|
+
bump
|
144
|
+
bundler (~> 2.0)
|
145
|
+
codeclimate-test-reporter (< 1.0.0)
|
146
|
+
copyright-header
|
147
|
+
fluent-plugin-kubernetes_metadata_filter!
|
148
|
+
minitest (~> 4.0)
|
149
|
+
rake
|
150
|
+
rubocop
|
151
|
+
test-unit (~> 3.0.2)
|
152
|
+
test-unit-rr (~> 1.0.3)
|
153
|
+
vcr
|
154
|
+
webmock
|
155
|
+
yajl-ruby
|
156
|
+
|
157
|
+
BUNDLED WITH
|
158
|
+
2.3.4
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
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
|
|
@@ -15,6 +17,8 @@ that rely on the authenticity of the namespace for proper log isolation.
|
|
15
17
|
|
16
18
|
| fluent-plugin-kubernetes_metadata_filter | fluentd | ruby |
|
17
19
|
|-------------------|---------|------|
|
20
|
+
| >= 2.10.0 | >= v1.10.0 | >= 2.6 |
|
21
|
+
| >= 2.5.0 | >= v1.10.0 | >= 2.5 |
|
18
22
|
| >= 2.0.0 | >= v0.14.20 | >= 2.1 |
|
19
23
|
| < 2.0.0 | >= v0.12.0 | >= 1.9 |
|
20
24
|
|
@@ -38,16 +42,18 @@ Configuration options for fluent.conf are:
|
|
38
42
|
* `client_key` - path to a client key file to authenticate to the API server
|
39
43
|
* `bearer_token_file` - path to a file containing the bearer token to use for authentication
|
40
44
|
* `tag_to_kubernetes_name_regexp` - the regular expression used to extract kubernetes metadata (pod name, container name, namespace) from the current fluentd tag.
|
41
|
-
This must
|
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)`
|
42
46
|
* `cache_size` - size of the cache of Kubernetes metadata to reduce requests to the API server (default: `1000`)
|
43
47
|
* `cache_ttl` - TTL in seconds of each cached element. Set to negative value to disable TTL eviction (default: `3600` - 1 hour)
|
44
48
|
* `watch` - set up a watch on pods on the API server for updates to metadata (default: `true`)
|
45
|
-
*
|
46
|
-
*
|
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: `__`)
|
47
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
|
48
54
|
if available, otherwise, will use the tag in the `tag_to_kubernetes_name_regexp` format.
|
49
|
-
* `container_name_to_kubernetes_regexp` - The regular expression used to extract the k8s metadata encoded in the journal `CONTAINER_NAME` field
|
50
|
-
* This corresponds to the definition [in the source](https://github.com/kubernetes/kubernetes/blob/
|
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)
|
56
|
+
* This corresponds to the definition [in the source](https://github.com/kubernetes/kubernetes/blob/release-1.6/pkg/kubelet/dockertools/docker.go#L317)
|
51
57
|
* `annotation_match` - Array of regular expressions matching annotation field names. Matched annotations are added to a log record.
|
52
58
|
* `allow_orphans` - Modify the namespace and namespace id to the values of `orphaned_namespace_name` and `orphaned_namespace_id`
|
53
59
|
when true (default: `true`)
|
@@ -61,35 +67,39 @@ when true (default: `true`)
|
|
61
67
|
* `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.
|
62
68
|
* `skip_master_url` - Skip the master_url field from the metadata.
|
63
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.
|
70
|
+
* `watch_retry_interval` - The time interval in seconds for retry backoffs when watch connections fail. (default: `10`)
|
64
71
|
|
65
|
-
**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
|
66
|
-
payload. The following configuration options are removed:
|
67
72
|
|
68
|
-
|
69
|
-
* `preserve_json_log`
|
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":
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
attempt to figure out the source of the metadata fields from the following:
|
75
|
-
- If `lookup_from_k8s_field true` (the default) and the following fields are present in the record:
|
76
|
-
`docker.container_id`, `kubernetes.namespace_name`, `kubernetes.pod_name`, `kubernetes.container_name`,
|
77
|
-
then the plugin will use those values as the source to use to lookup the metadata
|
78
|
-
- If `use_journal true`, or `use_journal` is unset, and the fields `CONTAINER_NAME` and `CONTAINER_ID_FULL` are present in the record,
|
79
|
-
then the plugin will parse those values using `container_name_to_kubernetes_regexp` and use those as the source to lookup the metadata
|
80
|
-
- Otherwise, if the tag matches `tag_to_kubernetes_name_regexp`, the plugin will parse the tag and use those values to
|
81
|
-
lookup the metdata
|
75
|
+
```
|
76
|
+
fluent-gem install fluent-plugin-multi-format-parser
|
77
|
+
```
|
82
78
|
|
83
|
-
|
79
|
+
The config block could look like this:
|
84
80
|
```
|
85
81
|
<source>
|
86
82
|
@type tail
|
87
83
|
path /var/log/containers/*.log
|
88
84
|
pos_file fluentd-docker.pos
|
89
|
-
time_format %Y-%m-%dT%H:%M:%S
|
90
|
-
tag kubernetes.*
|
91
|
-
format json
|
92
85
|
read_from_head true
|
86
|
+
tag kubernetes.*
|
87
|
+
<parse>
|
88
|
+
@type multi_format
|
89
|
+
<pattern>
|
90
|
+
format json
|
91
|
+
time_key time
|
92
|
+
time_type string
|
93
|
+
time_format "%Y-%m-%dT%H:%M:%S.%NZ"
|
94
|
+
keep_time_key false
|
95
|
+
</pattern>
|
96
|
+
<pattern>
|
97
|
+
format regexp
|
98
|
+
expression /^(?<time>.+) (?<stream>stdout|stderr)( (?<logtag>.))? (?<log>.*)$/
|
99
|
+
time_format '%Y-%m-%dT%H:%M:%S.%N%:z'
|
100
|
+
keep_time_key false
|
101
|
+
</pattern>
|
102
|
+
</parse>
|
93
103
|
</source>
|
94
104
|
|
95
105
|
<filter kubernetes.var.log.containers.**.log>
|
@@ -129,6 +139,7 @@ Reading from the systemd journal (requires the fluentd `fluent-plugin-systemd` a
|
|
129
139
|
</match>
|
130
140
|
```
|
131
141
|
|
142
|
+
|
132
143
|
## Environment variables for Kubernetes
|
133
144
|
|
134
145
|
If the name of the Kubernetes node the plugin is running on is set as
|
@@ -171,6 +182,7 @@ Then output becomes as belows
|
|
171
182
|
"host": "jimmi-redhat.localnet",
|
172
183
|
"pod_name":"fabric8-console-controller-98rqc",
|
173
184
|
"pod_id": "c76927af-f563-11e4-b32d-54ee7527188d",
|
185
|
+
"pod_ip": "172.17.0.8",
|
174
186
|
"container_name": "fabric8-console-container",
|
175
187
|
"namespace_name": "default",
|
176
188
|
"namespace_id": "23437884-8e08-4d95-850b-e94378c9b2fd",
|
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 :
|
9
|
+
task test: [:base_test]
|
10
|
+
task default: [:test, :build, :rubocop]
|
6
11
|
|
7
|
-
|
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
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
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(
|
39
|
+
command_line = CopyrightHeader::CommandLine.new(args)
|
36
40
|
command_line.execute
|
37
41
|
end
|
@@ -1,36 +1,34 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
|
5
6
|
Gem::Specification.new do |gem|
|
6
|
-
gem.name =
|
7
|
-
gem.version =
|
8
|
-
gem.authors = [
|
9
|
-
gem.email = [
|
10
|
-
gem.description =
|
11
|
-
gem.summary =
|
12
|
-
gem.homepage =
|
13
|
-
gem.license =
|
7
|
+
gem.name = 'fluent-plugin-kubernetes_metadata_filter'
|
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
|
+
gem.description = 'Filter plugin to add Kubernetes metadata'
|
12
|
+
gem.summary = 'Fluentd filter plugin to add Kubernetes metadata'
|
13
|
+
gem.homepage = 'https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter'
|
14
|
+
gem.license = 'Apache-2.0'
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = ["lib"]
|
19
17
|
|
20
|
-
gem.required_ruby_version = '>= 2.
|
18
|
+
gem.required_ruby_version = '>= 2.5.0'
|
21
19
|
|
22
|
-
gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '<
|
23
|
-
gem.add_runtime_dependency
|
24
|
-
gem.add_runtime_dependency
|
20
|
+
gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '< 1.15']
|
21
|
+
gem.add_runtime_dependency 'kubeclient', ['>= 4.0.0', '< 5.0.0']
|
22
|
+
gem.add_runtime_dependency 'lru_redux'
|
25
23
|
|
26
|
-
gem.add_development_dependency
|
27
|
-
gem.add_development_dependency
|
28
|
-
gem.add_development_dependency
|
29
|
-
gem.add_development_dependency
|
30
|
-
gem.add_development_dependency
|
31
|
-
gem.add_development_dependency
|
32
|
-
gem.add_development_dependency
|
33
|
-
gem.add_development_dependency
|
34
|
-
gem.add_development_dependency
|
35
|
-
gem.add_development_dependency
|
24
|
+
gem.add_development_dependency 'bump'
|
25
|
+
gem.add_development_dependency 'bundler', '~> 2.0'
|
26
|
+
gem.add_development_dependency 'copyright-header'
|
27
|
+
gem.add_development_dependency 'minitest', '~> 4.0'
|
28
|
+
gem.add_development_dependency 'rake'
|
29
|
+
gem.add_development_dependency 'test-unit', '~> 3.0.2'
|
30
|
+
gem.add_development_dependency 'test-unit-rr', '~> 1.0.3'
|
31
|
+
gem.add_development_dependency 'vcr'
|
32
|
+
gem.add_development_dependency 'webmock'
|
33
|
+
gem.add_development_dependency 'yajl-ruby'
|
36
34
|
end
|