fluent-plugin-kubernetes_metadata_filter 2.1.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +53 -0
  3. data/.gitignore +0 -2
  4. data/.rubocop.yml +57 -0
  5. data/Gemfile +4 -2
  6. data/Gemfile.lock +159 -0
  7. data/README.md +49 -60
  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 -28
  28. data/lib/fluent/plugin/filter_kubernetes_metadata.rb +207 -187
  29. data/lib/fluent/plugin/kubernetes_metadata_cache_strategy.rb +30 -23
  30. data/lib/fluent/plugin/kubernetes_metadata_common.rb +66 -24
  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 +154 -27
  35. data/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb +171 -29
  36. data/release_notes.md +42 -0
  37. data/test/cassettes/kubernetes_docker_metadata_annotations.yml +0 -34
  38. data/test/cassettes/{kubernetes_docker_metadata_dotted_labels.yml → kubernetes_docker_metadata_dotted_slashed_labels.yml} +0 -34
  39. data/test/cassettes/kubernetes_get_api_v1.yml +193 -0
  40. data/test/cassettes/kubernetes_get_api_v1_using_token.yml +195 -0
  41. data/test/cassettes/kubernetes_get_namespace_default.yml +72 -0
  42. data/test/cassettes/kubernetes_get_namespace_default_using_token.yml +71 -0
  43. data/test/cassettes/{kubernetes_docker_metadata.yml → kubernetes_get_pod.yml} +0 -82
  44. data/test/cassettes/kubernetes_get_pod_container_init.yml +145 -0
  45. data/test/cassettes/{metadata_with_namespace_id.yml → kubernetes_get_pod_using_token.yml} +2 -130
  46. data/test/cassettes/{kubernetes_docker_metadata_using_bearer_token.yml → kubernetes_get_pod_with_ownerrefs.yml} +17 -109
  47. data/test/cassettes/metadata_from_tag_and_journald_fields.yml +153 -0
  48. data/test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml +285 -0
  49. data/test/cassettes/{non_kubernetes_docker_metadata.yml → valid_kubernetes_api_server_using_token.yml} +4 -44
  50. data/test/helper.rb +20 -2
  51. data/test/plugin/test_cache_stats.rb +10 -13
  52. data/test/plugin/test_cache_strategy.rb +158 -160
  53. data/test/plugin/test_filter_kubernetes_metadata.rb +451 -314
  54. data/test/plugin/test_watch_namespaces.rb +209 -55
  55. data/test/plugin/test_watch_pods.rb +302 -71
  56. data/test/plugin/watch_test.rb +52 -33
  57. metadata +91 -70
  58. data/circle.yml +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 58bdc9ed97a93eb46eeec306ad5851b94d3b5656
4
- data.tar.gz: 56806c61750f533d2190c0a0915fb1fed0b4d46e
2
+ SHA256:
3
+ metadata.gz: 0754e97a3a06ac6c24eee7004490eb0e06bfb51f63a2c973e07d9edfc593a239
4
+ data.tar.gz: 340c6bdc268bc2ff009fd63e58ec460e043f65636d1a03f9a3726467e84821f5
5
5
  SHA512:
6
- metadata.gz: e38271b6f13d95781df47a4c99474ec9d54bd8926a48a55d2613086079997728902d74b1207986325e36f9ea647b65786b0602f280a8ae5d4c37f3ae4737973a
7
- data.tar.gz: 90a46813a80eec7928f35387adc4778d3c07e1e6f61eea0cf3ca1725ef8195bf73816f733bb7c5cb0464cd69269981a8fb7562bc2a3e17ffaf00384624821b74
6
+ metadata.gz: de4fa7d241b0b7efacd1cde9e2c18c0bb3c8553d13e13528e9ccc16aa3ab974c12b1a88ce43a7bd186c9060d29ba649f8aa0365c3a9ecc4eed2c2354e1092dc9
7
+ data.tar.gz: 02ca1c7a7703e85962e206571b25a8416be206ef18d706958dfc894c598a068727e53abb3bd3beb059f1245211f957072b0b4c38a21a9d4c1ed114286306ffc9
@@ -0,0 +1,53 @@
1
+ version: 2.1
2
+
3
+ install: &install
4
+ name: Install bundle
5
+ command: |
6
+ gem install bundler
7
+ bundle config set --local path vendor/bundle
8
+ bundle install
9
+
10
+ missingdeps: &missingdeps
11
+ name: Install missing dependecies
12
+ command: |
13
+ cat /etc/os-release
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
15
+ sudo cp /tmp/sources.list /etc/apt/sources.list
16
+ sudo apt-get --allow-releaseinfo-change update
17
+ sudo apt-get install cmake libicu-dev libssl-dev
18
+
19
+ test: &test
20
+ name: Test bundle
21
+ command: bundle exec rake test --trace
22
+
23
+ executors:
24
+ ruby-2-6:
25
+ docker:
26
+ - image: circleci/ruby:2.6.3
27
+ ruby-2-7:
28
+ docker:
29
+ - image: circleci/ruby:2.7.1
30
+ jobs:
31
+ "ruby-test":
32
+ parameters:
33
+ ruby-version:
34
+ type: executor
35
+ executor: << parameters.ruby-version >>
36
+ working_directory: ~/fluent-plugin-kubernetes_metadata_filter
37
+ steps:
38
+ - run: *missingdeps
39
+ - checkout
40
+ - run: *install
41
+ - run: *test
42
+ - store_test_results:
43
+ path: coverage
44
+ - store_artifacts:
45
+ path: coverage
46
+
47
+ workflows:
48
+ "test_multiple_ruby_versions":
49
+ jobs:
50
+ - ruby-test:
51
+ ruby-version: ruby-2-6
52
+ - ruby-test:
53
+ ruby-version: ruby-2-7
data/.gitignore CHANGED
@@ -4,11 +4,9 @@
4
4
  .config
5
5
  .yardoc
6
6
  vendor/
7
- Gemfile.lock
8
7
  InstalledFiles
9
8
  _yardoc
10
9
  coverage
11
- doc/
12
10
  lib/bundler/man
13
11
  pkg
14
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 ADDED
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-plugin-kubernetes_metadata_filter (3.4.0)
5
+ fluentd (>= 0.14.0, < 1.17)
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.2.2)
20
+ cool.io (1.8.0)
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.2)
29
+ ffi (1.16.2)
30
+ ffi-compiler (1.0.1)
31
+ ffi (>= 1.0.0)
32
+ rake
33
+ fluentd (1.16.2)
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.3.2, < 3.0.0)
39
+ sigdump (~> 0.2.5)
40
+ strptime (>= 0.2.4, < 1.0.0)
41
+ tzinfo (>= 1.0, < 3.0)
42
+ tzinfo-data (~> 1.0)
43
+ webrick (~> 1.4)
44
+ yajl-ruby (~> 1.0)
45
+ github-linguist (7.21.0)
46
+ charlock_holmes (~> 0.7.7)
47
+ escape_utils (~> 1.2.0)
48
+ mini_mime (~> 1.0)
49
+ rugged (~> 1.0)
50
+ hashdiff (1.0.1)
51
+ http (5.1.1)
52
+ addressable (~> 2.8)
53
+ http-cookie (~> 1.0)
54
+ http-form_data (~> 2.2)
55
+ llhttp-ffi (~> 0.4.0)
56
+ http-accept (1.7.0)
57
+ http-cookie (1.0.5)
58
+ domain_name (~> 0.5)
59
+ http-form_data (2.3.0)
60
+ http_parser.rb (0.8.0)
61
+ jsonpath (1.1.4)
62
+ multi_json
63
+ kubeclient (4.11.0)
64
+ http (>= 3.0, < 6.0)
65
+ jsonpath (~> 1.0)
66
+ recursive-open-struct (~> 1.1, >= 1.1.1)
67
+ rest-client (~> 2.0)
68
+ llhttp-ffi (0.4.0)
69
+ ffi-compiler (~> 1.0)
70
+ rake (~> 13.0)
71
+ lru_redux (1.1.0)
72
+ mime-types (3.5.1)
73
+ mime-types-data (~> 3.2015)
74
+ mime-types-data (3.2023.0808)
75
+ mini_mime (1.1.2)
76
+ minitest (4.7.5)
77
+ msgpack (1.7.2)
78
+ multi_json (1.15.0)
79
+ netrc (0.11.0)
80
+ parallel (1.22.1)
81
+ parser (3.1.2.0)
82
+ ast (~> 2.4.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)
89
+ rest-client (2.1.0)
90
+ http-accept (>= 1.7.0, < 2.0)
91
+ http-cookie (>= 1.0.2, < 2.0)
92
+ mime-types (>= 1.16, < 4.0)
93
+ netrc (~> 0.8)
94
+ rexml (3.2.5)
95
+ rr (3.0.9)
96
+ rubocop (1.28.2)
97
+ parallel (~> 1.10)
98
+ parser (>= 3.1.0.0)
99
+ rainbow (>= 2.2.2, < 4.0)
100
+ regexp_parser (>= 1.8, < 3.0)
101
+ rexml
102
+ rubocop-ast (>= 1.17.0, < 2.0)
103
+ ruby-progressbar (~> 1.7)
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)
110
+ sigdump (~> 0.2.2)
111
+ sigdump (0.2.5)
112
+ simplecov (0.21.2)
113
+ docile (~> 1.1)
114
+ simplecov-html (~> 0.11)
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)
120
+ power_assert
121
+ test-unit-rr (1.0.5)
122
+ rr (>= 1.1.1)
123
+ test-unit (>= 2.5.2)
124
+ tzinfo (2.0.6)
125
+ concurrent-ruby (~> 1.0)
126
+ tzinfo-data (1.2023.3)
127
+ tzinfo (>= 1.0.0)
128
+ unf (0.1.4)
129
+ unf_ext
130
+ unf_ext (0.0.8.2)
131
+ unicode-display_width (2.2.0)
132
+ vcr (6.0.0)
133
+ webmock (3.14.0)
134
+ addressable (>= 2.8.0)
135
+ crack (>= 0.3.2)
136
+ hashdiff (>= 0.4.0, < 2.0.0)
137
+ webrick (1.8.1)
138
+ yajl-ruby (1.4.3)
139
+
140
+ PLATFORMS
141
+ ruby
142
+
143
+ DEPENDENCIES
144
+ bump
145
+ bundler (~> 2.0)
146
+ codeclimate-test-reporter (< 1.0.0)
147
+ copyright-header
148
+ fluent-plugin-kubernetes_metadata_filter!
149
+ minitest (~> 4.0)
150
+ rake
151
+ rubocop
152
+ test-unit (~> 3.5.5)
153
+ test-unit-rr (~> 1.0.3)
154
+ vcr
155
+ webmock
156
+ yajl-ruby
157
+
158
+ BUNDLED WITH
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,8 @@ 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 |
20
+ | >= 2.5.0 | >= v1.10.0 | >= 2.5 |
18
21
  | >= 2.0.0 | >= v0.14.20 | >= 2.1 |
19
22
  | < 2.0.0 | >= v0.12.0 | >= 1.9 |
20
23
 
@@ -38,73 +41,70 @@ Configuration options for fluent.conf are:
38
41
  * `client_key` - path to a client key file to authenticate to the API server
39
42
  * `bearer_token_file` - path to a file containing the bearer token to use for authentication
40
43
  * `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 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)`
42
45
  * `cache_size` - size of the cache of Kubernetes metadata to reduce requests to the API server (default: `1000`)
43
46
  * `cache_ttl` - TTL in seconds of each cached element. Set to negative value to disable TTL eviction (default: `3600` - 1 hour)
44
47
  * `watch` - set up a watch on pods on the API server for updates to metadata (default: `true`)
45
- * `de_dot` - replace dots in labels and annotations with configured `de_dot_separator`, required for ElasticSearch 2.x compatibility (default: `true`)
46
- * `de_dot_separator` - separator to use if `de_dot` is enabled (default: `_`)
47
- * `use_journal` - If false (default), 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.
48
- * `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>[^_]+)_[^_]+_[^_]+$'`
49
- * This corresponds to the definition [in the source](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/dockertools/docker.go#L317)
50
48
  * `annotation_match` - Array of regular expressions matching annotation field names. Matched annotations are added to a log record.
51
49
  * `allow_orphans` - Modify the namespace and namespace id to the values of `orphaned_namespace_name` and `orphaned_namespace_id`
52
50
  when true (default: `true`)
53
51
  * `orphaned_namespace_name` - The namespace to associate with records where the namespace can not be determined (default: `.orphaned`)
54
52
  * `orphaned_namespace_id` - The namespace id to associate with records where the namespace can not be determined (default: `orphaned`)
53
+ * `lookup_from_k8s_field` - If the field `kubernetes` is present, lookup the metadata from the given subfields such as `kubernetes.namespace_name`, `kubernetes.pod_name`, etc. This allows you to avoid having to pass in metadata to lookup in an explicitly formatted tag name or in an explicitly formatted `CONTAINER_NAME` value. For example, set `kubernetes.namespace_name`, `kubernetes.pod_name`, `kubernetes.container_name`, and `docker.id` in the record, and the filter will fill in the rest. (default: `true`)
54
+ * `ssl_partial_chain` - if `ca_file` is for an intermediate CA, or otherwise we do not have the root CA and want
55
+ to trust the intermediate CA certs we do have, set this to `true` - this corresponds to
56
+ the `openssl s_client -partial_chain` flag and `X509_V_FLAG_PARTIAL_CHAIN` (default: `false`)
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.
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.
61
+ * `skip_master_url` - Skip the master_url field from the metadata.
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.
63
+ * `stats_interval` - The interval to display cache stats (default: 30s). Set to 0 to disable stats collection and logging
64
+ * `watch_retry_interval` - The time interval in seconds for retry backoffs when watch connections fail. (default: `10`)
65
+ * `open_timeout` - The time in seconds to wait for a connection to kubernetes service. (default: `3`)
66
+ * `read_timeout` - The time in seconds to wait for a read from kubernetes service. (default: `10`)
67
+ * `include_ownerrefs_metadata` - If set to true, it will include metadata (`kind` & `name`) in `kubernetes.ownerrefs` about the controller that owns the pod. (default: `false`)
68
+
69
+
70
+ 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":
55
71
 
56
- **NOTE:** As of the release 1.1.x of this plugin, it no longer supports parsing the source message into JSON and attaching it to the
57
- payload. The following configuration options are removed:
58
-
59
- * `merge_json_log`
60
- * `preserve_json_log`
72
+ ```
73
+ fluent-gem install fluent-plugin-multi-format-parser
74
+ ```
61
75
 
62
- Reading from the JSON formatted log files with `in_tail` and wildcard filenames:
76
+ The config block could look like this:
63
77
  ```
64
78
  <source>
65
- type tail
79
+ @type tail
66
80
  path /var/log/containers/*.log
67
81
  pos_file fluentd-docker.pos
68
- time_format %Y-%m-%dT%H:%M:%S
69
- tag kubernetes.*
70
- format json
71
82
  read_from_head true
83
+ tag kubernetes.*
84
+ <parse>
85
+ @type multi_format
86
+ <pattern>
87
+ format json
88
+ time_key time
89
+ time_type string
90
+ time_format "%Y-%m-%dT%H:%M:%S.%NZ"
91
+ keep_time_key false
92
+ </pattern>
93
+ <pattern>
94
+ format regexp
95
+ expression /^(?<time>.+) (?<stream>stdout|stderr)( (?<logtag>.))? (?<log>.*)$/
96
+ time_format '%Y-%m-%dT%H:%M:%S.%N%:z'
97
+ keep_time_key false
98
+ </pattern>
99
+ </parse>
72
100
  </source>
73
101
 
74
102
  <filter kubernetes.var.log.containers.**.log>
75
- type kubernetes_metadata
103
+ @type kubernetes_metadata
76
104
  </filter>
77
105
 
78
106
  <match **>
79
- type stdout
80
- </match>
81
- ```
82
-
83
- 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):
84
- ```
85
- <source>
86
- type systemd
87
- path /run/log/journal
88
- pos_file journal.pos
89
- tag journal
90
- read_from_head true
91
- </source>
92
-
93
- # probably want to use something like fluent-plugin-rewrite-tag-filter to
94
- # retag entries from k8s
95
- <match journal>
96
- @type rewrite_tag_filter
97
- rewriterule1 CONTAINER_NAME ^k8s_ kubernetes.journal.container
98
- ...
99
- </match>
100
-
101
- <filter kubernetes.**>
102
- type kubernetes_metadata
103
- use_journal true
104
- </filter>
105
-
106
- <match **>
107
- type stdout
107
+ @type stdout
108
108
  </match>
109
109
  ```
110
110
 
@@ -150,6 +150,7 @@ Then output becomes as belows
150
150
  "host": "jimmi-redhat.localnet",
151
151
  "pod_name":"fabric8-console-controller-98rqc",
152
152
  "pod_id": "c76927af-f563-11e4-b32d-54ee7527188d",
153
+ "pod_ip": "172.17.0.8",
153
154
  "container_name": "fabric8-console-container",
154
155
  "namespace_name": "default",
155
156
  "namespace_id": "23437884-8e08-4d95-850b-e94378c9b2fd",
@@ -166,18 +167,6 @@ Then output becomes as belows
166
167
  }
167
168
  ```
168
169
 
169
- If using journal input, from docker configured with `--log-driver=journald`, the input looks like the `journalctl -o export` format:
170
- ```
171
- # The stream identification is encoded into the PRIORITY field as an
172
- # integer: 6, or github.com/coreos/go-systemd/journal.Info, marks stdout,
173
- # while 3, or github.com/coreos/go-systemd/journal.Err, marks stderr.
174
- PRIORITY=6
175
- CONTAINER_ID=b6cbb6e73c0a
176
- CONTAINER_ID_FULL=b6cbb6e73c0ad63ab820e4baa97cdc77cec729930e38a714826764ac0491341a
177
- CONTAINER_NAME=k8s_registry.a49f5318_docker-registry-1-hhoj0_default_ae3a9bdc-1f66-11e6-80a2-fa163e2fff3a_799e4035
178
- MESSAGE=172.17.0.1 - - [21/May/2016:16:52:05 +0000] "GET /healthz HTTP/1.1" 200 0 "" "Go-http-client/1.1"
179
- ```
180
-
181
170
  ## Contributing
182
171
 
183
172
  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
+