Upgrade to Pro — share decks privately, control downloads, hide ads and more …

オンプレミス市監視村の人達と学ぶCloudWatch基礎

 オンプレミス市監視村の人達と学ぶCloudWatch基礎

Toru_Kubota

August 21, 2024
Tweet

More Decks by Toru_Kubota

Other Decks in Technology

Transcript

  1. CloudWatch Agentを入れる 間隔は指定可能 有料 自動的に有効になる 基本5分間隔 無料 CPU使用率 EC2ステータス メモリ使用率

    ディスク使用率 メトリクス 設定で有効にする 1分間隔 有料 EC2を例に ・・・・・・・ ・・・・・・・ 基本モニタリング カスタムメトリクス 詳細モニタリング 赤枠が前のページの 「作ると有効になる」 とこね!
  2. Amazon CloudWatch カスタムメトリクス → サーバの中から取得 基本モニタリング → サーバの外から取得 メモリ使用率 ディスク使用率

    ・・・・・・・ CPU使用率 EC2ステータス ・・・・・・・ CloudWatch Agent 余談 サーバの中から取るものと 外から取るもの
  3. CloudWatch Logsだと ログ ログ ログ CloudWatch Logs Alarm Amazon EC2

    AWS Transit Gateway Amazon VPC もう作らなくていいんですね!
  4. CloudWatch Logs → VPCを例に → VPCFlowlogsを作成する。 Amazon VPC 2024-07-14T06:48:04.000+09:002 123456789012

    eni-12345678901234567 192.168.1.10 10.1.1.10 443 37344 6 26 7481 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 37344 443 6 20 6039 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 50948 6 27 7527 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 50948 443 6 20 6141 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 50956 6 25 7149 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 50956 443 6 17 3869 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 37344 6 26 7481 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 37344 443 6 20 6039 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 50948 6 27 7527 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 50948 443 6 20 6141 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 50956 6 25 7149 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 50956 443 6 17 3869 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 37344 6 26 7481 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 37344 443 6 20 6039 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 50948 6 27 7527 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 50948 443 6 20 6141 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 50956 6 25 7149 1720907284 1720907320 ACCEPT OK 2024-07-14T06:48:04.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 50956 443 6 17 3869 1720907284 1720907320 ACCEPT OK 2024-07-14T06:49:05.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 35498 6 4 184 1720907345 1720907345 ACCEPT OK 2024-07-14T06:49:05.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 35498 443 6 4 160 1720907345 1720907345 ACCEPT OK 2024-07-14T06:49:48.000+09:002 123456789012 eni-12345678901234567 xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 443 45420 6 21 6947 1720907388 1720907389 ACCEPT OK
  5. CloudWatch Logs → VPCを例に CloudWatch Logs Insightsで見やすく Amazon CloudWatch fields

    @timestamp, srcAddr, srcPort, dstAddr, dstPort, srcPort, action, protocol
  6. CloudWatch Logs → VPCを例に ENI毎の通信量TOP10 Amazon CloudWatch fields @timestamp, @message

    | stats sum(bytes) as TotalBytes by interfaceId | sort TotalBytes DESC | limit 10
  7. メトリクスフィルター → EC2を例に → CloudWatch Agentを設定する。 /var/log/messages 2024-07-09T07:56:28.713+09:00 Jul 8

    22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx systemd: XXXXXXXXXXXXXXXXXXX 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx systemd: XXXXXXXXXXXXXXXXXXX 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: XXXXXXXXXXXXXXXXXXX 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: XXXXXXXXXXXXXXXXXXX 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: XXXXXXXXXXXXXXXXXXX 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx systemd: XXXXXXXXXXXXXXXXXXX 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx systemd: XXXXXXXXXXXXXXXXXXX Amazon EC2
  8. メトリクスフィルター → EC2を例に Logs Metrics Alarm /var/log/messages 2024-07-09T07:56:28.713+09:00 Jul 8

    22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR キーワードの出力回数をカウント するメトリクス作成 出力回数のしきい値を設定 Amazon EC2 ERRORが何回出たかカウント
  9. サブスクリプションフィルター → EC2を例に Logs 特定のキーワードを検知して 次の処理に送る 例)Lambda AWS Lambda ・

    ログ本文を次の処理に渡せる ・ SNSにそのまま渡すことが出来ない ・ アカウントレベルを最大1つ、1つのロググループに最大2つまで Amazon EC2 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR 2024-07-09T07:56:28.713+09:00 Jul 8 22:56:27 ip-xxx-xxx-xxx-xxx-xxx amazon-ssm-agent: ERROR
  10. Amazon EC2 AWS Transit Gateway Amazon VPC Logs Metrics Alarm

    Metrics AWS Lambda CloudWatch Logs まとめ メトリクスフィルター サブスクリプションフィルター CloudWatch Metrics CloudWatch Logs Insights Alarm Amazon EventBridge CloudWatch Alarm