fluent-plugin-append-kubernetes-labels-to-tag 0.0.3.pre.alpha
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/Gemfile +4 -0
- data/README.md +82 -0
- data/fluent-plugin-append-kubernetes-labels-to-tag.gemspec +27 -0
- data/lib/fluent/plugin/out_append_kubernetes_labels_to_tag.rb +56 -0
- data/lib/kubernetes_labels_tag_appender.rb +11 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d602ea7eaa8877d426625953e8c11f3e6566cc32
|
4
|
+
data.tar.gz: 1df90ca64bb93776798d7bd9a0cc4f9740a66512
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ca56fd4db82c6c89b4e1f7474c29c36e88e49287d7c5f3d7775e27a17b1e2d4d841952bc222fac46ca82b5a4873ee85531ed5c1224ae46bca34d17412e6866f1
|
7
|
+
data.tar.gz: 50ba90c933aab253c6a911e00b99aff0072fc2fbe35600e5a87e58e5626b4d8228989ac11ce0193a9efecb6423877215858b5159e76b6fe2611cef6440753946
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# fluent-plugin-append_kubernetes_labels_to_tag
|
2
|
+
|
3
|
+
## A Fluent plugin to add kubernetes container labels to the log tag
|
4
|
+
|
5
|
+
## Prerequisites
|
6
|
+
|
7
|
+
This plugin is intended for use with the [kuberenetes_metadata_filter](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter) plugin. You will need to filter with `kubernetes_metadata_filter` so that your log records have the `kubernetes` attribute loaded with the required data.
|
8
|
+
|
9
|
+
## TODO
|
10
|
+
|
11
|
+
### Open source this gem
|
12
|
+
* [x] Stop relying on a Redbubble-owned Docker image for the build
|
13
|
+
* [ ] Publish to Rubygems.org
|
14
|
+
* [ ] Make repo public
|
15
|
+
* [ ] Use Travis for public CI?
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
In your Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'fluent-plugin-append-kubernetes-labels-to-tag'
|
23
|
+
```
|
24
|
+
|
25
|
+
In your Fluent config:
|
26
|
+
|
27
|
+
```
|
28
|
+
<filter **>
|
29
|
+
@type kubernetes_metadata_filter # See 'Prerequisites' above
|
30
|
+
|
31
|
+
...
|
32
|
+
|
33
|
+
</filter>
|
34
|
+
|
35
|
+
<filter **>
|
36
|
+
@type append_kubernetes_labels_to_tag
|
37
|
+
|
38
|
+
labels label1,label2
|
39
|
+
</filter>
|
40
|
+
```
|
41
|
+
|
42
|
+
## Contributions
|
43
|
+
|
44
|
+
Contributions are welcome! Please feel free to open issues or pull requests to get help or discuss ideas or implementations. Note that opening pull requests with work in progress is not only welcome, but encouraged! Talk early, talk often, and we will all learn in the way :)
|
45
|
+
|
46
|
+
Finally, please note that this project is released with a [Contributor Code of Conduct][coc]. By participating in this project you agree to abide by its terms.
|
47
|
+
|
48
|
+
[coc]: ./CODE_OF_CONDUCT.md
|
49
|
+
|
50
|
+
## Credits
|
51
|
+
|
52
|
+
[][redbubble]
|
53
|
+
|
54
|
+
`fluent-plugin-append_kubernetes_labels_to_tag` is maintained and funded by [Redbubble][redbubble].
|
55
|
+
|
56
|
+
[redbubble]: https://www.redbubble.com
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
fluent-plugin-append_kubernetes_labels_to_tag
|
61
|
+
|
62
|
+
Copyright (C) 2017 Redbubble
|
63
|
+
|
64
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
65
|
+
a copy of this software and associated documentation files (the
|
66
|
+
"Software"), to deal in the Software without restriction, including
|
67
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
68
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
69
|
+
permit persons to whom the Software is furnished to do so, subject to
|
70
|
+
the following conditions:
|
71
|
+
|
72
|
+
The above copyright notice and this permission notice shall be included
|
73
|
+
in all copies or substantial portions of the Software.
|
74
|
+
|
75
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
76
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
77
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
78
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
79
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
80
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
81
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
82
|
+
|
@@ -0,0 +1,27 @@
|
|
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-append-kubernetes-labels-to-tag"
|
7
|
+
gem.version = "0.0.3-alpha"
|
8
|
+
gem.authors = ["Redbubble Delivery Engineering Team"]
|
9
|
+
gem.email = ["delivery-engineers@redbubble.com"]
|
10
|
+
gem.description = %q{Filter plugin to append certain Kubernetes labels to the Fluentd tag}
|
11
|
+
gem.summary = %q{Filter plugin to append certain Kubernetes labels to the Fluentd tag}
|
12
|
+
gem.homepage = "https://github.com/redbubble/fluent-plugin-append_kubernetes_labels_to_tag"
|
13
|
+
gem.license = "MIT"
|
14
|
+
|
15
|
+
gem.files = Dir['lib/**/*'] + %w(Gemfile README.md fluent-plugin-append-kubernetes-labels-to-tag.gemspec)
|
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
|
+
|
25
|
+
gem.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
gem.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'fluent/output'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class Fluent::AppendKubernetesLabelsToTag < Fluent::Output
|
5
|
+
Fluent::Plugin.register_output('append_kubernetes_labels_to_tag', self)
|
6
|
+
|
7
|
+
config_param :labels, :string
|
8
|
+
|
9
|
+
def configure(conf)
|
10
|
+
super
|
11
|
+
|
12
|
+
@labels = conf['labels'].split(',')
|
13
|
+
end
|
14
|
+
|
15
|
+
def emit(tag, es, chain)
|
16
|
+
es.each do |time, record|
|
17
|
+
events(tag, time, record).each do |(tag, time, record)|
|
18
|
+
router.emit(tag, time, record)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
chain.next
|
23
|
+
|
24
|
+
rescue
|
25
|
+
log.error "Failed to re-format docker record #{record}"
|
26
|
+
# this seems to be a way to safely swallow records we don't know how to format
|
27
|
+
""
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def events(tag, time, record)
|
33
|
+
[
|
34
|
+
event(tag, time, record)
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
def event(tag, time, record)
|
39
|
+
new_tag = if record.has_key? 'kubernetes' && record['kubernetes'].has_key? 'labels'
|
40
|
+
kubernetes_labels_tag_appender.append(tag, record['kubernetes']['labels'])
|
41
|
+
else
|
42
|
+
tag
|
43
|
+
end
|
44
|
+
|
45
|
+
[
|
46
|
+
new_tag,
|
47
|
+
time,
|
48
|
+
record
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
52
|
+
def kubernetes_labels_tag_appender
|
53
|
+
@kubernetes_labels_tag_appender ||= KubernetesLabelsTagAppender.new(@labels)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-append-kubernetes-labels-to-tag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3.pre.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Redbubble Delivery Engineering Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.12.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.12.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Filter plugin to append certain Kubernetes labels to the Fluentd tag
|
56
|
+
email:
|
57
|
+
- delivery-engineers@redbubble.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- README.md
|
64
|
+
- fluent-plugin-append-kubernetes-labels-to-tag.gemspec
|
65
|
+
- lib/fluent/plugin/out_append_kubernetes_labels_to_tag.rb
|
66
|
+
- lib/kubernetes_labels_tag_appender.rb
|
67
|
+
homepage: https://github.com/redbubble/fluent-plugin-append_kubernetes_labels_to_tag
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.0.0
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.3.1
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.6.11
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Filter plugin to append certain Kubernetes labels to the Fluentd tag
|
91
|
+
test_files: []
|