fluent-plugin-append-kubernetes-annotations-to-tag 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a7d7bf1ee7d6e83c8498d8ed86d796b4492e084
|
4
|
+
data.tar.gz: 5a20e6cb091a67753c4d6d20132f63781286b849
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e690ee2964acd86afec3510050a84d2a848628115427022180b678f16e196cdb3dace67380fa57d52f8eea7cb9440e4979b62c19f07dc073c86c455ac2f9b8d
|
7
|
+
data.tar.gz: fe6b96d2247791be76405b8633a49e7a3601eeb20211c3e1dc82e50cb99aba13024fb5f75e0b48b646a505829e32ecd694ec06b6a0cfdfe6faa01664c5b85e8f
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# fluent-plugin-append_kubernetes_annotations_to_tag
|
2
|
+
|
3
|
+
## A Fluent plugin to add kubernetes container annotations 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
|
+
* [ ] Stop relying on a Redbubble-owned Docker image for the build
|
13
|
+
* [ ] Publish to Rubygems.org
|
14
|
+
* [ ] Make repo public
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
In your Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'fluent-plugin-append-kubernetes-annotations-to-tag'
|
22
|
+
```
|
23
|
+
|
24
|
+
In your Fluent config:
|
25
|
+
|
26
|
+
```
|
27
|
+
<filter **>
|
28
|
+
@type kubernetes_metadata_filter # See 'Prerequisites' above
|
29
|
+
|
30
|
+
...
|
31
|
+
|
32
|
+
</filter>
|
33
|
+
|
34
|
+
<filter **>
|
35
|
+
@type append_kubernetes_annotations_to_tag
|
36
|
+
|
37
|
+
annotations ['log_destination']
|
38
|
+
</filter>
|
39
|
+
```
|
40
|
+
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
If you would like to contribute a fix or feature, here's what you should do:
|
45
|
+
|
46
|
+
1. Raise an issue so we can discuss your change, and be sure you're not wasting your time
|
47
|
+
1. Fork this repo (optional if you are a Redbubble engineer)
|
48
|
+
2. Make your changes
|
49
|
+
3. Submit a pull request
|
50
|
+
|
51
|
+
## Maintainers
|
52
|
+
|
53
|
+
delivery-engineers@redbubble.com
|
54
|
+
|
55
|
+
|
56
|
+
Copyright (c) Redbubble 2017. All rights reserved.
|
@@ -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-annotations-to-tag"
|
7
|
+
gem.version = "0.0.1"
|
8
|
+
gem.authors = ["Redbubble Delivery Engineering Team"]
|
9
|
+
gem.email = ["delivery-engineers@redbubble.com"]
|
10
|
+
gem.description = %q{Filter plugin to append certain Kubernetes annotations to the Fluentd tag}
|
11
|
+
gem.summary = %q{Filter plugin to append certain Kubernetes annotations to the Fluentd tag}
|
12
|
+
gem.homepage = "https://github.com/redbubble/fluent-plugin-append_kubernetes_annotations_to_tag"
|
13
|
+
gem.license = "Copyright (c) Redbubble 2017. All rights reserved."
|
14
|
+
|
15
|
+
gem.files = Dir['lib/**/*'] + %w(Gemfile README.md fluent-plugin-append-kubernetes-annotations-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::AppendKubernetesAnnotationsToTag < Fluent::Output
|
5
|
+
Fluent::Plugin.register_output('append_kubernetes_annotations_to_tag', self)
|
6
|
+
|
7
|
+
config_param :annotations, :string
|
8
|
+
|
9
|
+
def configure(conf)
|
10
|
+
super
|
11
|
+
|
12
|
+
@annotations = conf['annotations'].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? 'annotations'
|
40
|
+
kubernetes_annotations_tag_appender.append(tag, record['kubernetes']['annotations'])
|
41
|
+
else
|
42
|
+
tag
|
43
|
+
end
|
44
|
+
|
45
|
+
[
|
46
|
+
new_tag,
|
47
|
+
time,
|
48
|
+
record
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
52
|
+
def kubernetes_annotations_tag_appender
|
53
|
+
@kubernetes_annotations_tag_appender ||= KubernetesAnnotationsTagAppender.new(@annotations)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-append-kubernetes-annotations-to-tag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Redbubble Delivery Engineering Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-27 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 annotations to the Fluentd
|
56
|
+
tag
|
57
|
+
email:
|
58
|
+
- delivery-engineers@redbubble.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- Gemfile
|
64
|
+
- README.md
|
65
|
+
- fluent-plugin-append-kubernetes-annotations-to-tag.gemspec
|
66
|
+
- lib/fluent/plugin/out_append_kubernetes_annotations_to_tag.rb
|
67
|
+
- lib/kubernetes_annotations_tag_appender.rb
|
68
|
+
homepage: https://github.com/redbubble/fluent-plugin-append_kubernetes_annotations_to_tag
|
69
|
+
licenses:
|
70
|
+
- Copyright (c) Redbubble 2017. All rights reserved.
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.0.0
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.6.13
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Filter plugin to append certain Kubernetes annotations to the Fluentd tag
|
92
|
+
test_files: []
|