fluent-plugin-kubernetes_metadata_filter_v0.14 0.24.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c99456f8d62386a9ff9479a4222215dfc3609bdc
4
+ data.tar.gz: 460ab7d92063ec9997716a168c4ed97e9104c815
5
+ SHA512:
6
+ metadata.gz: 971dbe702ce028469f0c8c82186fd680181927ae24ae907946bc7f4ff71816170d97b6e6811c678fc4b5a19b59648ce2299dc6629d6a665a8cef1d03f9b30164
7
+ data.tar.gz: 37f5d6425326e99d18a12ce5e500e0ae5f446657089d9c6ce5ea042be41004f4bc4bc8752888fd208a56b96eded674831ce53cee6b334f7c1b00d11abb22aa5d
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea/
19
+ *.iml
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'codeclimate-test-reporter', :group => :test, :require => nil
4
+ gem 'rubocop', require: false
5
+
6
+ # Specify your gem's dependencies in fluent-plugin-add.gemspec
7
+ gemspec
@@ -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.
@@ -0,0 +1,141 @@
1
+ # fluent-plugin-kubernetes_metadata_filter, a plugin for [Fluentd](http://fluentd.org)
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
+ [![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
+ [![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
+
6
+ ## Installation
7
+
8
+ gem install fluent-plugin-kubernetes_metadata_filter
9
+
10
+ ## Configuration
11
+
12
+ Configuration options for fluent.conf are:
13
+
14
+ * `kubernetes_url` - URL to the API server. Set this to retrieve further kubernetes metadata for logs from kubernetes API server
15
+ * `apiVersion` - API version to use (default: `v1`)
16
+ * `ca_file` - path to CA file for Kubernetes server certificate validation
17
+ * `verify_ssl` - validate SSL certificates (default: `true`)
18
+ * `client_cert` - path to a client cert file to authenticate to the API server
19
+ * `client_key` - path to a client key file to authenticate to the API server
20
+ * `bearer_token_file` - path to a file containing the bearer token to use for authentication
21
+ * `tag_to_kubernetes_name_regexp` - the regular expression used to extract kubernetes metadata (pod name, container name, namespace) from the current fluentd tag.
22
+ 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>)`)
23
+ * `cache_size` - size of the cache of Kubernetes metadata to reduce requests to the API server (default: `1000`)
24
+ * `cache_ttl` - TTL in seconds of each cached element. Set to negative value to disable TTL eviction (default: `3600` - 1 hour)
25
+ * `watch` - set up a watch on pods on the API server for updates to metadata (default: `true`)
26
+ * `merge_json_log` - merge logs in JSON format as top level keys (default: `true`)
27
+ * `preserve_json_log` - preserve JSON logs in raw form in the `log` key, only used if the previous option is true (default: `true`)
28
+ * `de_dot` - replace dots in labels with configured `de_dot_separator`, required for ElasticSearch 2.x compatibility (default: `true`)
29
+ * `de_dot_separator` - separator to use if `de_dot` is enabled (default: `_`)
30
+ * `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.
31
+ * `container_name_to_kubernetes_regexp` - The regular expression used to extract the k8s metadata encoded in the journal `CONTAINER_NAME` field (default: `'^k8s_(?<container_name>[^\.]+)\.(?<container_hash>[a-z0-9]{8})_(?<pod_name>[^_]+)_(?<namespace>[^_]+)_(?<pod_id>[^_]+)_(?<pod_randhex>[a-z0-9]{8})$'`)
32
+ * `annotation_match` - Array of regular expressions matching annotation field names. Matched annotations are added to a log record.
33
+
34
+ Reading from the JSON formatted log files with `in_tail` and wildcard filenames:
35
+ ```
36
+ <source>
37
+ type tail
38
+ path /var/log/containers/*.log
39
+ pos_file fluentd-docker.pos
40
+ time_format %Y-%m-%dT%H:%M:%S
41
+ tag kubernetes.*
42
+ format json
43
+ read_from_head true
44
+ </source>
45
+
46
+ <filter kubernetes.var.lib.docker.containers.*.*.log>
47
+ type kubernetes_metadata
48
+ </filter>
49
+
50
+ <match **>
51
+ type stdout
52
+ </match>
53
+ ```
54
+
55
+ 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):
56
+ ```
57
+ <source>
58
+ type systemd
59
+ path /run/log/journal
60
+ pos_file journal.pos
61
+ tag journal
62
+ read_from_head true
63
+ </source>
64
+
65
+ # probably want to use something like fluent-plugin-rewrite-tag-filter to
66
+ # retag entries from k8s
67
+ <match journal>
68
+ @type rewrite_tag_filter
69
+ rewriterule1 CONTAINER_NAME ^k8s_ kubernetes.journal.container
70
+ ...
71
+ </match>
72
+
73
+ <filter kubernetes.**>
74
+ type kubernetes_metadata
75
+ use_journal true
76
+ </filter>
77
+
78
+ <match **>
79
+ type stdout
80
+ </match>
81
+ ```
82
+
83
+ ## Example input/output
84
+
85
+ Kubernetes creates symlinks to Docker log files in `/var/log/containers/*.log`. Docker logs in JSON format.
86
+
87
+ Assuming following inputs are coming from a log file named `/var/log/containers/fabric8-console-controller-98rqc_default_fabric8-console-container-df14e0d5ae4c07284fa636d739c8fc2e6b52bc344658de7d3f08c36a2e804115.log`:
88
+
89
+ ```
90
+ {
91
+ "log": "2015/05/05 19:54:41 \n",
92
+ "stream": "stderr",
93
+ "time": "2015-05-05T19:54:41.240447294Z"
94
+ }
95
+ ```
96
+
97
+ Then output becomes as belows
98
+ ```
99
+ {
100
+ "log": "2015/05/05 19:54:41 \n",
101
+ "stream": "stderr",
102
+ "docker": {
103
+ "id": "df14e0d5ae4c07284fa636d739c8fc2e6b52bc344658de7d3f08c36a2e804115",
104
+ }
105
+ "kubernetes": {
106
+ "host": "jimmi-redhat.localnet",
107
+ "pod_name":"fabric8-console-controller-98rqc",
108
+ "pod_id": "c76927af-f563-11e4-b32d-54ee7527188d",
109
+ "container_name": "fabric8-console-container",
110
+ "namespace_name": "default",
111
+ "namespace_id": "23437884-8e08-4d95-850b-e94378c9b2fd",
112
+ "labels": {
113
+ "component": "fabric8Console"
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ If using journal input, from docker configured with `--log-driver=journald`, the input looks like the `journalctl -o export` format:
120
+ ```
121
+ # The stream identification is encoded into the PRIORITY field as an
122
+ # integer: 6, or github.com/coreos/go-systemd/journal.Info, marks stdout,
123
+ # while 3, or github.com/coreos/go-systemd/journal.Err, marks stderr.
124
+ PRIORITY=6
125
+ CONTAINER_ID=b6cbb6e73c0a
126
+ CONTAINER_ID_FULL=b6cbb6e73c0ad63ab820e4baa97cdc77cec729930e38a714826764ac0491341a
127
+ CONTAINER_NAME=k8s_registry.a49f5318_docker-registry-1-hhoj0_default_ae3a9bdc-1f66-11e6-80a2-fa163e2fff3a_799e4035
128
+ MESSAGE=172.17.0.1 - - [21/May/2016:16:52:05 +0000] "GET /healthz HTTP/1.1" 200 0 "" "Go-http-client/1.1"
129
+ ```
130
+
131
+ ## Contributing
132
+
133
+ 1. Fork it
134
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
135
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
136
+ 4. Test it (`GEM_HOME=vendor bundle install; GEM_HOME=vendor bundle exec rake test`)
137
+ 5. Push to the branch (`git push origin my-new-feature`)
138
+ 6. Create new Pull Request
139
+
140
+ ## Copyright
141
+ Copyright (c) 2015 jimmidyson
@@ -0,0 +1,37 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'bump/tasks'
4
+
5
+ task :test => [:base_test]
6
+
7
+ task :default => [:test, :build]
8
+
9
+ desc 'Run test_unit based test'
10
+ Rake::TestTask.new(:base_test) do |t|
11
+ # To run test for only one file (or file path pattern)
12
+ # $ bundle exec rake base_test TEST=test/test_specified_path.rb
13
+ # $ bundle exec rake base_test TEST=test/test_*.rb
14
+ t.libs << 'test'
15
+ t.test_files = Dir['test/**/test_*.rb'].sort
16
+ #t.verbose = true
17
+ t.warning = false
18
+ end
19
+
20
+ desc 'Add copyright headers'
21
+ task :headers do
22
+ require 'rubygems'
23
+ require 'copyright_header'
24
+
25
+ args = {
26
+ :license => 'ASL2',
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'],
31
+ :add_path => 'lib:test',
32
+ :output_dir => '.'
33
+ }
34
+
35
+ command_line = CopyrightHeader::CommandLine.new( args )
36
+ command_line.execute
37
+ end
@@ -0,0 +1,7 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.2.3
4
+
5
+ test:
6
+ override:
7
+ - bundle exec rake test
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "fluent-plugin-kubernetes_metadata_filter_v0.14"
7
+ gem.version = "0.24.1"
8
+ gem.authors = ["Jimmi Dyson"]
9
+ gem.email = ["jimmidyson@gmail.com"]
10
+ gem.description = %q{Filter plugin to add Kubernetes metadata}
11
+ gem.summary = %q{Filter plugin to add Kubernetes metadata}
12
+ gem.homepage = "https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter"
13
+ gem.license = "ASL2"
14
+
15
+ 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
+ gem.has_rdoc = false
20
+
21
+ gem.required_ruby_version = '>= 2.0.0'
22
+
23
+ gem.add_runtime_dependency "fluentd", ">= 0.12.0"
24
+ gem.add_runtime_dependency "lru_redux"
25
+ gem.add_runtime_dependency "kubeclient", "~> 1.1.4"
26
+ gem.add_runtime_dependency "fluent-plugin-docker_metadata_filter"
27
+
28
+ gem.add_development_dependency "bundler", "~> 1.3"
29
+ gem.add_development_dependency "rake"
30
+ gem.add_development_dependency "minitest", "~> 4.0"
31
+ gem.add_development_dependency "test-unit", "~> 3.0.2"
32
+ gem.add_development_dependency "test-unit-rr", "~> 1.0.3"
33
+ gem.add_development_dependency "copyright-header"
34
+ gem.add_development_dependency "webmock"
35
+ gem.add_development_dependency "vcr"
36
+ gem.add_development_dependency "bump"
37
+ gem.add_development_dependency "yajl-ruby"
38
+ end