質問編集履歴

5

追記

2020/05/20 22:57

投稿

lin.ming
lin.ming

スコア50

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,9 @@
14
14
 
15
15
  #エラーになった箇所
16
16
 
17
+ ```
18
+
17
- ```# /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml -s
19
+ # /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml -s
18
20
 
19
21
  ```
20
22
 

4

追記

2020/05/20 22:57

投稿

lin.ming
lin.ming

スコア50

test CHANGED
File without changes
test CHANGED
@@ -16,66 +16,44 @@
16
16
 
17
17
  ```# /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml -s
18
18
 
19
+ ```
20
+
21
+ ##知りたいこと
22
+
23
+ JSON の形式がおかしいとのことですが、どのように直せばいいかわかりません。
24
+
25
+
26
+
27
+ ご知見のある方、ご教示お願いします。
28
+
29
+
30
+
31
+ ##追記
32
+
33
+ config に書くこともなかったので、
34
+
35
+ ```
36
+
37
+ # mv common-config.toml common-config.toml.bak
38
+
39
+ # touch common-config.toml
40
+
41
+ ```
42
+
43
+ としたのですが、下記エラーが出ます。
44
+
45
+ ```
46
+
47
+ # /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml -s
48
+
19
49
  /opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
20
50
 
21
- Got Home directory: /root
22
-
23
- I! Set home dir Linux: /root
24
-
25
- I! SDKRegionWithCredsMap region: ap-northeast-1
26
-
27
51
  Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml.tmp
28
52
 
29
53
  Start configuration validation...
30
54
 
31
55
  /opt/aws/amazon-cloudwatch-agent/bin/config-translator --input /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --input-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
32
56
 
33
- 2020/04/29 18:00:20 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml.tmp ...
34
-
35
- 2020/04/29 18:00:20 Invalid json format, please check. Reason: invalid character '#' looking for beginning of value
36
-
37
- 2020/04/29 18:00:20 I! AmazonCloudWatchAgent Version 1.237768.0.
38
-
39
- 2020/04/29 18:00:20 Configuration validation first phase failed. Agent version: 1.237768.0. Verify the JSON input is only using features supported by this version.
40
-
41
- ```
42
-
43
- ##知りたいこと
44
-
45
- JSON の形式がおかしいとのことですが、どのように直せばいいかわかりません。
46
-
47
-
48
-
49
- ご知見のある方、ご教示お願いします。
50
-
51
-
52
-
53
- ##追記
54
-
55
- config に書くこともなかったので、
56
-
57
- ```
58
-
59
- # mv common-config.toml common-config.toml.bak
60
-
61
- # touch common-config.toml
62
-
63
- ```
64
-
65
- としたのですが、下記エラーが出ます。
66
-
67
- ```
68
-
69
- # /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml -s
70
-
71
- /opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
72
-
73
- Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml.tmp
74
-
75
- Start configuration validation...
76
-
77
- /opt/aws/amazon-cloudwatch-agent/bin/config-translator --input /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --input-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
78
-
79
57
  2020/04/29 20:55:35 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml.tmp ...
80
58
 
81
59
  2020/04/29 20:55:35 Invalid json format, please check. Reason: unexpected end of JSON input
@@ -451,3 +429,191 @@
451
429
  ```
452
430
 
453
431
  credentials が読めないとありますが、どうしたら読めるようになりますか?
432
+
433
+
434
+
435
+ ##追記4
436
+
437
+ ```
438
+
439
+ # ps aux | grep cloud
440
+
441
+ cwagent 3089 0.1 3.0 158036 30516 ? Ssl 07:15 0:03 /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent -config /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml -pidfile /opt/aws/amazon-cloudwatch-agent/var/amazon-cloudwatch-agent.pid
442
+
443
+ ```
444
+
445
+ ```
446
+
447
+ # cat amazon-cloudwatch-agent.toml
448
+
449
+ [agent]
450
+
451
+ collection_jitter = "0s"
452
+
453
+ debug = false
454
+
455
+ flush_interval = "1s"
456
+
457
+ flush_jitter = "0s"
458
+
459
+ hostname = ""
460
+
461
+ interval = "60s"
462
+
463
+ logfile = "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"
464
+
465
+ metric_batch_size = 1000
466
+
467
+ metric_buffer_limit = 10000
468
+
469
+ omit_hostname = false
470
+
471
+ precision = ""
472
+
473
+ quiet = false
474
+
475
+ round_interval = false
476
+
477
+
478
+
479
+ [inputs]
480
+
481
+
482
+
483
+ [[inputs.disk]]
484
+
485
+ drop_device = false
486
+
487
+ fieldpass = ["used_percent"]
488
+
489
+ [inputs.disk.tags]
490
+
491
+ metricPath = "metrics"
492
+
493
+
494
+
495
+ [[inputs.mem]]
496
+
497
+ fieldpass = ["used_percent"]
498
+
499
+ [inputs.mem.tags]
500
+
501
+ metricPath = "metrics"
502
+
503
+
504
+
505
+ [outputs]
506
+
507
+
508
+
509
+ [[outputs.cloudwatch]]
510
+
511
+ force_flush_interval = "60s"
512
+
513
+ namespace = "CWAgent"
514
+
515
+ region = "ap-northeast-1"
516
+
517
+ shared_credential_file = "/root/.aws/credentials"
518
+
519
+ tagexclude = ["host", "metricPath"]
520
+
521
+ [outputs.cloudwatch.tagpass]
522
+
523
+ metricPath = ["metrics"]
524
+
525
+
526
+
527
+ [processors]
528
+
529
+
530
+
531
+ [[processors.ec2tagger]]
532
+
533
+ ec2_instance_tag_keys = ["aws:autoscaling:groupName"]
534
+
535
+ ec2_metadata_tags = ["ImageId", "InstanceId", "InstanceType"]
536
+
537
+ refresh_interval_seconds = "2147483647s"
538
+
539
+ shared_credential_file = "/root/.aws/credentials"
540
+
541
+ [processors.ec2tagger.tagpass]
542
+
543
+ metricPath = ["metrics"]
544
+
545
+ ```
546
+
547
+ ```
548
+
549
+ # cat common-config.toml
550
+
551
+ [credentials]
552
+
553
+ shared_credential_file = "/root/.aws/credentials"
554
+
555
+ ```
556
+
557
+ ```
558
+
559
+ # cat default
560
+
561
+
562
+
563
+ {
564
+
565
+ "agent": {
566
+
567
+ "run_as_user": "cwagent"
568
+
569
+ },
570
+
571
+ "metrics": {
572
+
573
+ "metrics_collected": {
574
+
575
+ "mem": {
576
+
577
+ "measurement": [
578
+
579
+ "mem_used_percent"
580
+
581
+ ]
582
+
583
+ },
584
+
585
+ "disk": {
586
+
587
+ "measurement": [
588
+
589
+ "used_percent"
590
+
591
+ ],
592
+
593
+ "resources": [
594
+
595
+ "*"
596
+
597
+ ]
598
+
599
+ }
600
+
601
+ },
602
+
603
+ "append_dimensions": {
604
+
605
+ "ImageId": "${aws:ImageId}",
606
+
607
+ "InstanceId": "${aws:InstanceId}",
608
+
609
+ "InstanceType": "${aws:InstanceType}",
610
+
611
+ "AutoScalingGroupName": "${aws:AutoScalingGroupName}"
612
+
613
+ }
614
+
615
+ }
616
+
617
+ }
618
+
619
+ ```

3

追記

2020/05/20 22:55

投稿

lin.ming
lin.ming

スコア50

test CHANGED
File without changes
test CHANGED
@@ -239,3 +239,215 @@
239
239
  }
240
240
 
241
241
  ```
242
+
243
+ ##追記3
244
+
245
+ config.json
246
+
247
+ ```
248
+
249
+ {
250
+
251
+ "agent": {
252
+
253
+ "metrics_collection_interval": 10,
254
+
255
+ "run_as_user": "root"
256
+
257
+ },
258
+
259
+ "logs": {
260
+
261
+ "logs_collected": {
262
+
263
+ "files": {
264
+
265
+ "collect_list": [
266
+
267
+ {
268
+
269
+ "file_path": "/var/log/messages",
270
+
271
+ "log_group_name": "messages",
272
+
273
+ "log_stream_name": "{instance_id}"
274
+
275
+ }
276
+
277
+ ]
278
+
279
+ }
280
+
281
+ }
282
+
283
+ },
284
+
285
+ "metrics": {
286
+
287
+ "append_dimensions": {
288
+
289
+ "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
290
+
291
+ "ImageId": "${aws:ImageId}",
292
+
293
+ "InstanceId": "${aws:InstanceId}",
294
+
295
+ "InstanceType": "${aws:InstanceType}"
296
+
297
+ },
298
+
299
+ "metrics_collected": {
300
+
301
+ "collectd": {
302
+
303
+ "metrics_aggregation_interval": 60
304
+
305
+ },
306
+
307
+ "cpu": {
308
+
309
+ "measurement": [
310
+
311
+ "cpu_usage_idle",
312
+
313
+ "cpu_usage_iowait",
314
+
315
+ "cpu_usage_user",
316
+
317
+ "cpu_usage_system"
318
+
319
+ ],
320
+
321
+ "metrics_collection_interval": 10,
322
+
323
+ "resources": [
324
+
325
+ "*"
326
+
327
+ ],
328
+
329
+ "totalcpu": false
330
+
331
+ },
332
+
333
+ "disk": {
334
+
335
+ "measurement": [
336
+
337
+ "used_percent",
338
+
339
+ "inodes_free"
340
+
341
+ ],
342
+
343
+ "metrics_collection_interval": 10,
344
+
345
+ "resources": [
346
+
347
+ "*"
348
+
349
+ ]
350
+
351
+ },
352
+
353
+ "diskio": {
354
+
355
+ "measurement": [
356
+
357
+ "io_time",
358
+
359
+ "write_bytes",
360
+
361
+ "read_bytes",
362
+
363
+ "writes",
364
+
365
+ "reads"
366
+
367
+ ],
368
+
369
+ "metrics_collection_interval": 10,
370
+
371
+ "resources": [
372
+
373
+ "*"
374
+
375
+ ]
376
+
377
+ },
378
+
379
+ "mem": {
380
+
381
+ "measurement": [
382
+
383
+ "mem_used_percent"
384
+
385
+ ],
386
+
387
+ "metrics_collection_interval": 10
388
+
389
+ },
390
+
391
+ "netstat": {
392
+
393
+ "measurement": [
394
+
395
+ "tcp_established",
396
+
397
+ "tcp_time_wait"
398
+
399
+ ],
400
+
401
+ "metrics_collection_interval": 10
402
+
403
+ },
404
+
405
+ "statsd": {
406
+
407
+ "metrics_aggregation_interval": 60,
408
+
409
+ "metrics_collection_interval": 10,
410
+
411
+ "service_address": ":8125"
412
+
413
+ },
414
+
415
+ "swap": {
416
+
417
+ "measurement": [
418
+
419
+ "swap_used_percent"
420
+
421
+ ],
422
+
423
+ "metrics_collection_interval": 10
424
+
425
+ }
426
+
427
+ }
428
+
429
+ }
430
+
431
+ }
432
+
433
+ ```
434
+
435
+ /opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log
436
+
437
+ ```
438
+
439
+ 2020-05-19T08:06:17Z E! refresh EC2 Instance Tags failed: SharedCredsLoad: failed to load shared credentials file
440
+
441
+ caused by: FailedRead: unable to open file
442
+
443
+ caused by: open /root/.aws/credentials: permission denied, metrics will be dropped until it got fixed
444
+
445
+ 2020-05-19T08:16:17Z E! refresh EC2 Instance Tags failed: SharedCredsLoad: failed to load shared credentials file
446
+
447
+ caused by: FailedRead: unable to open file
448
+
449
+ caused by: open /root/.aws/credentials: permission denied, metrics will be dropped until it got fixed
450
+
451
+ ```
452
+
453
+ credentials が読めないとありますが、どうしたら読めるようになりますか?

2

追記

2020/05/19 08:20

投稿

lin.ming
lin.ming

スコア50

test CHANGED
File without changes
test CHANGED
@@ -85,3 +85,157 @@
85
85
  2020/04/29 20:55:35 Configuration validation first phase failed. Agent version: 1.237768.0. Verify the JSON input is only using features supported by this version.
86
86
 
87
87
  ```
88
+
89
+ ##追記2
90
+
91
+ amazon-cloudwatch-agent.json
92
+
93
+ ```
94
+
95
+ {
96
+
97
+ "agent": {
98
+
99
+ "metrics_collection_interval": 60,
100
+
101
+ "run_as_user": "root"
102
+
103
+ },
104
+
105
+ "logs": {
106
+
107
+ "logs_collected": {
108
+
109
+ "files": {
110
+
111
+ "collect_list": [
112
+
113
+ {
114
+
115
+ "file_path": "/var/log/cloudwatch",
116
+
117
+ "log_group_name": "cloudwatch",
118
+
119
+ "log_stream_name": "{instance_id}"
120
+
121
+ }
122
+
123
+ ]
124
+
125
+ }
126
+
127
+ }
128
+
129
+ },
130
+
131
+ "metrics": {
132
+
133
+ "append_dimensions": {
134
+
135
+ "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
136
+
137
+ "ImageId": "${aws:ImageId}",
138
+
139
+ "InstanceId": "${aws:InstanceId}",
140
+
141
+ "InstanceType": "${aws:InstanceType}"
142
+
143
+ },
144
+
145
+ "metrics_collected": {
146
+
147
+ "collectd": {
148
+
149
+ "metrics_aggregation_interval": 60
150
+
151
+ },
152
+
153
+ "disk": {
154
+
155
+ "measurement": [
156
+
157
+ "used_percent"
158
+
159
+ ],
160
+
161
+ "metrics_collection_interval": 60,
162
+
163
+ "resources": [
164
+
165
+ "*"
166
+
167
+ ]
168
+
169
+ },
170
+
171
+ "mem": {
172
+
173
+ "measurement": [
174
+
175
+ "mem_used_percent"
176
+
177
+ ],
178
+
179
+ "metrics_collection_interval": 60
180
+
181
+ },
182
+
183
+ "statsd": {
184
+
185
+ "metrics_aggregation_interval": 60,
186
+
187
+ "metrics_collection_interval": 10,
188
+
189
+ "service_address": ":8125"
190
+
191
+ }
192
+
193
+ }
194
+
195
+ }
196
+
197
+ }
198
+
199
+ ```
200
+
201
+ ログ
202
+
203
+ ```
204
+
205
+ 2020/05/04 12:16:05 I! I! Detected the instance is EC2
206
+
207
+ 2020/05/04 12:16:05 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json ...
208
+
209
+ 2020/05/04 12:16:05 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml ...
210
+
211
+ 2020/05/04 12:16:05 Invalid json format, please check. Reason: unexpected end of JSON input
212
+
213
+ 2020/05/04 12:16:05 I! AmazonCloudWatchAgent Version 1.237768.0.
214
+
215
+ 2020/05/04 12:16:05 Configuration validation first phase failed. Agent version: 1.237768.0. Verify the JSON input is only using features supported by this version.
216
+
217
+
218
+
219
+ 2020/05/04 12:16:05 I! Return exit error: exit code=1
220
+
221
+ 2020/05/04 12:16:05 E! Cannot translate JSON config into TOML, ERROR is exit status 1
222
+
223
+ ```
224
+
225
+ cloudwatch agent のステータス
226
+
227
+ ```
228
+
229
+ # sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
230
+
231
+ {
232
+
233
+ "status": "stopped",
234
+
235
+ "starttime": "",
236
+
237
+ "version": "1.237768.0"
238
+
239
+ }
240
+
241
+ ```

1

追記

2020/05/04 03:21

投稿

lin.ming
lin.ming

スコア50

test CHANGED
File without changes
test CHANGED
@@ -47,3 +47,41 @@
47
47
 
48
48
 
49
49
  ご知見のある方、ご教示お願いします。
50
+
51
+
52
+
53
+ ##追記
54
+
55
+ config に書くこともなかったので、
56
+
57
+ ```
58
+
59
+ # mv common-config.toml common-config.toml.bak
60
+
61
+ # touch common-config.toml
62
+
63
+ ```
64
+
65
+ としたのですが、下記エラーが出ます。
66
+
67
+ ```
68
+
69
+ # /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml -s
70
+
71
+ /opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source file:/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
72
+
73
+ Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml.tmp
74
+
75
+ Start configuration validation...
76
+
77
+ /opt/aws/amazon-cloudwatch-agent/bin/config-translator --input /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --input-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
78
+
79
+ 2020/04/29 20:55:35 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml.tmp ...
80
+
81
+ 2020/04/29 20:55:35 Invalid json format, please check. Reason: unexpected end of JSON input
82
+
83
+ 2020/04/29 20:55:35 I! AmazonCloudWatchAgent Version 1.237768.0.
84
+
85
+ 2020/04/29 20:55:35 Configuration validation first phase failed. Agent version: 1.237768.0. Verify the JSON input is only using features supported by this version.
86
+
87
+ ```