无法在Windows 2016上使用EC2 CloudWatch日志 [英] Unable to use ec2 cloudwatch logs on windows 2016

查看:125
本文介绍了无法在Windows 2016上使用EC2 CloudWatch日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我向用户数据启动添加了程序文件 Amazon SSM Plugins awsCloudWatch AWS.EC2.Windows.Cloudwatch.json文件,并按如下所述重新启动了ssm服务Windows 2016文档。ssm代理日志中没有错误。但是,我看不到运行AWS.Cloudwatch.exe,也没有日志记录到cloudwatch。

I added a \Program Files\Amazon\SSM\Plugins\awsCloudWatch\AWS.EC2.Windows.Cloudwatch.json file as explained to my user-data startup and restarted the ssm service as explained in the documentation for windows 2016. There are no errors in the ssm agent log. However, I do not see AWS.Cloudwatch.exe running, and no logs make it to cloudwatch.

我真的只对应用程序和系统事件日志以及 programdata amazon ecs log目录感兴趣。如果我能正常工作,我也将添加启动日志。

I am really interested in just the application and system event logs and the \programdata\amazon\ecs\log directory. If I get that working, I will add the launch logs too.

我在哪里可以找到线索?我确实尝试手动启动aws.cloudwatch.exe,但不知道配置参数的外观。

Where can I look for clues? I did try starting the aws.cloudwatch.exe manually but don't know what the configuration argument is supposed to look like.

这是我的配置

$ssmconfig = @"
{
    "IsEnabled": true,
    "EngineConfiguration": {
        "PollInterval": "00:00:05",
        "Components": [
            {
                "Id": "ApplicationEventLog",
                "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
                "Parameters": {
                    "LogName": "Application",
                    "Levels": "1"
                }
            },
            {
                "Id": "SystemEventLog",
                "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
                "Parameters": {
                    "LogName": "System",
                    "Levels": "7"
                }
            },
            {
                "Id": "SecurityEventLog",
                "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
                "Parameters": {
                    "LogName": "Security",
                    "Levels": "7"
                }
            },
            {
                "Id": "CustomLogs",
                "FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch",
                "Parameters": {
                    "LogDirectoryPath": "C:\\ProgramData\\Amazon\ECS\Log
    ",
    "TimestampFormat": "MM/dd/yyyy HH:mm:ss",
                    "Encoding": "UTF-8",
                    "Filter": "",
                    "CultureName": "en-US",
                    "TimeZoneKind": "Local"
                }
            },
            {
                "Id": "CloudWatchLogs",
                "FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
                "Parameters": {
                    "Region": "MYREGION}",
                    "LogGroup": "MYLOGGGROUP/win-host-eventlog",
                    "LogStream": "THISINSTANCEID"
                }
            },
            {
                "Id": "CloudWatchEcsLogs",
                "FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
                "Parameters": {
                    "Region": "MYREGION",
                    "LogGroup": "MYLOGGROUP/win-host-ecs-logs",
                    "LogStream": "THISINSTANCEID"
                }
            }
        ],
        "Flows": {
            "Flows": [
                "(ApplicationEventLog,SystemEventLog),CloudWatchLogs"
"CustomLogs,CloudWatchEcsLogs"
            ]
        }
    }
}
"@

Add-Content "C:\Program Files\Amazon\SSM\Plugins\awsCloudWatch\AWS.ECS.Windows.CloudWatch.json"     $ssmconfig
Restart-Service AmazonSSMAgent

`

推荐答案

根据文档
AWS Windows中不包含EC2Config服务2016 AMI,您需要手动安装。安装,运行它,启用日志集成并更新位于以下路径中的JSON文件(通常):

According to the documentation: The EC2Config service is not included in AWS Windows 2016 AMIs and you need to install it manually. Install it, run it, enable log integration, and update the JSON file (normally) located in the following path:

C:\Program Files\Amazon\SSM\Plugins\awsCloudWatch

这是我的配置在我的服务器上。它工作正常,并且我同时获得了日志和性能指标。

Here is the configuration I have on my servers. It works fine and I get both logs and performance metrics.

{
    "IsEnabled": true,
    "EngineConfiguration": {
        "Components": [{
            "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "ApplicationEventLog",
            "Parameters": {
                "Levels": "1",
                "LogName": "Application" 
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "SystemEventLog",
            "Parameters": {
                "Levels": "7",
                "LogName": "System"
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "SecurityEventLog",
            "Parameters": {
                "Levels": "7",
                "LogName": "Security"
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "ETW",
            "Parameters": {
                "Levels": "7",
                "LogName": "Microsoft-Windows-WinINet/Analytic"
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.IisLog.IisLogInputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "IISLog",
            "Parameters": {
                "LogDirectoryPath": "C:\\inetpub\\logs\\LogFiles\\W3SVC1"
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "CustomLogs",
            "Parameters": {
                "CultureName": "en-US",
                "Encoding": "UTF-8",
                "Filter": "",
                "LogDirectoryPath": "C:\\Logs\\",
                "TimeZoneKind": "Local",
                "TimestampFormat": "yyyy-MM-dd HH:mm:ss"
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "PerformanceCounterMemory",
            "Parameters": {
                "CategoryName": "Memory",
                "CounterName": "Available MBytes",
                "DimensionName": "InstanceId",
                "DimensionValue": "{instance_id}",
                "InstanceName": "",
                "MetricName": "Memory",
                "Unit": "Megabytes"
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "PerformanceCounterDisk",
            "Parameters": {
                "CategoryName": "LogicalDisk",
                "CounterName": "Free Megabytes",
                "DimensionName": "InstanceId",
                "DimensionValue": "{instance_id}",
                "InstanceName": "D:",
                "MetricName": "FreeDisk",
                "Unit": "Megabytes"
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
            "Id": "CloudWatchLogs",
            "Parameters": {
                "AccessKey": "",
                "LogGroup": "ASG",
                "LogStream": "{instance_id}",
                "Region": "eu-west-1",
                "SecretKey": ""
            }
        }, {
            "FullName": "AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch",
            "Id": "CloudWatch",
            "Parameters": {
                "AccessKey": "",
                "NameSpace": "PerformanceMonitor",
                "Region": "eu-west-1",
                "SecretKey": ""
            }
        }],
        "Flows": {
            "Flows": [
                "(PerformanceCounterMemory,PerformanceCounterDisk),CloudWatch",
                "(ApplicationEventLog,SystemEventLog),CloudWatchLogs"
            ]
        },
        "PollInterval": "00:00:15"
    }
}

这篇关于无法在Windows 2016上使用EC2 CloudWatch日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆