Windows服务器的AWS CloudWatch代理未启动
我一直在尝试设置AWS CloudWatch代理,但是它一直在给我错误,我尝试使用配置文件生成器以及将配置器手动放置在指定的位置中,日志也没有太大帮助。 我已经将CloudWatchagentserver角色附加到了实例中,该实例在公共子网中,并且允许Internet流量,我遵循AWS文档安装代理。
以下是命令正在生成
2022/07/01 06:26:29 I! Return exit error: exit code=99
2022/07/01 06:26:29 I! there is no json configuration when running translator
2022/07/01 06:33:09 I! 2022/07/01 06:33:09 D! [EC2] Found active network interface
I! Detected the instance is EC2
2022/07/01 06:33:09 Reading json config file path: C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json ...
C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json does not exist or cannot read. Skipping it.
No json config files found, please provide config, exit now
PS C:\Users\Administrator> & $env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:$env:ProgramFiles\Amazon\AmazonCloudWatchAgent\config.json -s
****** processing amazon-cloudwatch-agent ******
I! Trying to detect region from ec2
2022/07/04 06:10:33 D! [EC2] Found active network interface
2022/07/04 06:10:34 E! Fail to fetch/remove json config: open C:\Program: The system cannot find the file specified.
E! Fail to fetch/remove json config: open C:\Program: The system cannot find the file specified.
Fail to fetch the config!
我下载代理的日志 -
Invoke-WebRequest -Uri https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi -OutFile $env:USERPROFILE\Desktop\amazon-cloudwatch-agent.msi
我正在使用的配置文件 -
{
"logs": {
"logs_collected": {
"windows_events": {
"collect_list": [
{
"event_format": "xml",
"event_levels": [
"ERROR",
"CRITICAL"
],
"event_name": "System",
"log_group_name": "WindowEvents",
"log_stream_name": "{instance_id}",
"retention_in_days": 1
}
]
}
}
},
"metrics": {
"aggregation_dimensions": [
[
"InstanceId"
]
],
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"LogicalDisk": {
"measurement": [
"% Free Space"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Memory": {
"measurement": [
"% Committed Bytes In Use"
],
"metrics_collection_interval": 60
},
"Paging File": {
"measurement": [
"% Usage"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"PhysicalDisk": {
"measurement": [
"% Disk Time",
"Disk Write Bytes/sec",
"Disk Read Bytes/sec",
"Disk Writes/sec",
"Disk Reads/sec"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Processor": {
"measurement": [
"% User Time",
"% Idle Time",
"% Interrupt Time"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"TCPv4": {
"measurement": [
"Connections Established"
],
"metrics_collection_interval": 60
},
"TCPv6": {
"measurement": [
"Connections Established"
],
"metrics_collection_interval": 60
},
"statsd": {
"metrics_aggregation_interval": 60,
"metrics_collection_interval": 60,
"service_address": ":8125"
}
}
}
}
I have been trying to setup the AWS CloudWatch agent but it has been constantly giving me error, I have tried using the config file generator as well as placing the config.json file manually in the specified location, the logs are not much help either.
I have attached the CloudWatchAgentServer role to the instance, the instance is in public subnet and internet traffic is allowed, I have followed the AWS docs to install the agent.
Below are the logs the command is generating
2022/07/01 06:26:29 I! Return exit error: exit code=99
2022/07/01 06:26:29 I! there is no json configuration when running translator
2022/07/01 06:33:09 I! 2022/07/01 06:33:09 D! [EC2] Found active network interface
I! Detected the instance is EC2
2022/07/01 06:33:09 Reading json config file path: C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json ...
C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json does not exist or cannot read. Skipping it.
No json config files found, please provide config, exit now
PS C:\Users\Administrator> & $env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:$env:ProgramFiles\Amazon\AmazonCloudWatchAgent\config.json -s
****** processing amazon-cloudwatch-agent ******
I! Trying to detect region from ec2
2022/07/04 06:10:33 D! [EC2] Found active network interface
2022/07/04 06:10:34 E! Fail to fetch/remove json config: open C:\Program: The system cannot find the file specified.
E! Fail to fetch/remove json config: open C:\Program: The system cannot find the file specified.
Fail to fetch the config!
How I downloaded the agent -
Invoke-WebRequest -Uri https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi -OutFile $env:USERPROFILE\Desktop\amazon-cloudwatch-agent.msi
What config file I am using -
{
"logs": {
"logs_collected": {
"windows_events": {
"collect_list": [
{
"event_format": "xml",
"event_levels": [
"ERROR",
"CRITICAL"
],
"event_name": "System",
"log_group_name": "WindowEvents",
"log_stream_name": "{instance_id}",
"retention_in_days": 1
}
]
}
}
},
"metrics": {
"aggregation_dimensions": [
[
"InstanceId"
]
],
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"LogicalDisk": {
"measurement": [
"% Free Space"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Memory": {
"measurement": [
"% Committed Bytes In Use"
],
"metrics_collection_interval": 60
},
"Paging File": {
"measurement": [
"% Usage"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"PhysicalDisk": {
"measurement": [
"% Disk Time",
"Disk Write Bytes/sec",
"Disk Read Bytes/sec",
"Disk Writes/sec",
"Disk Reads/sec"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Processor": {
"measurement": [
"% User Time",
"% Idle Time",
"% Interrupt Time"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"TCPv4": {
"measurement": [
"Connections Established"
],
"metrics_collection_interval": 60
},
"TCPv6": {
"measurement": [
"Connections Established"
],
"metrics_collection_interval": 60
},
"statsd": {
"metrics_aggregation_interval": 60,
"metrics_collection_interval": 60,
"service_address": ":8125"
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误消息:
表明您正在经过的路径无法正确评估。
通过这样的路径时,您需要使用双引号:
This error message:
Indicates that the path you are passing through isn't being evaluated properly.
You need to use double quotes when passing such a path, like this: