1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Use cloud watch metrics by onpremiss winodows server

Last updated at Posted at 2018-07-11

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

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. In the navigation pane, choose Systems Manager Services, Run Command.
  3. Choose Run a command.
  4. For Command document, choose AWS-ConfigureCloudWatch.
  5. 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.
  6. For Status, choose Enabled.
  7. For Properties, copy and paste your JSON content.
  8. 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"
            ]
        }
    }
}


1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?