ssm activate
create new activation
https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/what-is-systems-manager.html
execute this cmd by windows power shell
.ps1
$code = "activation-code"
$id = "activation-id"
$region = "region"
$dir = $env:TEMP + "\ssm"
New-Item -ItemType directory -Path $dir -Force
cd $dir
(New-Object System.Net.WebClient).DownloadFile("https://amazon-ssm-$region.s3.amazonaws.com/latest/windows_amd64/AmazonSSMAgentSetup.exe", $dir + "\AmazonSSMAgentSetup.exe")
Start-Process .\AmazonSSMAgentSetup.exe -ArgumentList @("/q", "/log", "install.log", "CODE=$code", "ID=$id", "REGION=$region") -Wait
Get-Content ($env:ProgramData + "\Amazon\SSM\InstanceData\registration")
Get-Service -Name "AmazonSSMAgent"
install aws-cli
setup cloudwatch agent
aws configure --profile AmazonCloudWatchAgent
ConfigureCloudWatch
use Run Coomand
https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/WindowsGuide/send_logs_to_cwl_instances.html
- Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
- In the navigation pane, choose Systems Manager Services, Run Command.
- Choose Run a command.
- For Command document, choose AWS-ConfigureCloudWatch.
- For Target instances, choose the instances to integrate with CloudWatch. If you do not see an instance in this list, it might not be configured for Run Command. For more information, see Systems Manager Prerequisites in the AWS Systems Manager User Guide.
- For Status, choose Enabled.
- For Properties, copy and paste your JSON content.
- Complete the remaining optional fields and choose Run.
this is my json configuration
send processor , memory and TcpConnections
.json
{
"IsEnabled": true,
"EngineConfiguration": {
"PollInterval": "00:00:15",
"Components": [
{
"Id": "ProcessorTime",
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"CategoryName": "Processor Information",
"CounterName": "% Processor Time",
"InstanceName": "_Total",
"MetricName": "Processor Use",
"Unit": "Percent",
"DimensionName": "hostname",
"DimensionValue": "{hostname}"
}
},
{
"Id": "Memory",
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"CategoryName": "Memory",
"CounterName": "Available MBytes",
"InstanceName": "",
"MetricName": "Memory",
"Unit": "Megabytes",
"DimensionName": "hostname",
"DimensionValue": "{hostname}"
}
},
{
"Id": "TcpConnections",
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"CategoryName": "TCPv4",
"CounterName": "Connections Established",
"InstanceName": "",
"MetricName": "TcpConnections",
"Unit": "Count",
"DimensionName": "hostname",
"DimensionValue": "{hostname}"
}
},
{
"Id": "CloudWatch",
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters":
{
"AccessKey": "",
"SecretKey": "",
"Region": "",
"NameSpace": ""
}
}
],
"Flows": {
"Flows":
[
"ProcessorTime,CloudWatch",
"Memory,CloudWatch",
"TcpConnections,CloudWatch"
]
}
}
}