fluent-plugin-firelens-tag-filter 0.1.0 → 0.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 +4 -4
- data/README.md +20 -1
- data/example.conf +6 -0
- data/fluent-plugin-firelens-tag-filter.gemspec +1 -1
- data/lib/fluent/plugin/out_firelens_tag_filter.rb +16 -2
- data/test/plugin/test_out_firelens_tag_filter.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fae1c8e9ddeda7c653e66a9279f5e50b1b2fa0a18022d0481775270e887f3ae3
|
4
|
+
data.tar.gz: 77a304edd71d77f8aef9219cc054f1a6a73b5ff3568900b63631d94352392591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a008fbbf4f4a2fdfee94f1cbd794ef2482f73a75a479e63f1170b75b2853253a0bdcbaefec362f3a81330e722d35bdc11faa08295b8f8f103b6c2356934d474
|
7
|
+
data.tar.gz: 668d417d2261f42a876c9175dae69cc7ce15e1ee9e51b9fa060e08e93b2ca8743e6d8676d9e3b395969a2f9702a594b2e5fa2ce422e8f4882f014034d59310e7
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
A tag of messages from AWS firelens has format like `[containerName]-firelens-[taskID]`, but a tag of fluentd is a string separated by dots (e.g. myapp.access) usually.
|
6
6
|
|
7
|
-
fluent-plugin-firelens-tag-filter rewrites message tags from `[containerName]-firelens-[taskID]` to `[tag_prefix].[containerName].(stdout|stderr).[taskID]
|
7
|
+
fluent-plugin-firelens-tag-filter rewrites message tags from `[containerName]-firelens-[taskID]` to `[tag_prefix].[containerName].(stdout|stderr).[taskID]` by default.
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -47,6 +47,25 @@ $ bundle
|
|
47
47
|
</match>
|
48
48
|
```
|
49
49
|
|
50
|
+
Customize `tag` format.
|
51
|
+
|
52
|
+
```conf
|
53
|
+
<match *-firelens-*>
|
54
|
+
@type firelens_tag_filter
|
55
|
+
tag ${container_name}.${source}
|
56
|
+
</match>
|
57
|
+
|
58
|
+
<match app.stdout>
|
59
|
+
# ...
|
60
|
+
</match>
|
61
|
+
```
|
62
|
+
|
63
|
+
Placeholders allowed in tag as below.
|
64
|
+
|
65
|
+
- ${container-name} : Container name in task.
|
66
|
+
- ${task_id} : ECS task ID
|
67
|
+
- ${source} : source field in record (`stdout` or `stderr`)
|
68
|
+
|
50
69
|
## Copyright
|
51
70
|
|
52
71
|
* Copyright(c) 2020- FUJIWARA Shunichiro
|
data/example.conf
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-firelens-tag-filter"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.2.0"
|
7
7
|
spec.authors = ["FUJIWARA Shunichiro"]
|
8
8
|
spec.email = ["fujiwara.shunichiro@gmail.com"]
|
9
9
|
|
@@ -24,6 +24,15 @@ module Fluent
|
|
24
24
|
desc 'rewrote tag prefix'
|
25
25
|
config_param :tag_prefix, :string, :default => 'firelens'
|
26
26
|
|
27
|
+
desc 'tag format'
|
28
|
+
config_param :tag, :string, :default => '${tag_prefix}.${container_name}.${source}.${task_id}'
|
29
|
+
|
30
|
+
def configure(conf)
|
31
|
+
super
|
32
|
+
@tag_format = @tag.gsub(/%/, '%%').gsub(/\$\{(.*?)\}/, '%{\1}')
|
33
|
+
log.debug("tag_format #{@tag_format}")
|
34
|
+
end
|
35
|
+
|
27
36
|
# rewrite message tag
|
28
37
|
# from: [containerName]-firelens-[taskID]
|
29
38
|
# to: [tag_prefix].[containerName].(stdout|stderr).[taskID]
|
@@ -34,10 +43,15 @@ module Fluent
|
|
34
43
|
router.emit_stream(@tag_prefix + "." + tag, es)
|
35
44
|
return
|
36
45
|
end
|
46
|
+
v = {
|
47
|
+
tag_prefix: @tag_prefix,
|
48
|
+
container_name: matched[1],
|
49
|
+
task_id: matched[2],
|
50
|
+
}
|
37
51
|
es.each do |time, record|
|
38
|
-
|
52
|
+
v[:source] = record['source'] || 'unknown'
|
39
53
|
router.emit(
|
40
|
-
|
54
|
+
sprintf(@tag_format, v),
|
41
55
|
time,
|
42
56
|
record,
|
43
57
|
)
|
@@ -38,6 +38,22 @@ class FirelensTagFilterOutputTest < Test::Unit::TestCase
|
|
38
38
|
assert_equal events[2], ['ecs.app.unknown.a27287f301b06d77', time, {"foo" => "boo"}]
|
39
39
|
end
|
40
40
|
|
41
|
+
test "tag" do
|
42
|
+
d = create_driver "tag xxx.${source}.${task_id}.${container_name}"
|
43
|
+
time = event_time("2020-07-22 11:22:33Z")
|
44
|
+
d.run(default_tag: "app-firelens-a27287f301b06d77") do
|
45
|
+
d.feed(time, {"foo" => "bar", "source" => "stdout"})
|
46
|
+
d.feed(time, {"foo" => "baz", "source" => "stderr"})
|
47
|
+
d.feed(time, {"foo" => "boo"})
|
48
|
+
end
|
49
|
+
|
50
|
+
events = d.events
|
51
|
+
assert_equal 3, events.length
|
52
|
+
assert_equal events[0], ['xxx.stdout.a27287f301b06d77.app', time, {"foo" => "bar", "source" => "stdout"}]
|
53
|
+
assert_equal events[1], ['xxx.stderr.a27287f301b06d77.app', time, {"foo" => "baz", "source" => "stderr"}]
|
54
|
+
assert_equal events[2], ['xxx.unknown.a27287f301b06d77.app', time, {"foo" => "boo"}]
|
55
|
+
end
|
56
|
+
|
41
57
|
test "unexpected" do
|
42
58
|
d = create_driver ""
|
43
59
|
time = event_time("2020-07-22 11:22:33Z")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-firelens-tag-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FUJIWARA Shunichiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|