fluent-plugin-cloudwatch-logs 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ISSUE_TEMPLATE.md +21 -0
- data/README.md +24 -0
- data/lib/fluent/plugin/cloudwatch/logs/version.rb +1 -1
- data/lib/fluent/plugin/in_cloudwatch_logs.rb +12 -7
- data/test/plugin/test_out_cloudwatch_logs.rb +76 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ac14d761ae8cfffe1fd6cc11abdc282861f8639924776117c6773a4599057a
|
4
|
+
data.tar.gz: 933cc8a97a346ade8287f5fbfc339aa2340a8982c3252cf822a9b95d70c0c78f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64c6c225b57fe907a6ac9e1941d3cb3a1c0356096aeda2e9213bee288e479c18ed33d73eea754a58474d60e818f6c6ce7f33f5efa0b339c663d3a84f743d8ccf
|
7
|
+
data.tar.gz: 5300d8d29f83242479ac2f38c8bdf26bacd3d8dd353f8b286eb593912671ec6143ad26ff3640affbd33293ae07cea1b9bf3d22dcbe0eb81acb2ffc5564cc0aec
|
data/ISSUE_TEMPLATE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#### Problem
|
2
|
+
|
3
|
+
...
|
4
|
+
|
5
|
+
#### Steps to replicate
|
6
|
+
|
7
|
+
Provide example config and message
|
8
|
+
|
9
|
+
#### Expected Behavior or What you need to ask
|
10
|
+
|
11
|
+
...
|
12
|
+
|
13
|
+
#### Using Fluentd and CloudWatchLogs plugin versions
|
14
|
+
|
15
|
+
* OS version
|
16
|
+
* Bare Metal or within Docker or Kubernetes or others?
|
17
|
+
* Fluentd v0.12 or v0.14/v1.0
|
18
|
+
* paste result of ``fluentd --version`` or ``td-agent --version``
|
19
|
+
* Dependent gem versions
|
20
|
+
* paste boot log of fluentd or td-agent
|
21
|
+
* paste result of ``fluent-gem list``, ``td-agent-gem list`` or your Gemfile.lock
|
data/README.md
CHANGED
@@ -262,6 +262,30 @@ In this case IAM can be used to allow the fluentd instance in one account ("A")
|
|
262
262
|
</source>
|
263
263
|
```
|
264
264
|
|
265
|
+
### Using build-in placeholders, but they don't replace placeholders with actual values, why?
|
266
|
+
|
267
|
+
Built-in placeholders use buffer metadata when replacing placeholders with actual values.
|
268
|
+
So, you should specify buffer attributes what you want to replace placeholders with.
|
269
|
+
|
270
|
+
Using `${tag}` placeholders, you should specify `tag` attributes in buffer:
|
271
|
+
|
272
|
+
```aconf
|
273
|
+
<buffer tag>
|
274
|
+
@type memory
|
275
|
+
</buffer>
|
276
|
+
```
|
277
|
+
|
278
|
+
Using `%Y%m%d` placeholders, you should specify `time` attributes in buffer:
|
279
|
+
|
280
|
+
```aconf
|
281
|
+
<buffer time>
|
282
|
+
@type memory
|
283
|
+
timekey 3600
|
284
|
+
</buffer>
|
285
|
+
```
|
286
|
+
|
287
|
+
In more detail, please refer to [the officilal document for built-in placeholders](https://docs.fluentd.org/v1.0/articles/buffer-section#placeholders).
|
288
|
+
|
265
289
|
## TODO
|
266
290
|
|
267
291
|
* out_cloudwatch_logs
|
@@ -109,14 +109,19 @@ module Fluent::Plugin
|
|
109
109
|
|
110
110
|
if @use_log_stream_name_prefix || @use_todays_log_stream
|
111
111
|
log_stream_name_prefix = @use_todays_log_stream ? get_todays_date : @log_stream_name
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
112
|
+
begin
|
113
|
+
log_streams = describe_log_streams(log_stream_name_prefix)
|
114
|
+
log_streams.concat(describe_log_streams(get_yesterdays_date)) if @use_todays_log_stream
|
115
|
+
log_streams.each do |log_stream|
|
116
|
+
log_stream_name = log_stream.log_stream_name
|
117
|
+
events = get_events(log_stream_name)
|
118
|
+
events.each do |event|
|
119
|
+
emit(log_stream_name, event)
|
120
|
+
end
|
119
121
|
end
|
122
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceNotFoundException
|
123
|
+
log.warn "'#{@log_stream_name}' prefixed log stream(s) are not found"
|
124
|
+
next
|
120
125
|
end
|
121
126
|
else
|
122
127
|
events = get_events(@log_stream_name)
|
@@ -257,6 +257,82 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
257
257
|
assert_equal('message2 logs2', events[1].message)
|
258
258
|
end
|
259
259
|
|
260
|
+
def test_write_use_placeholders_parts
|
261
|
+
new_log_stream
|
262
|
+
|
263
|
+
config = {'@type' => 'cloudwatch_logs',
|
264
|
+
'auto_create_stream' => true,
|
265
|
+
'message_keys' => ["message","cloudwatch"],
|
266
|
+
'log_stream_name' => "${tag[0]}-${tag[1]}-${tag[2]}-${tag[3]}",
|
267
|
+
'log_group_name' => log_group_name}
|
268
|
+
config.merge!(config_elementify(aws_key_id)) if aws_key_id
|
269
|
+
config.merge!(config_elementify(aws_sec_key)) if aws_sec_key
|
270
|
+
config.merge!(config_elementify(region)) if region
|
271
|
+
config.merge!(config_elementify(endpoint)) if endpoint
|
272
|
+
|
273
|
+
d = create_driver(
|
274
|
+
Fluent::Config::Element.new('ROOT', '', config,[
|
275
|
+
Fluent::Config::Element.new('buffer', 'tag, time', {
|
276
|
+
'@type' => 'memory',
|
277
|
+
'timekey' => 3600
|
278
|
+
}, [])
|
279
|
+
])
|
280
|
+
)
|
281
|
+
|
282
|
+
time = event_time
|
283
|
+
d.run(default_tag: fluentd_tag) do
|
284
|
+
d.feed(time, {'cloudwatch' => 'logs1', 'message' => 'message1'})
|
285
|
+
d.feed(time + 1, {'cloudwatch' => 'logs2', 'message' => 'message2'})
|
286
|
+
end
|
287
|
+
|
288
|
+
sleep 10
|
289
|
+
|
290
|
+
events = get_log_events(log_group_name, 'fluent-plugin-cloudwatch-test')
|
291
|
+
assert_equal(2, events.size)
|
292
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
293
|
+
assert_equal('message1 logs1', events[0].message)
|
294
|
+
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
295
|
+
assert_equal('message2 logs2', events[1].message)
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_write_use_time_placeholders
|
299
|
+
new_log_stream
|
300
|
+
|
301
|
+
config = {'@type' => 'cloudwatch_logs',
|
302
|
+
'auto_create_stream' => true,
|
303
|
+
'message_keys' => ["message","cloudwatch"],
|
304
|
+
'log_stream_name' => "fluent-plugin-cloudwatch-test-%Y%m%d",
|
305
|
+
'log_group_name' => log_group_name}
|
306
|
+
config.merge!(config_elementify(aws_key_id)) if aws_key_id
|
307
|
+
config.merge!(config_elementify(aws_sec_key)) if aws_sec_key
|
308
|
+
config.merge!(config_elementify(region)) if region
|
309
|
+
config.merge!(config_elementify(endpoint)) if endpoint
|
310
|
+
|
311
|
+
d = create_driver(
|
312
|
+
Fluent::Config::Element.new('ROOT', '', config,[
|
313
|
+
Fluent::Config::Element.new('buffer', 'tag, time', {
|
314
|
+
'@type' => 'memory',
|
315
|
+
'timekey' => 3600
|
316
|
+
}, [])
|
317
|
+
])
|
318
|
+
)
|
319
|
+
|
320
|
+
time = event_time
|
321
|
+
d.run(default_tag: fluentd_tag) do
|
322
|
+
d.feed(time, {'cloudwatch' => 'logs1', 'message' => 'message1'})
|
323
|
+
d.feed(time + 1, {'cloudwatch' => 'logs2', 'message' => 'message2'})
|
324
|
+
end
|
325
|
+
|
326
|
+
sleep 10
|
327
|
+
|
328
|
+
events = get_log_events(log_group_name, "fluent-plugin-cloudwatch-test-#{Time.at(time).strftime("%Y%m%d")}")
|
329
|
+
assert_equal(2, events.size)
|
330
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
331
|
+
assert_equal('message1 logs1', events[0].message)
|
332
|
+
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
333
|
+
assert_equal('message2 logs2', events[1].message)
|
334
|
+
end
|
335
|
+
|
260
336
|
def test_include_time_key
|
261
337
|
new_log_stream
|
262
338
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-cloudwatch-logs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
105
|
- Gemfile
|
106
|
+
- ISSUE_TEMPLATE.md
|
106
107
|
- LICENSE.txt
|
107
108
|
- README.md
|
108
109
|
- Rakefile
|