質問編集履歴
5
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,8 +6,9 @@
|
|
6
6
|
|
7
7
|
common-config.toml の設定は、オプションと書いてあったので、修正していません。
|
8
8
|
#エラーになった箇所
|
9
|
-
```# /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
|
10
9
|
```
|
10
|
+
# /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
|
11
|
+
```
|
11
12
|
##知りたいこと
|
12
13
|
JSON の形式がおかしいとのことですが、どのように直せばいいかわかりません。
|
13
14
|
|
4
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,17 +7,6 @@
|
|
7
7
|
common-config.toml の設定は、オプションと書いてあったので、修正していません。
|
8
8
|
#エラーになった箇所
|
9
9
|
```# /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
|
10
|
-
/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
|
11
|
-
Got Home directory: /root
|
12
|
-
I! Set home dir Linux: /root
|
13
|
-
I! SDKRegionWithCredsMap region: ap-northeast-1
|
14
|
-
Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml.tmp
|
15
|
-
Start configuration validation...
|
16
|
-
/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
|
17
|
-
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 ...
|
18
|
-
2020/04/29 18:00:20 Invalid json format, please check. Reason: invalid character '#' looking for beginning of value
|
19
|
-
2020/04/29 18:00:20 I! AmazonCloudWatchAgent Version 1.237768.0.
|
20
|
-
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.
|
21
10
|
```
|
22
11
|
##知りたいこと
|
23
12
|
JSON の形式がおかしいとのことですが、どのように直せばいいかわかりません。
|
@@ -224,4 +213,98 @@
|
|
224
213
|
caused by: FailedRead: unable to open file
|
225
214
|
caused by: open /root/.aws/credentials: permission denied, metrics will be dropped until it got fixed
|
226
215
|
```
|
227
|
-
credentials が読めないとありますが、どうしたら読めるようになりますか?
|
216
|
+
credentials が読めないとありますが、どうしたら読めるようになりますか?
|
217
|
+
|
218
|
+
##追記4
|
219
|
+
```
|
220
|
+
# ps aux | grep cloud
|
221
|
+
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
|
222
|
+
```
|
223
|
+
```
|
224
|
+
# cat amazon-cloudwatch-agent.toml
|
225
|
+
[agent]
|
226
|
+
collection_jitter = "0s"
|
227
|
+
debug = false
|
228
|
+
flush_interval = "1s"
|
229
|
+
flush_jitter = "0s"
|
230
|
+
hostname = ""
|
231
|
+
interval = "60s"
|
232
|
+
logfile = "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"
|
233
|
+
metric_batch_size = 1000
|
234
|
+
metric_buffer_limit = 10000
|
235
|
+
omit_hostname = false
|
236
|
+
precision = ""
|
237
|
+
quiet = false
|
238
|
+
round_interval = false
|
239
|
+
|
240
|
+
[inputs]
|
241
|
+
|
242
|
+
[[inputs.disk]]
|
243
|
+
drop_device = false
|
244
|
+
fieldpass = ["used_percent"]
|
245
|
+
[inputs.disk.tags]
|
246
|
+
metricPath = "metrics"
|
247
|
+
|
248
|
+
[[inputs.mem]]
|
249
|
+
fieldpass = ["used_percent"]
|
250
|
+
[inputs.mem.tags]
|
251
|
+
metricPath = "metrics"
|
252
|
+
|
253
|
+
[outputs]
|
254
|
+
|
255
|
+
[[outputs.cloudwatch]]
|
256
|
+
force_flush_interval = "60s"
|
257
|
+
namespace = "CWAgent"
|
258
|
+
region = "ap-northeast-1"
|
259
|
+
shared_credential_file = "/root/.aws/credentials"
|
260
|
+
tagexclude = ["host", "metricPath"]
|
261
|
+
[outputs.cloudwatch.tagpass]
|
262
|
+
metricPath = ["metrics"]
|
263
|
+
|
264
|
+
[processors]
|
265
|
+
|
266
|
+
[[processors.ec2tagger]]
|
267
|
+
ec2_instance_tag_keys = ["aws:autoscaling:groupName"]
|
268
|
+
ec2_metadata_tags = ["ImageId", "InstanceId", "InstanceType"]
|
269
|
+
refresh_interval_seconds = "2147483647s"
|
270
|
+
shared_credential_file = "/root/.aws/credentials"
|
271
|
+
[processors.ec2tagger.tagpass]
|
272
|
+
metricPath = ["metrics"]
|
273
|
+
```
|
274
|
+
```
|
275
|
+
# cat common-config.toml
|
276
|
+
[credentials]
|
277
|
+
shared_credential_file = "/root/.aws/credentials"
|
278
|
+
```
|
279
|
+
```
|
280
|
+
# cat default
|
281
|
+
|
282
|
+
{
|
283
|
+
"agent": {
|
284
|
+
"run_as_user": "cwagent"
|
285
|
+
},
|
286
|
+
"metrics": {
|
287
|
+
"metrics_collected": {
|
288
|
+
"mem": {
|
289
|
+
"measurement": [
|
290
|
+
"mem_used_percent"
|
291
|
+
]
|
292
|
+
},
|
293
|
+
"disk": {
|
294
|
+
"measurement": [
|
295
|
+
"used_percent"
|
296
|
+
],
|
297
|
+
"resources": [
|
298
|
+
"*"
|
299
|
+
]
|
300
|
+
}
|
301
|
+
},
|
302
|
+
"append_dimensions": {
|
303
|
+
"ImageId": "${aws:ImageId}",
|
304
|
+
"InstanceId": "${aws:InstanceId}",
|
305
|
+
"InstanceType": "${aws:InstanceType}",
|
306
|
+
"AutoScalingGroupName": "${aws:AutoScalingGroupName}"
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
```
|
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -118,4 +118,110 @@
|
|
118
118
|
"starttime": "",
|
119
119
|
"version": "1.237768.0"
|
120
120
|
}
|
121
|
-
```
|
121
|
+
```
|
122
|
+
##追記3
|
123
|
+
config.json
|
124
|
+
```
|
125
|
+
{
|
126
|
+
"agent": {
|
127
|
+
"metrics_collection_interval": 10,
|
128
|
+
"run_as_user": "root"
|
129
|
+
},
|
130
|
+
"logs": {
|
131
|
+
"logs_collected": {
|
132
|
+
"files": {
|
133
|
+
"collect_list": [
|
134
|
+
{
|
135
|
+
"file_path": "/var/log/messages",
|
136
|
+
"log_group_name": "messages",
|
137
|
+
"log_stream_name": "{instance_id}"
|
138
|
+
}
|
139
|
+
]
|
140
|
+
}
|
141
|
+
}
|
142
|
+
},
|
143
|
+
"metrics": {
|
144
|
+
"append_dimensions": {
|
145
|
+
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
|
146
|
+
"ImageId": "${aws:ImageId}",
|
147
|
+
"InstanceId": "${aws:InstanceId}",
|
148
|
+
"InstanceType": "${aws:InstanceType}"
|
149
|
+
},
|
150
|
+
"metrics_collected": {
|
151
|
+
"collectd": {
|
152
|
+
"metrics_aggregation_interval": 60
|
153
|
+
},
|
154
|
+
"cpu": {
|
155
|
+
"measurement": [
|
156
|
+
"cpu_usage_idle",
|
157
|
+
"cpu_usage_iowait",
|
158
|
+
"cpu_usage_user",
|
159
|
+
"cpu_usage_system"
|
160
|
+
],
|
161
|
+
"metrics_collection_interval": 10,
|
162
|
+
"resources": [
|
163
|
+
"*"
|
164
|
+
],
|
165
|
+
"totalcpu": false
|
166
|
+
},
|
167
|
+
"disk": {
|
168
|
+
"measurement": [
|
169
|
+
"used_percent",
|
170
|
+
"inodes_free"
|
171
|
+
],
|
172
|
+
"metrics_collection_interval": 10,
|
173
|
+
"resources": [
|
174
|
+
"*"
|
175
|
+
]
|
176
|
+
},
|
177
|
+
"diskio": {
|
178
|
+
"measurement": [
|
179
|
+
"io_time",
|
180
|
+
"write_bytes",
|
181
|
+
"read_bytes",
|
182
|
+
"writes",
|
183
|
+
"reads"
|
184
|
+
],
|
185
|
+
"metrics_collection_interval": 10,
|
186
|
+
"resources": [
|
187
|
+
"*"
|
188
|
+
]
|
189
|
+
},
|
190
|
+
"mem": {
|
191
|
+
"measurement": [
|
192
|
+
"mem_used_percent"
|
193
|
+
],
|
194
|
+
"metrics_collection_interval": 10
|
195
|
+
},
|
196
|
+
"netstat": {
|
197
|
+
"measurement": [
|
198
|
+
"tcp_established",
|
199
|
+
"tcp_time_wait"
|
200
|
+
],
|
201
|
+
"metrics_collection_interval": 10
|
202
|
+
},
|
203
|
+
"statsd": {
|
204
|
+
"metrics_aggregation_interval": 60,
|
205
|
+
"metrics_collection_interval": 10,
|
206
|
+
"service_address": ":8125"
|
207
|
+
},
|
208
|
+
"swap": {
|
209
|
+
"measurement": [
|
210
|
+
"swap_used_percent"
|
211
|
+
],
|
212
|
+
"metrics_collection_interval": 10
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}
|
216
|
+
}
|
217
|
+
```
|
218
|
+
/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log
|
219
|
+
```
|
220
|
+
2020-05-19T08:06:17Z E! refresh EC2 Instance Tags failed: SharedCredsLoad: failed to load shared credentials file
|
221
|
+
caused by: FailedRead: unable to open file
|
222
|
+
caused by: open /root/.aws/credentials: permission denied, metrics will be dropped until it got fixed
|
223
|
+
2020-05-19T08:16:17Z E! refresh EC2 Instance Tags failed: SharedCredsLoad: failed to load shared credentials file
|
224
|
+
caused by: FailedRead: unable to open file
|
225
|
+
caused by: open /root/.aws/credentials: permission denied, metrics will be dropped until it got fixed
|
226
|
+
```
|
227
|
+
credentials が読めないとありますが、どうしたら読めるようになりますか?
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -41,4 +41,81 @@
|
|
41
41
|
2020/04/29 20:55:35 Invalid json format, please check. Reason: unexpected end of JSON input
|
42
42
|
2020/04/29 20:55:35 I! AmazonCloudWatchAgent Version 1.237768.0.
|
43
43
|
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.
|
44
|
+
```
|
45
|
+
##追記2
|
46
|
+
amazon-cloudwatch-agent.json
|
47
|
+
```
|
48
|
+
{
|
49
|
+
"agent": {
|
50
|
+
"metrics_collection_interval": 60,
|
51
|
+
"run_as_user": "root"
|
52
|
+
},
|
53
|
+
"logs": {
|
54
|
+
"logs_collected": {
|
55
|
+
"files": {
|
56
|
+
"collect_list": [
|
57
|
+
{
|
58
|
+
"file_path": "/var/log/cloudwatch",
|
59
|
+
"log_group_name": "cloudwatch",
|
60
|
+
"log_stream_name": "{instance_id}"
|
61
|
+
}
|
62
|
+
]
|
63
|
+
}
|
64
|
+
}
|
65
|
+
},
|
66
|
+
"metrics": {
|
67
|
+
"append_dimensions": {
|
68
|
+
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
|
69
|
+
"ImageId": "${aws:ImageId}",
|
70
|
+
"InstanceId": "${aws:InstanceId}",
|
71
|
+
"InstanceType": "${aws:InstanceType}"
|
72
|
+
},
|
73
|
+
"metrics_collected": {
|
74
|
+
"collectd": {
|
75
|
+
"metrics_aggregation_interval": 60
|
76
|
+
},
|
77
|
+
"disk": {
|
78
|
+
"measurement": [
|
79
|
+
"used_percent"
|
80
|
+
],
|
81
|
+
"metrics_collection_interval": 60,
|
82
|
+
"resources": [
|
83
|
+
"*"
|
84
|
+
]
|
85
|
+
},
|
86
|
+
"mem": {
|
87
|
+
"measurement": [
|
88
|
+
"mem_used_percent"
|
89
|
+
],
|
90
|
+
"metrics_collection_interval": 60
|
91
|
+
},
|
92
|
+
"statsd": {
|
93
|
+
"metrics_aggregation_interval": 60,
|
94
|
+
"metrics_collection_interval": 10,
|
95
|
+
"service_address": ":8125"
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
```
|
101
|
+
ログ
|
102
|
+
```
|
103
|
+
2020/05/04 12:16:05 I! I! Detected the instance is EC2
|
104
|
+
2020/05/04 12:16:05 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json ...
|
105
|
+
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 ...
|
106
|
+
2020/05/04 12:16:05 Invalid json format, please check. Reason: unexpected end of JSON input
|
107
|
+
2020/05/04 12:16:05 I! AmazonCloudWatchAgent Version 1.237768.0.
|
108
|
+
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.
|
109
|
+
|
110
|
+
2020/05/04 12:16:05 I! Return exit error: exit code=1
|
111
|
+
2020/05/04 12:16:05 E! Cannot translate JSON config into TOML, ERROR is exit status 1
|
112
|
+
```
|
113
|
+
cloudwatch agent のステータス
|
114
|
+
```
|
115
|
+
# sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
|
116
|
+
{
|
117
|
+
"status": "stopped",
|
118
|
+
"starttime": "",
|
119
|
+
"version": "1.237768.0"
|
120
|
+
}
|
44
121
|
```
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -22,4 +22,23 @@
|
|
22
22
|
##知りたいこと
|
23
23
|
JSON の形式がおかしいとのことですが、どのように直せばいいかわかりません。
|
24
24
|
|
25
|
-
ご知見のある方、ご教示お願いします。
|
25
|
+
ご知見のある方、ご教示お願いします。
|
26
|
+
|
27
|
+
##追記
|
28
|
+
config に書くこともなかったので、
|
29
|
+
```
|
30
|
+
# mv common-config.toml common-config.toml.bak
|
31
|
+
# touch common-config.toml
|
32
|
+
```
|
33
|
+
としたのですが、下記エラーが出ます。
|
34
|
+
```
|
35
|
+
# /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
|
36
|
+
/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
|
37
|
+
Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_common-config.toml.tmp
|
38
|
+
Start configuration validation...
|
39
|
+
/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
|
40
|
+
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 ...
|
41
|
+
2020/04/29 20:55:35 Invalid json format, please check. Reason: unexpected end of JSON input
|
42
|
+
2020/04/29 20:55:35 I! AmazonCloudWatchAgent Version 1.237768.0.
|
43
|
+
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.
|
44
|
+
```
|