gpt4 book ai didi

amazon-web-services - 如何在运行Windows的ElasticBeanstalk环境中启用CloudWatchLogs?

转载 作者:行者123 更新时间:2023-12-04 00:14:34 26 4
gpt4 key购买 nike

我有一个将数据假脱机到平面文件的Web服务。在非EC2原始Windows实例中,我们使用EC2Config服务将日志文件和一些性能计数器泵送到CloudWatch(请参阅此处:http://blogs.aws.amazon.com/application-management/post/Tx1KG4IKXZ94QFK/Using-CloudWatch-Logs-with-Amazon-EC2-Running-Microsoft-Windows-Server)。

如何配置我的应用程序和ElasticBeanstalk以在Windows实例中启用CloudWatch Logging?

最佳答案

为此,我使用.ebextensions文件。以下cloudwatch.config文件位于应用程序根目录的.ebextensions目录中。它安装代理,将其设置为服务,并更新配置。度量是从perfmon可用的列表中选择的。

packages:
msi:
cloudwatch: https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi
services:
windows:
AmazonCloudWatchAgent:
enabled: 'true'
ensureRunning: 'true'
files:
- "C:/ProgramData/Amazon/AmazonCloudWatchAgent/amazon-cloudwatch-agent.json"
files:
"C:/ProgramData/Amazon/AmazonCloudWatchAgent/amazon-cloudwatch-agent.json":
content: |
{
"metrics": {
"namespace": "suprep",
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"LogicalDisk": {
"measurement": [
"% Free Space",
"Avg. Disk Bytes/Transfer"
],
"metrics_collection_interval": 60,
"resources": [
"C:"
]
},
"Memory": {
"measurement": [
"Available MBytes",
"Page Faults/sec",
"% Committed Bytes In Use"
],
"metrics_collection_interval": 60
},
"Network Interface": {
"measurement": [
"Bytes Total/sec"
],
"metrics_collection_interval": 60,
"resources": [
"_Total"
]
},
"Paging File": {
"measurement": [
"% Usage"
],
"metrics_collection_interval": 60,
"resources": [
"_Total"
]
},
"Process": {
"measurement": [
"% Processor Time",
"Private Bytes"
],
"metrics_collection_interval": 60,
"resources": [
"dotnet"
]
}
}
},
"aggregation_dimensions" : [["AutoScalingGroupName"], ["InstanceId"],[]],
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "c:\\Windows\\Temp\\log*.txt",
"log_group_name": "MyLogGroup",
"timezone": "UTC"
}
]
},
"windows_events": {
"collect_list": [
{
"event_name": "System",
"event_levels": [
"WARNING",
"ERROR"
],
"log_group_name": "MyLogGroup",
"log_stream_name": "System",
"event_format": "xml"
},
{
"event_name": "Application",
"event_levels": [
"WARNING",
"ERROR"
],
"log_group_name": "MyLogGroup",
"log_stream_name": "Application",
"event_format": "xml"
}
]
}
},
"log_stream_name": "MyLogStream"
}
}
commands:
01_stop_service:
command: powershell -NoProfile -ExecutionPolicy Bypass -Command "C:\\'Program Files'\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1 -a stop"
02_start_service:
command: powershell -NoProfile -ExecutionPolicy Bypass -Command "C:\\'Program Files'\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json -s"

关于amazon-web-services - 如何在运行Windows的ElasticBeanstalk环境中启用CloudWatchLogs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28035945/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com