fluent-plugin-kubernetes_metadata_filter_splunk 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/config.yml +56 -0
- data/.gitignore +20 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +201 -0
- data/README.md +209 -0
- data/Rakefile +37 -0
- data/fluent-plugin-kubernetes_metadata_filter.gemspec +36 -0
- data/lib/fluent/plugin/filter_kubernetes_metadata.rb +446 -0
- data/lib/fluent/plugin/kubernetes_metadata_cache_strategy.rb +98 -0
- data/lib/fluent/plugin/kubernetes_metadata_common.rb +113 -0
- data/lib/fluent/plugin/kubernetes_metadata_stats.rb +46 -0
- data/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb +65 -0
- data/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb +68 -0
- data/test/cassettes/invalid_api_server_config.yml +53 -0
- data/test/cassettes/kubernetes_docker_metadata.yml +228 -0
- data/test/cassettes/kubernetes_docker_metadata_annotations.yml +239 -0
- data/test/cassettes/kubernetes_docker_metadata_dotted_labels.yml +231 -0
- data/test/cassettes/kubernetes_docker_metadata_using_bearer_token.yml +248 -0
- data/test/cassettes/kubernetes_get_api_v1.yml +193 -0
- data/test/cassettes/kubernetes_get_api_v1_using_token.yml +195 -0
- data/test/cassettes/kubernetes_get_namespace_default.yml +69 -0
- data/test/cassettes/kubernetes_get_namespace_default_using_token.yml +71 -0
- data/test/cassettes/kubernetes_get_pod.yml +146 -0
- data/test/cassettes/kubernetes_get_pod_using_token.yml +148 -0
- data/test/cassettes/metadata_from_tag_and_journald_fields.yml +408 -0
- data/test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml +540 -0
- data/test/cassettes/metadata_with_namespace_id.yml +276 -0
- data/test/cassettes/non_kubernetes_docker_metadata.yml +97 -0
- data/test/cassettes/valid_kubernetes_api_server.yml +55 -0
- data/test/cassettes/valid_kubernetes_api_server_using_token.yml +57 -0
- data/test/helper.rb +64 -0
- data/test/plugin/test.token +1 -0
- data/test/plugin/test_cache_stats.rb +36 -0
- data/test/plugin/test_cache_strategy.rb +196 -0
- data/test/plugin/test_filter_kubernetes_metadata.rb +970 -0
- data/test/plugin/test_watch_namespaces.rb +91 -0
- data/test/plugin/test_watch_pods.rb +145 -0
- data/test/plugin/watch_test.rb +57 -0
- metadata +295 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbd674163f0ced73de0edcc80fe6ecb006277867922692defe2eb0e4a29bfcf5
|
4
|
+
data.tar.gz: fdf3c253e7d9e03b006251d5e61a1423b0f5016f1358e1f56976a653a8fa309b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4c3368b40e3d95c93022350bddc52319d4c79bafbd11c8c7a214ca3418554b29f9fe7293a5f4992e6fe57f434776b3f348a1f33042e87565d53c0bd0be996c7
|
7
|
+
data.tar.gz: b5538513ca0b1682d30663e553198d75905d0f1283985145e579a722fd2528bad2791f2f28a2b563ee0860c899c8810997c540e13568db3e75695abe4f11d7a4
|
@@ -0,0 +1,56 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
install: &install
|
4
|
+
name: Install bundle
|
5
|
+
command: bundle install --path vendor/bundle
|
6
|
+
|
7
|
+
missingdeps: &missingdeps
|
8
|
+
name: Install missing dependecies
|
9
|
+
command: |
|
10
|
+
cat /etc/os-release
|
11
|
+
printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /tmp/sources.list
|
12
|
+
sudo cp /tmp/sources.list /etc/apt/sources.list
|
13
|
+
sudo apt-get update
|
14
|
+
sudo apt-get install cmake libicu-dev libssl-dev
|
15
|
+
|
16
|
+
test: &test
|
17
|
+
name: Test bundle
|
18
|
+
command: bundle exec rake test
|
19
|
+
|
20
|
+
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
|
+
ruby-2-6:
|
28
|
+
docker:
|
29
|
+
- image: circleci/ruby:2.6.3
|
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-4
|
52
|
+
- ruby-test:
|
53
|
+
ruby-version: ruby-2-5
|
54
|
+
- ruby-test:
|
55
|
+
ruby-version: ruby-2-6
|
56
|
+
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
# fluent-plugin-kubernetes_metadata_filter, a plugin for [Fluentd](http://fluentd.org)
|
2
|
+
[](https://circleci.com/gh/fabric8io/fluent-plugin-kubernetes_metadata_filter)
|
3
|
+
[](https://codeclimate.com/github/fabric8io/fluent-plugin-kubernetes_metadata_filter)
|
4
|
+
[](https://codeclimate.com/github/fabric8io/fluent-plugin-kubernetes_metadata_filter)
|
5
|
+
|
6
|
+
The Kubernetes metadata plugin filter enriches container log records with pod and namespace metadata.
|
7
|
+
|
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
|
+
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
|
+
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
|
+
that rely on the authenticity of the namespace for proper log isolation.
|
13
|
+
|
14
|
+
## Requirements
|
15
|
+
|
16
|
+
| fluent-plugin-kubernetes_metadata_filter | fluentd | ruby |
|
17
|
+
|-------------------|---------|------|
|
18
|
+
| >= 2.0.0 | >= v0.14.20 | >= 2.1 |
|
19
|
+
| < 2.0.0 | >= v0.12.0 | >= 1.9 |
|
20
|
+
|
21
|
+
NOTE: For v0.12 version, you should use 1.x.y version. Please send patch into v0.12 branch if you encountered 1.x version's bug.
|
22
|
+
|
23
|
+
NOTE: This documentation is for fluent-plugin-kubernetes_metadata_filter-plugin-elasticsearch 2.x or later. For 1.x documentation, please see [v0.12 branch](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/tree/v0.12).
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
gem install fluent-plugin-kubernetes_metadata_filter
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
Configuration options for fluent.conf are:
|
32
|
+
|
33
|
+
* `kubernetes_url` - URL to the API server. Set this to retrieve further kubernetes metadata for logs from kubernetes API server. If not specified, environment variables `KUBERNETES_SERVICE_HOST` and `KUBERNETES_SERVICE_PORT` will be used if both are present which is typically true when running fluentd in a pod.
|
34
|
+
* `apiVersion` - API version to use (default: `v1`)
|
35
|
+
* `ca_file` - path to CA file for Kubernetes server certificate validation
|
36
|
+
* `verify_ssl` - validate SSL certificates (default: `true`)
|
37
|
+
* `client_cert` - path to a client cert file to authenticate to the API server
|
38
|
+
* `client_key` - path to a client key file to authenticate to the API server
|
39
|
+
* `bearer_token_file` - path to a file containing the bearer token to use for authentication
|
40
|
+
* `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>)`)
|
42
|
+
* `cache_size` - size of the cache of Kubernetes metadata to reduce requests to the API server (default: `1000`)
|
43
|
+
* `cache_ttl` - TTL in seconds of each cached element. Set to negative value to disable TTL eviction (default: `3600` - 1 hour)
|
44
|
+
* `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
|
+
* *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
|
+
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 (default: `'^(?<name_prefix>[^_]+)_(?<container_name>[^\._]+)(\.(?<container_hash>[^_]+))?_(?<pod_name>[^_]+)_(?<namespace>[^_]+)_[^_]+_[^_]+$'`
|
50
|
+
* This corresponds to the definition [in the source](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/dockertools/docker.go#L317)
|
51
|
+
* `annotation_match` - Array of regular expressions matching annotation field names. Matched annotations are added to a log record.
|
52
|
+
* `allow_orphans` - Modify the namespace and namespace id to the values of `orphaned_namespace_name` and `orphaned_namespace_id`
|
53
|
+
when true (default: `true`)
|
54
|
+
* `orphaned_namespace_name` - The namespace to associate with records where the namespace can not be determined (default: `.orphaned`)
|
55
|
+
* `orphaned_namespace_id` - The namespace id to associate with records where the namespace can not be determined (default: `orphaned`)
|
56
|
+
* `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`)
|
57
|
+
* `ssl_partial_chain` - if `ca_file` is for an intermediate CA, or otherwise we do not have the root CA and want
|
58
|
+
to trust the intermediate CA certs we do have, set this to `true` - this corresponds to
|
59
|
+
the `openssl s_client -partial_chain` flag and `X509_V_FLAG_PARTIAL_CHAIN` (default: `false`)
|
60
|
+
* `skip_labels` - Skip all label fields from the metadata.
|
61
|
+
* `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
|
+
* `skip_master_url` - Skip the master_url field from the metadata.
|
63
|
+
* `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.
|
64
|
+
**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
|
65
|
+
payload. The following configuration options are removed:
|
66
|
+
|
67
|
+
* `merge_json_log`
|
68
|
+
* `preserve_json_log`
|
69
|
+
|
70
|
+
**NOTE** As of this release, the use of `use_journal` is **DEPRECATED**. If this setting is not present, the plugin will
|
71
|
+
attempt to figure out the source of the metadata fields from the following:
|
72
|
+
- If `lookup_from_k8s_field true` (the default) and the following fields are present in the record:
|
73
|
+
`docker.container_id`, `kubernetes.namespace_name`, `kubernetes.pod_name`, `kubernetes.container_name`,
|
74
|
+
then the plugin will use those values as the source to use to lookup the metadata
|
75
|
+
- If `use_journal true`, or `use_journal` is unset, and the fields `CONTAINER_NAME` and `CONTAINER_ID_FULL` are present in the record,
|
76
|
+
then the plugin will parse those values using `container_name_to_kubernetes_regexp` and use those as the source to lookup the metadata
|
77
|
+
- Otherwise, if the tag matches `tag_to_kubernetes_name_regexp`, the plugin will parse the tag and use those values to
|
78
|
+
lookup the metdata
|
79
|
+
|
80
|
+
Reading from the JSON formatted log files with `in_tail` and wildcard filenames:
|
81
|
+
```
|
82
|
+
<source>
|
83
|
+
@type tail
|
84
|
+
path /var/log/containers/*.log
|
85
|
+
pos_file fluentd-docker.pos
|
86
|
+
time_format %Y-%m-%dT%H:%M:%S
|
87
|
+
tag kubernetes.*
|
88
|
+
format json
|
89
|
+
read_from_head true
|
90
|
+
</source>
|
91
|
+
|
92
|
+
<filter kubernetes.var.log.containers.**.log>
|
93
|
+
@type kubernetes_metadata
|
94
|
+
</filter>
|
95
|
+
|
96
|
+
<match **>
|
97
|
+
@type stdout
|
98
|
+
</match>
|
99
|
+
```
|
100
|
+
|
101
|
+
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):
|
102
|
+
```
|
103
|
+
<source>
|
104
|
+
@type systemd
|
105
|
+
path /run/log/journal
|
106
|
+
pos_file journal.pos
|
107
|
+
tag journal
|
108
|
+
read_from_head true
|
109
|
+
</source>
|
110
|
+
|
111
|
+
# probably want to use something like fluent-plugin-rewrite-tag-filter to
|
112
|
+
# retag entries from k8s
|
113
|
+
<match journal>
|
114
|
+
@type rewrite_tag_filter
|
115
|
+
rewriterule1 CONTAINER_NAME ^k8s_ kubernetes.journal.container
|
116
|
+
...
|
117
|
+
</match>
|
118
|
+
|
119
|
+
<filter kubernetes.**>
|
120
|
+
@type kubernetes_metadata
|
121
|
+
use_journal true
|
122
|
+
</filter>
|
123
|
+
|
124
|
+
<match **>
|
125
|
+
@type stdout
|
126
|
+
</match>
|
127
|
+
```
|
128
|
+
|
129
|
+
## Environment variables for Kubernetes
|
130
|
+
|
131
|
+
If the name of the Kubernetes node the plugin is running on is set as
|
132
|
+
an environment variable with the name `K8S_NODE_NAME`, it will reduce cache
|
133
|
+
misses and needless calls to the Kubernetes API.
|
134
|
+
|
135
|
+
In the Kubernetes container definition, this is easily accomplished by:
|
136
|
+
|
137
|
+
```yaml
|
138
|
+
env:
|
139
|
+
- name: K8S_NODE_NAME
|
140
|
+
valueFrom:
|
141
|
+
fieldRef:
|
142
|
+
fieldPath: spec.nodeName
|
143
|
+
```
|
144
|
+
|
145
|
+
## Example input/output
|
146
|
+
|
147
|
+
Kubernetes creates symlinks to Docker log files in `/var/log/containers/*.log`. Docker logs in JSON format.
|
148
|
+
|
149
|
+
Assuming following inputs are coming from a log file named `/var/log/containers/fabric8-console-controller-98rqc_default_fabric8-console-container-df14e0d5ae4c07284fa636d739c8fc2e6b52bc344658de7d3f08c36a2e804115.log`:
|
150
|
+
|
151
|
+
```
|
152
|
+
{
|
153
|
+
"log": "2015/05/05 19:54:41 \n",
|
154
|
+
"stream": "stderr",
|
155
|
+
"time": "2015-05-05T19:54:41.240447294Z"
|
156
|
+
}
|
157
|
+
```
|
158
|
+
|
159
|
+
Then output becomes as belows
|
160
|
+
```
|
161
|
+
{
|
162
|
+
"log": "2015/05/05 19:54:41 \n",
|
163
|
+
"stream": "stderr",
|
164
|
+
"docker": {
|
165
|
+
"id": "df14e0d5ae4c07284fa636d739c8fc2e6b52bc344658de7d3f08c36a2e804115",
|
166
|
+
}
|
167
|
+
"kubernetes": {
|
168
|
+
"host": "jimmi-redhat.localnet",
|
169
|
+
"pod_name":"fabric8-console-controller-98rqc",
|
170
|
+
"pod_id": "c76927af-f563-11e4-b32d-54ee7527188d",
|
171
|
+
"container_name": "fabric8-console-container",
|
172
|
+
"namespace_name": "default",
|
173
|
+
"namespace_id": "23437884-8e08-4d95-850b-e94378c9b2fd",
|
174
|
+
"namespace_annotations": {
|
175
|
+
"fabric8.io/git-commit": "5e1116f63df0bac2a80bdae2ebdc563577bbdf3c"
|
176
|
+
},
|
177
|
+
"namespace_labels": {
|
178
|
+
"product_version": "v1.0.0"
|
179
|
+
},
|
180
|
+
"labels": {
|
181
|
+
"component": "fabric8Console"
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
```
|
186
|
+
|
187
|
+
If using journal input, from docker configured with `--log-driver=journald`, the input looks like the `journalctl -o export` format:
|
188
|
+
```
|
189
|
+
# The stream identification is encoded into the PRIORITY field as an
|
190
|
+
# integer: 6, or github.com/coreos/go-systemd/journal.Info, marks stdout,
|
191
|
+
# while 3, or github.com/coreos/go-systemd/journal.Err, marks stderr.
|
192
|
+
PRIORITY=6
|
193
|
+
CONTAINER_ID=b6cbb6e73c0a
|
194
|
+
CONTAINER_ID_FULL=b6cbb6e73c0ad63ab820e4baa97cdc77cec729930e38a714826764ac0491341a
|
195
|
+
CONTAINER_NAME=k8s_registry.a49f5318_docker-registry-1-hhoj0_default_ae3a9bdc-1f66-11e6-80a2-fa163e2fff3a_799e4035
|
196
|
+
MESSAGE=172.17.0.1 - - [21/May/2016:16:52:05 +0000] "GET /healthz HTTP/1.1" 200 0 "" "Go-http-client/1.1"
|
197
|
+
```
|
198
|
+
|
199
|
+
## Contributing
|
200
|
+
|
201
|
+
1. Fork it
|
202
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
203
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
204
|
+
4. Test it (`GEM_HOME=vendor bundle install; GEM_HOME=vendor bundle exec rake test`)
|
205
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
206
|
+
6. Create new Pull Request
|
207
|
+
|
208
|
+
## Copyright
|
209
|
+
Copyright (c) 2015 jimmidyson
|