fluent-plugin-cloudwatch-logs 0.10.1 → 0.12.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 +30 -0
- data/lib/fluent/plugin/cloudwatch/logs/version.rb +1 -1
- data/lib/fluent/plugin/in_cloudwatch_logs.rb +29 -2
- data/lib/fluent/plugin/out_cloudwatch_logs.rb +54 -9
- data/test/plugin/test_in_cloudwatch_logs.rb +2 -0
- data/test/plugin/test_out_cloudwatch_logs.rb +178 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff7c8514095015603f6197f312b3e73439485ad9fd8b296522605919f5c53930
|
4
|
+
data.tar.gz: b49f0d62c6033f22409c1046ebd87d884a1f693725e4f372119487225c7b0d5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a3520d9d89be225d7fce95a4cc5acc0064b6fdf316de8c85b0a0dda8e7bcc95c3a8290e106459312e9c14aaf2639300aed693169ac200f56c795b04b38d91f6
|
7
|
+
data.tar.gz: 2f3ab8a2a8eb9e98d013f184bdb9cfc7cc2607ba88a1bce37ed8ea56552d1211c1b1b565bebe7aa00791d2c5579d3348507ce612e1070d7bb8abe9dfa3b509ad
|
data/README.md
CHANGED
@@ -160,6 +160,14 @@ Fetch sample log from CloudWatch Logs:
|
|
160
160
|
#endpoint http://localhost:5000/
|
161
161
|
#json_handler json
|
162
162
|
#log_rejected_request true
|
163
|
+
#<web_identity_credentials>
|
164
|
+
# role_arn "#{ENV['AWS_ROLE_ARN']}"
|
165
|
+
# role_session_name ROLE_SESSION_NAME
|
166
|
+
# web_identity_token_file "#{ENV['AWS_WEB_IDENTITY_TOKEN_FILE']}"
|
167
|
+
#</web_identity_credentials>
|
168
|
+
#<format>
|
169
|
+
# @type ltsv
|
170
|
+
#</format>
|
163
171
|
</match>
|
164
172
|
```
|
165
173
|
|
@@ -194,6 +202,15 @@ Fetch sample log from CloudWatch Logs:
|
|
194
202
|
* `retention_in_days_key`: use specified field of records as retention period
|
195
203
|
* `use_tag_as_group`: to use tag as a group name
|
196
204
|
* `use_tag_as_stream`: to use tag as a stream name
|
205
|
+
* `<web_identity_credentials>`: For EKS authentication.
|
206
|
+
* `role_arn`: The Amazon Resource Name (ARN) of the role to assume. This parameter is required when using `<web_identity_credentials>`.
|
207
|
+
* `role_session_name`: An identifier for the assumed role session. This parameter is required when using `<web_identity_credentials>`.
|
208
|
+
* `web_identity_token_file`: The absolute path to the file on disk containing the OIDC token. This parameter is required when using `<web_identity_credentials>`.
|
209
|
+
* `policy`: An IAM policy in JSON format. (default `nil`)
|
210
|
+
* `duration_seconds`: The duration, in seconds, of the role session. The value can range from
|
211
|
+
900 seconds (15 minutes) to 43200 seconds (12 hours). By default, the value
|
212
|
+
is set to 3600 seconds (1 hour). (default `nil`)
|
213
|
+
* `<format>`: For specifying records format. See [formatter overview](https://docs.fluentd.org/formatter) and [formatter section overview](https://docs.fluentd.org/configuration/format-section) on the official documentation.
|
197
214
|
|
198
215
|
**NOTE:** `retention_in_days` requests additional IAM permission `logs:PutRetentionPolicy` for log_group.
|
199
216
|
Please refer to [the PutRetentionPolicy column in documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/permissions-reference-cwl.html) for details.
|
@@ -221,6 +238,11 @@ Please refer to [the PutRetentionPolicy column in documentation](https://docs.aw
|
|
221
238
|
#<storage>
|
222
239
|
# @type local # or redis, memcached, etc.
|
223
240
|
#</storage>
|
241
|
+
#<web_identity_credentials>
|
242
|
+
# role_arn "#{ENV['AWS_ROLE_ARN']}"
|
243
|
+
# role_session_name ROLE_SESSION_NAME
|
244
|
+
# web_identity_token_file "#{ENV['AWS_WEB_IDENTITY_TOKEN_FILE']}"
|
245
|
+
#</web_identity_credentials>
|
224
246
|
</source>
|
225
247
|
```
|
226
248
|
|
@@ -249,6 +271,14 @@ Please refer to [the PutRetentionPolicy column in documentation](https://docs.aw
|
|
249
271
|
* `format`: specify CloudWatchLogs' log format. (default `nil`)
|
250
272
|
* `<parse>`: specify parser plugin configuration. see also: https://docs.fluentd.org/v/1.0/parser#how-to-use
|
251
273
|
* `<storage>`: specify storage plugin configuration. see also: https://docs.fluentd.org/v/1.0/storage#how-to-use
|
274
|
+
* `<web_identity_credentials>`: For EKS authentication.
|
275
|
+
* `role_arn`: The Amazon Resource Name (ARN) of the role to assume. This parameter is required when using `<web_identity_credentials>`.
|
276
|
+
* `role_session_name`: An identifier for the assumed role session. This parameter is required when using `<web_identity_credentials>`.
|
277
|
+
* `web_identity_token_file`: The absolute path to the file on disk containing the OIDC token. This parameter is required when using `<web_identity_credentials>`.
|
278
|
+
* `policy`: An IAM policy in JSON format. (default `nil`)
|
279
|
+
* `duration_seconds`: The duration, in seconds, of the role session. The value can range from
|
280
|
+
900 seconds (15 minutes) to 43200 seconds (12 hours). By default, the value
|
281
|
+
is set to 3600 seconds (1 hour). (default `nil`)
|
252
282
|
|
253
283
|
## Test
|
254
284
|
|
@@ -17,6 +17,7 @@ module Fluent::Plugin
|
|
17
17
|
config_param :aws_use_sts, :bool, default: false
|
18
18
|
config_param :aws_sts_role_arn, :string, default: nil
|
19
19
|
config_param :aws_sts_session_name, :string, default: 'fluentd'
|
20
|
+
config_param :aws_sts_endpoint_url, :string, default: nil
|
20
21
|
config_param :region, :string, default: nil
|
21
22
|
config_param :endpoint, :string, default: nil
|
22
23
|
config_param :tag, :string
|
@@ -35,6 +36,13 @@ module Fluent::Plugin
|
|
35
36
|
config_param :time_range_format, :string, default: "%Y-%m-%d %H:%M:%S"
|
36
37
|
config_param :throttling_retry_seconds, :time, default: nil
|
37
38
|
config_param :include_metadata, :bool, default: false
|
39
|
+
config_section :web_identity_credentials, multi: false do
|
40
|
+
config_param :role_arn, :string
|
41
|
+
config_param :role_session_name, :string
|
42
|
+
config_param :web_identity_token_file, :string, default: nil #required
|
43
|
+
config_param :policy, :string, default: nil
|
44
|
+
config_param :duration_seconds, :time, default: nil
|
45
|
+
end
|
38
46
|
|
39
47
|
config_section :parse do
|
40
48
|
config_set_default :@type, 'none'
|
@@ -75,10 +83,29 @@ module Fluent::Plugin
|
|
75
83
|
|
76
84
|
if @aws_use_sts
|
77
85
|
Aws.config[:region] = options[:region]
|
78
|
-
|
86
|
+
credentials_options = {
|
79
87
|
role_arn: @aws_sts_role_arn,
|
80
88
|
role_session_name: @aws_sts_session_name
|
81
|
-
|
89
|
+
}
|
90
|
+
credentials_options[:sts_endpoint_url] = @aws_sts_endpoint_url if @aws_sts_endpoint_url
|
91
|
+
if @region and @aws_sts_endpoint_url
|
92
|
+
credentials_options[:client] = Aws::STS::Client.new(:region => @region, endpoint: @aws_sts_endpoint_url)
|
93
|
+
elsif @region
|
94
|
+
credentials_options[:client] = Aws::STS::Client.new(:region => @region)
|
95
|
+
end
|
96
|
+
options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options)
|
97
|
+
elsif @web_identity_credentials
|
98
|
+
c = @web_identity_credentials
|
99
|
+
credentials_options = {}
|
100
|
+
credentials_options[:role_arn] = c.role_arn
|
101
|
+
credentials_options[:role_session_name] = c.role_session_name
|
102
|
+
credentials_options[:web_identity_token_file] = c.web_identity_token_file
|
103
|
+
credentials_options[:policy] = c.policy if c.policy
|
104
|
+
credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds
|
105
|
+
if @region
|
106
|
+
credentials_options[:client] = Aws::STS::Client.new(:region => @region)
|
107
|
+
end
|
108
|
+
options[:credentials] = Aws::AssumeRoleWebIdentityCredentials.new(credentials_options)
|
82
109
|
else
|
83
110
|
options[:credentials] = Aws::Credentials.new(@aws_key_id, @aws_sec_key) if @aws_key_id && @aws_sec_key
|
84
111
|
end
|
@@ -9,7 +9,7 @@ module Fluent::Plugin
|
|
9
9
|
|
10
10
|
class TooLargeEventError < Fluent::UnrecoverableError; end
|
11
11
|
|
12
|
-
helpers :compat_parameters, :inject
|
12
|
+
helpers :compat_parameters, :inject, :formatter
|
13
13
|
|
14
14
|
DEFAULT_BUFFER_TYPE = "memory"
|
15
15
|
|
@@ -19,6 +19,7 @@ module Fluent::Plugin
|
|
19
19
|
config_param :aws_use_sts, :bool, default: false
|
20
20
|
config_param :aws_sts_role_arn, :string, default: nil
|
21
21
|
config_param :aws_sts_session_name, :string, default: 'fluentd'
|
22
|
+
config_param :aws_sts_endpoint_url, :string, default: nil
|
22
23
|
config_param :region, :string, :default => nil
|
23
24
|
config_param :endpoint, :string, :default => nil
|
24
25
|
config_param :log_group_name, :string, :default => nil
|
@@ -46,10 +47,20 @@ module Fluent::Plugin
|
|
46
47
|
config_param :remove_retention_in_days_key, :bool, default: false
|
47
48
|
config_param :json_handler, :enum, list: [:yajl, :json], :default => :yajl
|
48
49
|
config_param :log_rejected_request, :bool, :default => false
|
50
|
+
config_section :web_identity_credentials, multi: false do
|
51
|
+
config_param :role_arn, :string
|
52
|
+
config_param :role_session_name, :string
|
53
|
+
config_param :web_identity_token_file, :string, default: nil #required
|
54
|
+
config_param :policy, :string, default: nil
|
55
|
+
config_param :duration_seconds, :time, default: nil
|
56
|
+
end
|
49
57
|
|
50
58
|
config_section :buffer do
|
51
59
|
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
52
60
|
end
|
61
|
+
config_section :format do
|
62
|
+
config_set_default :@type, 'json'
|
63
|
+
end
|
53
64
|
|
54
65
|
MAX_EVENTS_SIZE = 1_048_576
|
55
66
|
MAX_EVENT_SIZE = 256 * 1024
|
@@ -80,6 +91,22 @@ module Fluent::Plugin
|
|
80
91
|
if [conf['retention_in_days'], conf['retention_in_days_key']].compact.size > 1
|
81
92
|
raise ConfigError, "Set only one of retention_in_days, retention_in_days_key"
|
82
93
|
end
|
94
|
+
|
95
|
+
formatter_conf = conf.elements('format').first
|
96
|
+
@formatter_proc = unless formatter_conf
|
97
|
+
unless @message_keys.empty?
|
98
|
+
Proc.new { |tag, time, record|
|
99
|
+
@message_keys.map{|k| record[k].to_s }.reject{|e| e.empty? }.join(' ')
|
100
|
+
}
|
101
|
+
else
|
102
|
+
Proc.new { |tag, time, record|
|
103
|
+
@json_handler.dump(record)
|
104
|
+
}
|
105
|
+
end
|
106
|
+
else
|
107
|
+
formatter = formatter_create(usage: 'cloudwatch-logs-plugin', conf: formatter_conf)
|
108
|
+
formatter.method(:format)
|
109
|
+
end
|
83
110
|
end
|
84
111
|
|
85
112
|
def start
|
@@ -94,10 +121,29 @@ module Fluent::Plugin
|
|
94
121
|
|
95
122
|
if @aws_use_sts
|
96
123
|
Aws.config[:region] = options[:region]
|
97
|
-
|
124
|
+
credentials_options = {
|
98
125
|
role_arn: @aws_sts_role_arn,
|
99
126
|
role_session_name: @aws_sts_session_name
|
100
|
-
|
127
|
+
}
|
128
|
+
credentials_options[:sts_endpoint_url] = @aws_sts_endpoint_url if @aws_sts_endpoint_url
|
129
|
+
if @region and @aws_sts_endpoint_url
|
130
|
+
credentials_options[:client] = Aws::STS::Client.new(:region => @region, endpoint: @aws_sts_endpoint_url)
|
131
|
+
elsif @region
|
132
|
+
credentials_options[:client] = Aws::STS::Client.new(:region => @region)
|
133
|
+
end
|
134
|
+
options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options)
|
135
|
+
elsif @web_identity_credentials
|
136
|
+
c = @web_identity_credentials
|
137
|
+
credentials_options = {}
|
138
|
+
credentials_options[:role_arn] = c.role_arn
|
139
|
+
credentials_options[:role_session_name] = c.role_session_name
|
140
|
+
credentials_options[:web_identity_token_file] = c.web_identity_token_file
|
141
|
+
credentials_options[:policy] = c.policy if c.policy
|
142
|
+
credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds
|
143
|
+
if @region
|
144
|
+
credentials_options[:client] = Aws::STS::Client.new(:region => @region)
|
145
|
+
end
|
146
|
+
options[:credentials] = Aws::AssumeRoleWebIdentityCredentials.new(credentials_options)
|
101
147
|
else
|
102
148
|
options[:credentials] = Aws::Credentials.new(@aws_key_id, @aws_sec_key) if @aws_key_id && @aws_sec_key
|
103
149
|
end
|
@@ -132,6 +178,9 @@ module Fluent::Plugin
|
|
132
178
|
def write(chunk)
|
133
179
|
log_group_name = extract_placeholders(@log_group_name, chunk) if @log_group_name
|
134
180
|
log_stream_name = extract_placeholders(@log_stream_name, chunk) if @log_stream_name
|
181
|
+
aws_tags = @log_group_aws_tags.each {|k, v|
|
182
|
+
@log_group_aws_tags[extract_placeholders(k, chunk)] = extract_placeholders(v, chunk)
|
183
|
+
} if @log_group_aws_tags
|
135
184
|
|
136
185
|
queue = Thread::Queue.new
|
137
186
|
|
@@ -184,7 +233,7 @@ module Fluent::Plugin
|
|
184
233
|
#as we create log group only once, values from first record will persist
|
185
234
|
record = rs[0][2]
|
186
235
|
|
187
|
-
awstags =
|
236
|
+
awstags = aws_tags
|
188
237
|
unless @log_group_aws_tags_key.nil?
|
189
238
|
if @remove_log_group_aws_tags_key
|
190
239
|
awstags = record.delete(@log_group_aws_tags_key)
|
@@ -234,11 +283,7 @@ module Fluent::Plugin
|
|
234
283
|
time_ms = (time.to_f * 1000).floor
|
235
284
|
|
236
285
|
scrub_record!(record)
|
237
|
-
|
238
|
-
message = @message_keys.map{|k| record[k].to_s }.reject{|e| e.empty? }.join(' ')
|
239
|
-
else
|
240
|
-
message = @json_handler.dump(record)
|
241
|
-
end
|
286
|
+
message = @formatter_proc.call(t, time, record)
|
242
287
|
|
243
288
|
if message.empty?
|
244
289
|
log.warn "Within specified message_key(s): (#{@message_keys.join(',')}) do not have non-empty record. Skip."
|
@@ -76,6 +76,143 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
76
76
|
assert(logs.any?{|log| log.include?("Called PutLogEvents API") })
|
77
77
|
end
|
78
78
|
|
79
|
+
sub_test_case "formatter" do
|
80
|
+
test "csv" do
|
81
|
+
new_log_stream
|
82
|
+
|
83
|
+
config = {'@type' => 'cloudwatch_logs',
|
84
|
+
'auto_create_stream' => true,
|
85
|
+
'log_stream_name' => log_stream_name,
|
86
|
+
'log_group_name' => log_group_name,
|
87
|
+
'@log_level' => 'debug'}
|
88
|
+
config.merge!(config_elementify(aws_key_id)) if aws_key_id
|
89
|
+
config.merge!(config_elementify(aws_sec_key)) if aws_sec_key
|
90
|
+
config.merge!(config_elementify(region)) if region
|
91
|
+
config.merge!(config_elementify(endpoint)) if endpoint
|
92
|
+
|
93
|
+
d = create_driver(
|
94
|
+
Fluent::Config::Element.new('ROOT', '', config, [
|
95
|
+
Fluent::Config::Element.new('buffer', 'tag, time', {
|
96
|
+
'@type' => 'memory',
|
97
|
+
'timekey' => 3600
|
98
|
+
}, []),
|
99
|
+
Fluent::Config::Element.new('format', '', {
|
100
|
+
'@type' => 'csv',
|
101
|
+
'fields' => ["message","cloudwatch"],
|
102
|
+
}, []),
|
103
|
+
]))
|
104
|
+
|
105
|
+
time = event_time
|
106
|
+
d.run(default_tag: fluentd_tag, flush: true) do
|
107
|
+
d.feed(time, {'cloudwatch' => 'logs1'})
|
108
|
+
# Addition converts EventTime to seconds
|
109
|
+
d.feed(time + 1, {'cloudwatch' => 'logs2'})
|
110
|
+
end
|
111
|
+
|
112
|
+
sleep 10
|
113
|
+
|
114
|
+
logs = d.logs
|
115
|
+
events = get_log_events
|
116
|
+
assert_equal(2, events.size)
|
117
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
118
|
+
assert_equal('"","logs1"', events[0].message.strip)
|
119
|
+
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
120
|
+
assert_equal('"","logs2"', events[1].message.strip)
|
121
|
+
|
122
|
+
assert(logs.any?{|log| log.include?("Called PutLogEvents API") })
|
123
|
+
end
|
124
|
+
|
125
|
+
test "ltsv" do
|
126
|
+
new_log_stream
|
127
|
+
|
128
|
+
config = {'@type' => 'cloudwatch_logs',
|
129
|
+
'auto_create_stream' => true,
|
130
|
+
'log_stream_name' => log_stream_name,
|
131
|
+
'log_group_name' => log_group_name,
|
132
|
+
'@log_level' => 'debug'}
|
133
|
+
config.merge!(config_elementify(aws_key_id)) if aws_key_id
|
134
|
+
config.merge!(config_elementify(aws_sec_key)) if aws_sec_key
|
135
|
+
config.merge!(config_elementify(region)) if region
|
136
|
+
config.merge!(config_elementify(endpoint)) if endpoint
|
137
|
+
|
138
|
+
d = create_driver(
|
139
|
+
Fluent::Config::Element.new('ROOT', '', config, [
|
140
|
+
Fluent::Config::Element.new('buffer', 'tag, time', {
|
141
|
+
'@type' => 'memory',
|
142
|
+
'timekey' => 3600
|
143
|
+
}, []),
|
144
|
+
Fluent::Config::Element.new('format', '', {
|
145
|
+
'@type' => 'ltsv',
|
146
|
+
'fields' => ["message","cloudwatch"],
|
147
|
+
}, []),
|
148
|
+
]))
|
149
|
+
|
150
|
+
time = event_time
|
151
|
+
d.run(default_tag: fluentd_tag, flush: true) do
|
152
|
+
d.feed(time, {'cloudwatch' => 'logs1'})
|
153
|
+
# Addition converts EventTime to seconds
|
154
|
+
d.feed(time + 1, {'cloudwatch' => 'logs2'})
|
155
|
+
end
|
156
|
+
|
157
|
+
sleep 10
|
158
|
+
|
159
|
+
logs = d.logs
|
160
|
+
events = get_log_events
|
161
|
+
assert_equal(2, events.size)
|
162
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
163
|
+
assert_equal('cloudwatch:logs1', events[0].message.strip)
|
164
|
+
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
165
|
+
assert_equal('cloudwatch:logs2', events[1].message.strip)
|
166
|
+
|
167
|
+
assert(logs.any?{|log| log.include?("Called PutLogEvents API") })
|
168
|
+
end
|
169
|
+
|
170
|
+
test "single_value" do
|
171
|
+
new_log_stream
|
172
|
+
|
173
|
+
config = {'@type' => 'cloudwatch_logs',
|
174
|
+
'auto_create_stream' => true,
|
175
|
+
'log_stream_name' => log_stream_name,
|
176
|
+
'log_group_name' => log_group_name,
|
177
|
+
'@log_level' => 'debug'}
|
178
|
+
config.merge!(config_elementify(aws_key_id)) if aws_key_id
|
179
|
+
config.merge!(config_elementify(aws_sec_key)) if aws_sec_key
|
180
|
+
config.merge!(config_elementify(region)) if region
|
181
|
+
config.merge!(config_elementify(endpoint)) if endpoint
|
182
|
+
|
183
|
+
d = create_driver(
|
184
|
+
Fluent::Config::Element.new('ROOT', '', config, [
|
185
|
+
Fluent::Config::Element.new('buffer', 'tag, time', {
|
186
|
+
'@type' => 'memory',
|
187
|
+
'timekey' => 3600
|
188
|
+
}, []),
|
189
|
+
Fluent::Config::Element.new('format', '', {
|
190
|
+
'@type' => 'single_value',
|
191
|
+
'message_key' => "cloudwatch",
|
192
|
+
}, []),
|
193
|
+
]))
|
194
|
+
|
195
|
+
time = event_time
|
196
|
+
d.run(default_tag: fluentd_tag, flush: true) do
|
197
|
+
d.feed(time, {'cloudwatch' => 'logs1', 'message' => 'Hi!'})
|
198
|
+
# Addition converts EventTime to seconds
|
199
|
+
d.feed(time + 1, {'cloudwatch' => 'logs2', 'message' => 'Hi!'})
|
200
|
+
end
|
201
|
+
|
202
|
+
sleep 10
|
203
|
+
|
204
|
+
logs = d.logs
|
205
|
+
events = get_log_events
|
206
|
+
assert_equal(2, events.size)
|
207
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
208
|
+
assert_equal('logs1', events[0].message.strip)
|
209
|
+
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
210
|
+
assert_equal('logs2', events[1].message.strip)
|
211
|
+
|
212
|
+
assert(logs.any?{|log| log.include?("Called PutLogEvents API") })
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
79
216
|
def test_write_utf8
|
80
217
|
new_log_stream
|
81
218
|
|
@@ -492,6 +629,47 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
492
629
|
assert_equal("value2", awstags.fetch("tag2"))
|
493
630
|
end
|
494
631
|
|
632
|
+
def test_log_group_aws_tags_with_placeholders
|
633
|
+
clear_log_group
|
634
|
+
|
635
|
+
config = {
|
636
|
+
"@type" => "cloudwatch_logs",
|
637
|
+
"auto_create_stream" => true,
|
638
|
+
"use_tag_as_stream" => true,
|
639
|
+
"log_group_name_key" => "group_name_key",
|
640
|
+
"log_group_aws_tags" => '{"tag1": "${tag}", "tag2": "${namespace_name}"}',
|
641
|
+
}
|
642
|
+
config.merge!(config_elementify(aws_key_id)) if aws_key_id
|
643
|
+
config.merge!(config_elementify(aws_sec_key)) if aws_sec_key
|
644
|
+
config.merge!(config_elementify(region)) if region
|
645
|
+
config.merge!(config_elementify(endpoint)) if endpoint
|
646
|
+
|
647
|
+
d = create_driver(
|
648
|
+
Fluent::Config::Element.new('ROOT', '', config, [
|
649
|
+
Fluent::Config::Element.new('buffer', 'tag, namespace_name', {
|
650
|
+
'@type' => 'memory',
|
651
|
+
}, [])
|
652
|
+
])
|
653
|
+
)
|
654
|
+
|
655
|
+
records = [
|
656
|
+
{'cloudwatch' => 'logs1', 'message' => 'message1', 'group_name_key' => log_group_name, "namespace_name" => "fluentd"},
|
657
|
+
{'cloudwatch' => 'logs2', 'message' => 'message1', 'group_name_key' => log_group_name, "namespace_name" => "fluentd"},
|
658
|
+
{'cloudwatch' => 'logs3', 'message' => 'message1', 'group_name_key' => log_group_name, "namespace_name" => "fluentd"},
|
659
|
+
]
|
660
|
+
|
661
|
+
time = Time.now
|
662
|
+
d.run(default_tag: fluentd_tag) do
|
663
|
+
records.each_with_index do |record, i|
|
664
|
+
d.feed(time.to_i + i, record)
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
668
|
+
awstags = get_log_group_tags
|
669
|
+
assert_equal(fluentd_tag, awstags.fetch("tag1"))
|
670
|
+
assert_equal("fluentd", awstags.fetch("tag2"))
|
671
|
+
end
|
672
|
+
|
495
673
|
def test_retention_in_days
|
496
674
|
clear_log_group
|
497
675
|
|
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.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description:
|
111
|
+
description:
|
112
112
|
email:
|
113
113
|
- ryota.arai@gmail.com
|
114
114
|
executables: []
|
@@ -136,7 +136,7 @@ homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-cloudwatch-log
|
|
136
136
|
licenses:
|
137
137
|
- MIT
|
138
138
|
metadata: {}
|
139
|
-
post_install_message:
|
139
|
+
post_install_message:
|
140
140
|
rdoc_options: []
|
141
141
|
require_paths:
|
142
142
|
- lib
|
@@ -151,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
155
|
-
signing_key:
|
154
|
+
rubygems_version: 3.1.2
|
155
|
+
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: CloudWatch Logs Plugin for Fluentd
|
158
158
|
test_files:
|