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

CloudWatchの地味だけど強力な機能紹介!

 CloudWatchの地味だけど強力な機能紹介!

2025/4/16に開催されたAWS 春の Observability 祭り登壇資料
Amazon CloudWatchのニッチな機能と特徴について説明しています。

Tsuyoshi Ito

April 16, 2025
Tweet

More Decks by Tsuyoshi Ito

Other Decks in Programming

Transcript

  1. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 1 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. CloudWatchの地味だけど強力な機能紹介! 2025/04/16 伊藤 威(Tsuyoshi Ito) 春 の O b s e r v a b i l i t y 祭 り 2 0 2 5 アマゾンウェブサービスジャパン合同会社
  2. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 2 自己紹介 • 名前 Ø 伊藤 威 (Tsuyoshi Ito) • 所属 Ø 主に通信業界のお客様をご支援 Ø ソリューションアーキテクト • 好きなサービス Ø Amazon CloudWatch
  3. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 3 アジェンダ • CloudWatch logs insightsのフィールドインデックス機能 • クロスアカウントオブザーバビリティ× Live Tail • Explore Related
  4. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 4 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. CloudWatch logs insightsの フィールドインデックス機能
  5. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 5 CloudWatch logs insights • AWSが提供するログデータの分析サービス • 専用クエリ言語(*)でCloudWatch Logsから 必要な情報を抽出可能 • 料金体系はスキャンされたログ量 Ø USD 0.0076/スキャンされたデータの GB (東京 リージョン) • ユースケース Ø アプリケーションエラーの特定 Ø パフォーマンス分析 (*)直近の アップデートで OpenSearch PPL, SQLでのクエリも可能になりました
  6. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 6 CloudWatch Logs フィールドインデックス機能 • 課題 Ø スキャン量による課金であるためログの規模が増えるとともに、クエリ時間コストも増加 • 実現できること Ø 重要なログ属性にインデックスを作成し、クエリパフォーマンスを向上 Ø すべてのリージョンで利用可能 Ø 追加料金の発生はしない
  7. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 7 そもそもフィールドとは? • ログデータ内部で個別の情報要素を識別するための名前付き属性 Ø システムフィールドはすべてのログに付与 Lambda のログ フィールド名 説明 @message 解析されていない生のログイベント @timestamp ログイベントが発生した時刻 @ingestionTime ログイベントを受信した時刻 @logStream ログイベントが記録されるログストリーム @log account-id:log-group-name で表記 される。ロググループ識別子 @entity (option) Explore Related で使用する エンティティ情報 自動生成されたフィールドには 先頭に @ がつく
  8. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 8 フィールドインデックスを付与できるシステムフィールド フィールド名 説明 補⾜ @ingestionTime ログイベントを受信した時刻 システム @logStream ログイベントが記録されるログストリーム システム @requestId Lambda などでリクエストごとに生成される一意の ID Lambda 関連 @type Lambda のログエントリタイプ(START, END, REPORT) Lambda 関連 @initDuration Lambda関数のINITセクション(メインハンドラーの外側のコード)の実行にかかった時間 Lambda 関連 @duration クションLambda関数ハンドラーの合計呼び出し時間 Lambda 関連 @billedDuration 請求目的で丸められた時間 Lambda 関連 @memorySize Lambda 関数に割り当てられたメモリ Lambda 関連 @maxMemoryUsed Lambda 呼び出し中に使用された最大メモリ量 Lambda 関連 @xrayTraceId X-ray のトレース ID X-ray 関連 @xraySegmentId 時刻X-ray セグメントID X-ray 関連 @message などの多くの情報を含むフィールドは指定できない点には注意 この表以外のカスタムフィールドも指定可能
  9. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 9 インデックスポリシー • フィールドインデックスを適用するためのポリシー Ø アカウントレベル : アカウントに含まれるロググループ全体 Ø ロググループレベル : 指定した特定のロググループのみ • インデックスポリシーの制限 Ø 1つのポリシーにつき20フィールド Ø ロググループレベルが優先 AWS Cloud Logs Logs アカウントレベル アカウントレベル ロググループレベル ロググループレベル
  10. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 10 デモを通じてフィールドインデックスを学ぶ • Lambda のログをクエリを通して効果を体験 • 設定 Ø 10個の Lambda 関数 Ø 事前に1,000,000 回以上呼び出し Ø アカウントレベルで下記のフィールドにインデックスを作成 ü @type ü @requestId ロググループ ロググループ ロググループ ロググループ ロググループ ロググループ ロググループ ロググループ Lambda 関数とロググループの関係
  11. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 11 フィールドインデックスを設定 アカウントレベルのポリシーがロ ググループに適用されている プレフィックスを絞って インデックスを適用 @type と @requestId を指定
  12. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 12 特定の ID を抽出してみる 全ログ 約 600 MB から 180 MB をスキップ
  13. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 13 フィールドインデックスが無効な場合 = 演算子を使用 like 演算子を使用
  14. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 14 注意事項 • インデックスが適用される演算子は = と IN のみ Ø 正規表現を使用可能な like 演算子、不等号 <, > には適用されない • ポリシー作成前のログにインデックスは付与できない Ø 事前にクエリするフィールドをインデックス化する必要がある
  15. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 15 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. クロスアカウントオブザーバビリティ× Live Tail
  16. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 16 CloudWatch のクロスアカウントオブザーバビリティとは • 課題 Ø マルチアカウント管理をする場合、横断的に分析するのが困難 • 実現すること Ø 「メトリクス」「ログ」「トレース」 などを一つのアカウントへ共有 Ø モニタリングアカウントで、ソースアカウントのテレメトリに対して分析が可能 *ソースアカウントとモニタリングアカウントは同⼀リージョン CloudWatch のクロスアカウントオブザーバビリティ https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html ソースアカウント A ソースアカウント B Amazon CloudWatch モニタリングアカウント Amazon CloudWatch Alarm Logs Insight
  17. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 17 クロスアカウントオブザーバビリティで共有できるテレメトリ • テレメトリ Ø ログ Ø メトリクス Ø トレース Ø Application Insights – Applications Ø Internet Monitor – モニター Ø Application Signals – サービス、サービスレベル目標(SLO) • ログとメトリクス、Application Signals の追加コストは発生せず、最初のト レースコピーも無料(複数のモニタリングアカウントに接続すると料金発生)
  18. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 18 共有方法 AWS Organizations に属しているアカウント(推奨) or 個別のアカウント • モニタリングアカウント側 Ø ソースアカウントの org-id か、個別の AWS アカウント ID を指定 Ø 共有受け入れるテレメトリを指定 • ソースアカウント側 Ø モニタリングアカウントのシンク ARN を入手 Ø 共有を許可するテレメトリを指定 意図しないアカウントからの意図しないテレメトリの共有を防ぐ https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html
  19. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 19 共有されたテレメトリはシームレスに分析可能 Live Tail 機能で試してみる • Live Tail とは? Ø CloudWatch Log ロググループに配信 されるログをリアルタイムで可視化 Ø 料金 ü 一ヶ月あたり 1,800 分までは無料 ü 0.01 USD/分
  20. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 20 クロスアカウントオブザーバビリティ × Live Tail 異なる環境で動いてる同一の処理のエラーのばらつき具合を確認 hoge001 : 環境 1 hoge002 : 環境 2 モニタリングアカウント : 環境 3 Amazon CloudWatch AWS Lambda AWS Lambda AWS Lambda
  21. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 21 Live Tail で可視化 ロググループの先頭にアカウントID エラー箇所を描画 モニタリングアカウントとして分析
  22. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 22 Logs intighs で集計 @log でグループ化
  23. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 23 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Explore Related
  24. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 24 Explore related で関連するテレメトリを可視化 リソース間の関連とテレメトリをトポロジーマップで一元的に表現することで問題特定を迅速に スパン • 課題 Ø 複数のテレメトリを調査するには多数のサービスページ の遷移が必要だった • 実現できること Ø Explore Related では ALB と EC2 など関連があるサービ スを自動判定し、トポロジーマップとして可視化 Ø 「メトリクスナビゲーション」「マネジメントコンソー ルのツールバー」など、様々な場所からアクセス可能
  25. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 25 トポロジーマップの使い所 • トレースマップがなくてもトポロジーマップでシステムのつながりを把握可 能 Ø 担当者のいないシステムの連携を探る場合 Ø サービスの前後のつながりと流量を把握可能
  26. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 26 Explore Related にアクセス 始点となるサービスに狙いを定める(今回はELB) CloudWatch 以外のサービス からでもアクセス可能
  27. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 27 リソースの選択 ARN を頼りに始点となるリソースを指定する
  28. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 28 トレースマップでリソースのつながりを探索 「リソースの前後のつながり」「それらに紐づくテレメトリ」を確認できる
  29. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 29 Explore related が自動でトポロジーを作る仕組み AWS リソースが発生させるメトリクスとログ には、エンティティ情報が付与 https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/services-with-related-telemetry.html Auto Scaling Group と関連付けられた EC2 インスタンスは トポロジーマップの表示可能 エンティティ対応しているリソース
  30. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 30 注意点 • すべてのサービスをEnd to End で見れるわけではない Ø 設定値に基づいて自動でトポロジーを作成しているため、前後関係しか見えない
  31. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 31 まとめ • CloudWatch logs の フィールドインデックス機能 Ø logs insights クエリのコストとパフォーマンス効率化 • クロスアカウントオブザーバービリティ × Live Tail Ø 一つのアカウントでテレメトリのシームレスな分析が可能 • Explore Related Ø サービスページを移動しなくてもテレメトリの探索が可能
  32. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon Confidential and Trademark. 32 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Thank you