Windows用のCloudWatch エージェント設定ファイルを手動で作成してみた


この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので十分ご注意ください。

背景

WSUSサーバにCloudwatch agentをインストールし、カスタムメトリクスなどを検証しました。忘録として設定ファイルを残していきたいと思います。

設定ファイル

{
  "logs": {
    "logs_collected": {
      "files": {
        "collect_list": [
          {
            "file_path": "C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Logs\\amazon-cloudwatch-agent.log",
            "log_group_name": "Windows_AmazonCloudWatchAgentLog",
            "encoding": "shift_jis",
            "log_stream_name": "{instance_id}"
          },

          {
            "file_path": "C:\\ProgramData\\Amazon\\SSM\\Logs\\amazon-ssm-agent.log",
            "log_group_name": "ssm",
            "encoding": "shift_jis",
            "log_stream_name": "{instance_id}_Windows_ssm-agentlog"
          },
          {
            "file_path": "C:\\ProgramData\\Amazon\\SSM\\Logs\\errors.log",
            "log_group_name": "ssm",
            "encoding": "shift_jis",
            "log_stream_name": "{instance_id}_Windows_ssm-errorslog"
          },
          {
            "file_path": "C:\\ProgramData\\Amazon\\SSM\\Logs\\audits\\amazon-ssm-agent-audit*",
            "log_group_name": "ssm",
            "encoding": "shift_jis",
            "log_stream_name": "{instance_id}_Windows_ssm-auditslog"
          },

      "windows_events": {
        "collect_list": [
        {
            "event_name": "System",
            "event_levels": [
                "VERBOSE",
                "INFORMATION",
                "WARNING",
                "ERROR",
                "CRITICAL"
            ],
            "log_group_name": "Windows_SystemEventLog",
            "log_stream_name": "{instance_id}_Windows_SystemEventLog"
        },
        {
            "event_name": "Security",
            "event_levels": [
                "VERBOSE",
                "INFORMATION",
                "WARNING",
                "ERROR",
                "CRITICAL"
            ],
            "log_group_name": "Windows_SecurityEventLog",
            "log_stream_name": "{instance_id}_Windows_SecurityEventLog"
        },
        {
            "event_name": "Application",
            "event_levels": [
                "VERBOSE",
                "INFORMATION",
                "WARNING",
                "ERROR",
                "CRITICAL"
            ],
            "log_group_name": "Windows_ApplicationEventLog",
            "log_stream_name": "{instance_id}_Windows_ApplicationEventLog"
        }
        ]
    }

    },

    "force_flush_interval" : 1
  },

  "metrics": {
      "append_dimensions": {
          "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
          "ImageId": "${aws:ImageId}",
          "InstanceId": "${aws:InstanceId}",
          "InstanceType": "${aws:InstanceType}"
      },
      "namespace": "CW_WSUS",
      "metrics_collected": {
          "LogicalDisk":{
              "measurement":[
                {
                    "name":"% Free Space",
                    "rename":"FreeStorageSpaceInPercent",
                    "unit":"Percent"
                },
                {
                    "name":"Free Megabytes",
                    "rename":"FreeStorageSpaceInMB",
                    "unit":"Megabytes"
                }
              ],
              "resources":[
                  "C:",
                  "D:",
                  "_Total"
              ]
            },
            "Memory":{
              "metrics_collection_interval":300,
              "measurement":[
                {
                    "name":"% Committed Bytes In Use",
                    "rename":"MemoryUtilization",
                    "unit":"Percent"
                },
                {
                    "name":"Pages/Sec",
                    "rename":"PagesRetreivedPerSecFromDisk",
                    "unit":"Count/Second"
                }
              ]
            },
          "Paging File": {
              "measurement": [
                  "% Usage"
              ],
              "metrics_collection_interval": 300,
              "resources": [
                  "*"
              ]
          },
          "PhysicalDisk": {
              "measurement": [
                  "% Disk Time"
              ],
              "metrics_collection_interval": 300,
              "resources": [
                  "*"
              ]
          },
          "Processor":{
              "measurement":[
                  {
                    "name":"% Processor Time",
                    "rename":"CPUUtilization",
                    "unit":"Percent"
                  }
              ],
              "resources":[
                  "_Total"
              ]
            }
      }
  }
}

まとめ

以上、Windows用のCloudWatch エージェント設定ファイルを紹介しました。次回、LinuxのCloudWatch エージェント設定ファイルを紹介したいと思います。

参照リンク

https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html

https://oji-cloud.net/2019/08/19/post-2770/

https://blog.serverworks.co.jp/2021/11/05/134906

https://cloud5.jp/metrics-monitoring-windows/

Last modified: 2023-06-29

Author