質問編集履歴
1
構築手順とCloudWatch Agentの設定内容を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -91,3 +91,313 @@
|
|
91
91
|
</Plugin>
|
92
92
|
|
93
93
|
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
【追記】
|
98
|
+
|
99
|
+
ここまでの手順とCloudWatch Agentの設定ファイルの内容を記載します。
|
100
|
+
|
101
|
+
0. CloudWatch用ロールの作成
|
102
|
+
|
103
|
+
AmazonEC2RoleforSSM
|
104
|
+
|
105
|
+
CloudWatchAgentAdminPolicy
|
106
|
+
|
107
|
+
CloudWatchAgentServerPolicy
|
108
|
+
|
109
|
+
0. EC2構築(Amazonlinux2)ロール割り当て
|
110
|
+
|
111
|
+
0. CloudWatch Agentのインストール
|
112
|
+
|
113
|
+
sudo yum install amazon-cloudwatch-agent
|
114
|
+
|
115
|
+
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
|
116
|
+
|
117
|
+
0. collectdのインストール
|
118
|
+
|
119
|
+
sudo yum install -y collectd
|
120
|
+
|
121
|
+
sudo yum install -y collectd-snmp
|
122
|
+
|
123
|
+
0. collectd の CloudWatch 用プラグインをインストール
|
124
|
+
|
125
|
+
git clone https://github.com/awslabs/collectd-cloudwatch.git
|
126
|
+
|
127
|
+
cd collectd-cloudwatch/src
|
128
|
+
|
129
|
+
sudo ./setup.py
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
0. /etc/collectd.d/snmp.confの設定(上記内容)
|
134
|
+
|
135
|
+
0. CloudWatch でメトリクス確認(ネットワーク機器が表示できない)←いまここ
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
● /opt/collectd-plugins/cloudwatch/config/plugin.conf の設定
|
140
|
+
|
141
|
+
```ここに言語を入力
|
142
|
+
|
143
|
+
# The path to the AWS credentials file. This value has to be provided if plugin is used outside of EC2 instances
|
144
|
+
|
145
|
+
#credentials_path = "/home/user/.aws/credentials"
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
# The target region which will be used to publish metric data
|
150
|
+
|
151
|
+
# For list of valid regions visit: http://docs.aws.amazon.com/general/latest/gr/rande.html#cw_region
|
152
|
+
|
153
|
+
#region = "us-west-1"
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
# The host parameter can be used to override instance-id or host information published with every metric
|
158
|
+
|
159
|
+
#host = "Server1"
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
# The pass through option allows unsafe regexes such as '.*' or '.+'.
|
164
|
+
|
165
|
+
# WARNING: ENABLING THIS OPTION MAY LEAD TO PUBLISHING A LARGE NUMBER OF METRICS
|
166
|
+
|
167
|
+
# SEE https://aws.amazon.com/cloudwatch/pricing/ TO UNDERSTAND HOW TO ESTIMATE YOUR BILL.
|
168
|
+
|
169
|
+
whitelist_pass_through = False
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
# The debug parameter enables verbose logging of published metrics
|
174
|
+
|
175
|
+
debug = False
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
# Wheter or not to push the ASG as part of the dimension.
|
180
|
+
|
181
|
+
# WARNING: ENABLING THIS WILL LEAD TO CREATING A LARGE NUMBER OF METRICS.
|
182
|
+
|
183
|
+
push_asg = False
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
# Whether or not to push the constant value to CWM as a metric
|
188
|
+
|
189
|
+
push_constant = False
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
# Constant dimension value to add to CWL
|
194
|
+
|
195
|
+
constant_dimension_value = "ALL"
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
# The proxy_server_name is used for connecting *.amazonaws.com, to put metrics.
|
200
|
+
|
201
|
+
#proxy_server_name = http://myproxyserver.com
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
# The proxy_server_port is used for connecting *.amazonaws.com, to put metrics.
|
206
|
+
|
207
|
+
#proxy_server_port = 8080
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
# The storage resolution is for high resolution support, it shows the resolution of storage, the unit is second
|
212
|
+
|
213
|
+
#enable_high_resolution_metrics = False
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
# The flush_interval_in_seconds is used for flush interval, it means how long plugin should flush the metrics to Cloudwatch, the unit here is second
|
218
|
+
|
219
|
+
#flush_interval_in_seconds = 60
|
220
|
+
|
221
|
+
```
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
●CloudWatch Agentの設定ファイル(SSM パラメータストアに保存)
|
226
|
+
|
227
|
+
```
|
228
|
+
|
229
|
+
ファイル名:AmazonCloudWatch-linux
|
230
|
+
|
231
|
+
{
|
232
|
+
|
233
|
+
"agent": {
|
234
|
+
|
235
|
+
"metrics_collection_interval": 60,
|
236
|
+
|
237
|
+
"run_as_user": "root"
|
238
|
+
|
239
|
+
},
|
240
|
+
|
241
|
+
"logs": {
|
242
|
+
|
243
|
+
"logs_collected": {
|
244
|
+
|
245
|
+
"files": {
|
246
|
+
|
247
|
+
"collect_list": [
|
248
|
+
|
249
|
+
{
|
250
|
+
|
251
|
+
"file_path": "/var/log/messages",
|
252
|
+
|
253
|
+
"log_group_name": "messages",
|
254
|
+
|
255
|
+
"log_stream_name": "{instance_id}"
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
]
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
},
|
266
|
+
|
267
|
+
"metrics": {
|
268
|
+
|
269
|
+
"metrics_collected": {
|
270
|
+
|
271
|
+
"collectd": {
|
272
|
+
|
273
|
+
"metrics_aggregation_interval": 60
|
274
|
+
|
275
|
+
},
|
276
|
+
|
277
|
+
"cpu": {
|
278
|
+
|
279
|
+
"measurement": [
|
280
|
+
|
281
|
+
"cpu_usage_idle"
|
282
|
+
|
283
|
+
],
|
284
|
+
|
285
|
+
"metrics_collection_interval": 60,
|
286
|
+
|
287
|
+
"resources": [
|
288
|
+
|
289
|
+
"*"
|
290
|
+
|
291
|
+
],
|
292
|
+
|
293
|
+
"totalcpu": true
|
294
|
+
|
295
|
+
},
|
296
|
+
|
297
|
+
"disk": {
|
298
|
+
|
299
|
+
"measurement": [
|
300
|
+
|
301
|
+
"used_percent"
|
302
|
+
|
303
|
+
],
|
304
|
+
|
305
|
+
"metrics_collection_interval": 60,
|
306
|
+
|
307
|
+
"resources": [
|
308
|
+
|
309
|
+
"*"
|
310
|
+
|
311
|
+
]
|
312
|
+
|
313
|
+
},
|
314
|
+
|
315
|
+
"diskio": {
|
316
|
+
|
317
|
+
"measurement": [
|
318
|
+
|
319
|
+
"write_bytes",
|
320
|
+
|
321
|
+
"read_bytes",
|
322
|
+
|
323
|
+
"writes",
|
324
|
+
|
325
|
+
"reads"
|
326
|
+
|
327
|
+
],
|
328
|
+
|
329
|
+
"metrics_collection_interval": 60,
|
330
|
+
|
331
|
+
"resources": [
|
332
|
+
|
333
|
+
"*"
|
334
|
+
|
335
|
+
]
|
336
|
+
|
337
|
+
},
|
338
|
+
|
339
|
+
"mem": {
|
340
|
+
|
341
|
+
"measurement": [
|
342
|
+
|
343
|
+
"mem_used_percent"
|
344
|
+
|
345
|
+
],
|
346
|
+
|
347
|
+
"metrics_collection_interval": 60
|
348
|
+
|
349
|
+
},
|
350
|
+
|
351
|
+
"net": {
|
352
|
+
|
353
|
+
"measurement": [
|
354
|
+
|
355
|
+
"bytes_sent",
|
356
|
+
|
357
|
+
"bytes_recv",
|
358
|
+
|
359
|
+
"packets_sent",
|
360
|
+
|
361
|
+
"packets_recv"
|
362
|
+
|
363
|
+
],
|
364
|
+
|
365
|
+
"metrics_collection_interval": 60,
|
366
|
+
|
367
|
+
"resources": [
|
368
|
+
|
369
|
+
"*"
|
370
|
+
|
371
|
+
]
|
372
|
+
|
373
|
+
},
|
374
|
+
|
375
|
+
"statsd": {
|
376
|
+
|
377
|
+
"metrics_aggregation_interval": 60,
|
378
|
+
|
379
|
+
"metrics_collection_interval": 10,
|
380
|
+
|
381
|
+
"service_address": ":8125"
|
382
|
+
|
383
|
+
},
|
384
|
+
|
385
|
+
"swap": {
|
386
|
+
|
387
|
+
"measurement": [
|
388
|
+
|
389
|
+
"swap_used_percent"
|
390
|
+
|
391
|
+
],
|
392
|
+
|
393
|
+
"metrics_collection_interval": 60
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
}
|
398
|
+
|
399
|
+
}
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
```
|