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

Observability as Code の必要性

Mitsuaki Tsugo
October 06, 2023
280

Observability as Code の必要性

2023/9/22に開催されたAWS 秋の Observability 祭り登壇資料

Mitsuaki Tsugo

October 06, 2023
Tweet

Transcript

  1. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. A W S 秋 の O b s e r v a b i l i t y 祭 り Observability as Code の必要性 Mitsuaki Tsugo Amazon Web Service Japan G.K. Solutions Architect
  2. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 自己紹介 津郷 光明 (Mitsuaki Tsugo) エンタープライズ技術本部 ソリューションアーキテクト 運用&DevOps系サービスの推進 Observability / IaC
  3. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Agenda • Observability の実装における課題 • Observability as Code とは • Observability as Code が与える変化 • Observability as Code の活用例 3
  4. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability の実装における課題 4
  5. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability の獲得に向けた実装の例 5 Agent のインストール パラメータの設定 プロセス・サービスの起動・運用 ダッシュボードの作成 アラームの設定 権限管理 など
  6. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability の獲得に向けた実装における課題の例 6 開発スピード 変化への対応 煩雑な管理・ 設定漏れ
  7. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability の実装における課題の例 7 開発スピード 変化への対応 煩雑な管理 Observability as Code が 解決の1つになるかもしれない
  8. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability as Code とは 8
  9. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability as Code とは ソースコード IaC ツール Observability 関連リソース https://docs.aws.amazon.com/whitepapers/latest/introduction-devops-aws/infrastructure-as-code.html 3rd Party Tools AWS X-Ray AWS Distro for OpenTelemetry Amazon Managed Service for Prometheus Amazon Managed Grafana Amazon CloudWatch Infrastructure as Code (IaC) を Observability に適用 コードによってリソースの管理やプロビジョニングを行う
  10. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. AWSで利用できるInfrastructures as a code 10 AWS CloudFormation AWS Cloud Development Kit (AWS CDK) AWSが提供するIaC Tool • AWSがサポート • マネジメントコンソール、AWS CLI、 AWS CDK Toolkitによる操作 3rd ベンダーサービス • アプライアンスベンダーによる サポート • 製品によって仕様、インター フェースが異なる など
  11. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. AWS Cloud Development Kit (CDK) AWS CDK Meeting developers where they are 使い慣れたプログラミング言語で クラウドリソースを定義できる OSS のフレームワーク アプリ全体をコードで定義 高レベルの抽象化 開発者体験を改善 • アプリと同じ言語で記述でき ドメイン固有言語の習得が不要 • ソフトウェア開発の技法と プラクティス、ツールを活用 • 型付けとバリデーションで 素早くフィードバックを得る • リソースとスタックの依存関係を 自動的に解決 • クラウドリソースだけでなく AWS Lambda 関数のコードや コンテナイメージなど アプリ全体をまとめて管理 • CI/CD パイプラインを自動構築 • 複数の AWS アカウントに またがる環境を管理 • 複雑な設定を抽象化し コード量と学習コストを削減 • いつでも抽象化から抜け出して 個別の設定にアクセス可能 • ベストプラクティスに基づく デフォルト値と設定を提供 • チームの構成パターンや ガードレールを共有・再利用 TypeScript JavaScript Python Java .NET Go https://github.com/aws/aws-cdk 11
  12. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Terraformとは • HashiCorp社が提供するinfrastructure as code (IaC) ツール • HashiCorp Configuration Language (HCL)を利用した宣言型インフラ管理 • Provider/Provisionerを利用して様々な製品、環境をコントロール可能 • AWSのサービスローンチやアップデートにほぼリアルタイムで対応 12
  13. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Terraform採用のメリット 13 Terraformだけで管理できる領域が広い 豊富なProvider・Provisoner 各種クラウド / アプライアンス製品 / ミドルウェア など よく利⽤するAWS以外のリソース NewRelic / Datadog / Kubernetes周り / CDN など すぐに始められる 学習コストが低い 0から作ることはほとんどない Terraform Registry の活⽤ 利⽤者が多いので情報量が多い
  14. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability as Code が与える変化 14
  15. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 環境変更への追従が容易に インフラと Observability を IaC で管理することで リソースの変更に対して追従が可能 Dashboard i-xxxxxxxxxxxxxxxx1 i-xxxxxxxxxxxxxxxxa 作り直し に伴う 論理ID変更
  16. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 設定漏れ・確認漏れのリスク低減 16 設定漏れや設定ミスを環境適用前に防ぐことが可能 Policy as Code による評価も有効な手段 Observability as Code 設計書 Policy as Code 評価 ※ Policy as Code : コードを使ってポリシーを定義、更新、共有、適⽤する。IaCと組み合わせることで 作成するリソースがポリシーに準拠しているかを評価できる。 https://speakerdeck.com/nemops/yahariporisi-dot-dot-dot-porisihaquan-tewojie-jue-suru-dot-dot-dot-opa-deshi-meru-policy-as-code
  17. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. スピードアップ • デプロイ作業時間を削減 • CI/CD 自動テスト、デプロイ リスク低減 • 人的ミスの排除 • バージョン管理による 変更の追跡と承認プロセス • 必要に応じて前のバージョン にロールバック 変更管理の実現 / 再現性の確保 • 同じ構成を何度でもデプロイ 開発効率の向上
  18. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability の実装における課題の例 18 開発スピード 変化への対応 煩雑な管理・ 設定漏れ 再掲
  19. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability の実装における課題の例 19 開発スピード 変化への対応 煩雑な管理 Observability as Code が 解決の1つになるかもしれない 再掲
  20. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability as Code の活用 20
  21. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability Lifecycle 21 インスツルメンテーション・ 収集 可視化 通知 分析 収集・可視化・分析・通知を循環する
  22. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability Lifecycle 22 インスツルメンテーション・ 収集 可視化 通知 分析 Observability as Code は 収集・可視化・通知で有効
  23. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. Observability Lifecycle 23 インスツルメンテーション・ 収集 可視化 通知 分析 AWS で Observability as Code によって 収集で実現する例をご紹介
  24. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 24 Observabilityでよく利用されるテレメトリデータ Observability メトリクス ログ トレース 時間間隔で計測されたデータの数値表現 傾向の把握、予測に役⽴つ タイムスタンプが記録された、時間の 経過とともに起こったイベントの記録 予測不可能な振る舞いの発⾒に役⽴つ エンドツーエンドのリクエストフローの記録 リクエストの流れと構造の両⽅を可視化 することで因果関係の追跡に役⽴つ
  25. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. AWS Observability Overview Observability Collectors and SDKs Container insights Lambda insights Contributor insights Application insights Synthetics Dashboards Alarms RUM AWS X-Ray AWS native services Amazon CloudWatch ServiceLens Open-source managed services Amazon Managed Grafana Do it yourself (DIY) – AWS OSS Solutions Amazon OpenSearch Service Amazon Managed Service for Prometheus Jaeger and Zipkin Tracing Insights & ML Instrumentation Metrics CloudWatch agent AWS X-Ray agent AWS Distro for OpenTelemetry Internet monitor Logs
  26. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. AWS CDK による AWS Lambda のインスツルメンテーション AWS Lambda my_lambda = _lambda.Function(self,'HelloHandler', runtime = _lambda.Runtime.PYTHON_3_8, code = _lambda.Code.from_asset('lambda'), handler = 'hello.handler', environment = { 'AWS_LAMBDA_EXEC_WRAPPER': '/opt/otel-instrument', }, adot_instrumentation=_lambda.AdotInstrumentationConfig( layer_version=AdotLayerVersion.from_python_sdk_layer_version(Adot LambdaLayerPythonSdkVersion.LATEST), exec_wrapper=AdotLambdaExecWrapper.INSTRUMENT_HANDLER ), insights_version=_lambda.LambdaInsightsVersion.VERSION_1_0_98_0, ) Python
  27. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. AWS CDK による AWS Lambda のインスツルメンテーション my_lambda = _lambda.Function(self,'HelloHandler', runtime = _lambda.Runtime.PYTHON_3_8, code = _lambda.Code.from_asset('lambda'), handler = 'hello.handler', environment = { 'AWS_LAMBDA_EXEC_WRAPPER': '/opt/otel-instrument', }, adot_instrumentation=_lambda.AdotInstrumentationConfig( layer_version=AdotLayerVersion.from_python_sdk_layer_version(Adot LambdaLayerPythonSdkVersion.LATEST), exec_wrapper=AdotLambdaExecWrapper.INSTRUMENT_HANDLER ), insights_version=_lambda.LambdaInsightsVersion.VERSION_1_0_98_0, ) Python AWS Lambda • Construct でCloudWatch logsへの出力 が標準で設定 • ログ出力のための権限設定不要 • ログレベルやロググループの設定も可能 ログ
  28. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. AWS CDK による AWS Lambda のインスツルメンテーション my_lambda = _lambda.Function(self,'HelloHandler', runtime = _lambda.Runtime.PYTHON_3_8, code = _lambda.Code.from_asset('lambda'), handler = 'hello.handler', environment = { 'AWS_LAMBDA_EXEC_WRAPPER': '/opt/otel-instrument', }, adot_instrumentation=_lambda.AdotInstrumentationConfig( layer_version=AdotLayerVersion.from_python_sdk_layer_version(Adot LambdaLayerPythonSdkVersion.LATEST), exec_wrapper=AdotLambdaExecWrapper.INSTRUMENT_HANDLER ), insights_version=_lambda.LambdaInsightsVersion.VERSION_1_0_98_0, ) Python AWS Lambda メトリクス • Lambda InsightsがLambda Layer の 追加によって有効化
  29. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. AWS CDK による AWS Lambda のインスツルメンテーション my_lambda = _lambda.Function(self,'HelloHandler', runtime = _lambda.Runtime.PYTHON_3_8, code = _lambda.Code.from_asset('lambda'), handler = 'hello.handler', environment = { 'AWS_LAMBDA_EXEC_WRAPPER': '/opt/otel-instrument', }, adot_instrumentation=_lambda.AdotInstrumentationConfig( layer_version=AdotLayerVersion.from_python_sdk_layer_version(Adot LambdaLayerPythonSdkVersion.LATEST), exec_wrapper=AdotLambdaExecWrapper.INSTRUMENT_HANDLER ), insights_version=_lambda.LambdaInsightsVersion.VERSION_1_0_98_0, ) Python AWS Lambda • Amazon Distro for Open Telemetryの Lambda Layer の追加でトレースの取得が 可能 • ここでは自動インスツルメンテーションを 実現 • このほかにも AWS X-Ray SDKを利用する 方法も トレース https://aws-otel.github.io/
  30. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. まとめ 30
  31. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

    Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. まとめ 31 • Observability as Code は IaC を Observability の領域に適用したもの • Observability as Code で Observability の実装に関する課題を解決 • インスツルメンテーションから実装できる
  32. AWS 秋の Observability 祭り Observability as Code の必要性 © 2023,

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