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

Health endpoint pattern as application monitoring #mackerelio

Health endpoint pattern as application monitoring #mackerelio

Health endpoint pattern as application monitoring #mackerelio

original: https://docs.google.com/presentation/d/1ihsnXBN4ELwL5kuKUICgM3EmZ4zWjUYPtGo3DJxYTGE/edit?usp=sharing

Kazuki Higashiguchi
PRO

March 01, 2019
Tweet

More Decks by Kazuki Higashiguchi

Other Decks in Technology

Transcript

  1. Health endpoint pattern
    as
    application monitoring
    #mackerelio Mackerel Meetup #13
    Kazuki Higashiguchi (@hgsgtk)
    1

    View Slide

  2. Health endpoint pattern
    = 外形監視
    2

    View Slide

  3. @hgsgtk
    Kazuki Higashiguchi
    job is … Software Engineer
    lang is ... PHP, Go ...etc
    belongs to ... BASE BANK株式会社
    (BASE株式会社の100%子会社)
    worked with …
    Mackerel, Docker,
    AWS(ECS/Fargate)
    3

    View Slide

  4. =
    4
    BASE BANK
    Mission
    「銀行をかんたんにし、全ての人が挑戦できる世の中に」
    即座に資金調達ができる金融サービス「YELL BANK(エールバンク)」
    https://thebase.in/yellbank

    View Slide

  5. Reference
    入門 監視
    ――モダンなモニタリングのための
    デザインパターン
    Mike Julian 著、松浦 隼人 訳
    7.3 Health check endpoint pattern
    5
    https://www.oreilly.co.jp/books/9784873118642/

    View Slide

  6. =
    ● like “canary endpoint”, “status endpoint”
    ● アプリケーション内のHTTPエンドポイント
    ● アプリケーションの健全性を伝える(外形監視)
    ● デプロイバージョン・依存性のステータスなど基本情報を含む場合もある
    6
    Health endpoint pattern

    View Slide

  7. =
    Status Code
    ● ヘルスチェック成功時は、200 (OK)
    ● ヘルスチェック失敗時は、503 (Service Unavaialbe)
    HTTP Response
    ● ステータス・依存している連携サービスの状態などの状態情報
    ● JSON形式など構造化したデータ形式で返却
    7
    Health endpoint pattern Implementation

    View Slide

  8. =
    8
    Go言語での実装例
    https://github.com/hgsgtk/health-endpoint

    View Slide

  9. Simple pattern
    Statusのみを返却する
    9
    ステータスコード: 200を返すだけのエンドポイント

    View Slide

  10. Simple pattern
    Statusのみを返却する
    10
    依存しているMySQLサーバへのコネクションも確認する

    View Slide

  11. Simple pattern
    Statusのみを返却する
    11
    ヘルスチェック失敗の場合は、503 (Service Unavailable)

    View Slide

  12. Usage
    エンドポイントの使い方
    12
    ● Mackerelなど監視SaaSからの外形監視
    ● ALBなどロードバランサのヘルスチェック
    ● アプリケーション起動確認のデバッグ
    ○ 「health endpointは200を返してる?」

    View Slide

  13. =
    ● コンテナベースアプリケーションにおける、Health endpoint pattern
    ● Principles of container-based application design(Redhat)
    ○ https://www.redhat.com/en/resources/cloud-native-container-design-whitepaper
    ● HIGH OBSERVABILITY PRINCIPLE (HOP) 高観測可能性の原則
    ○ 活動状況や準備状況など、様々な状態チェックに対して APIを提供する
    ● HOP観点でも、HTTPエンドポイントを用意するこのパターンは有益
    13
    閑話休題:コンテナベースアプリケーションとの親和性

    View Slide

  14. =
    14
    See also...
    https://speakerdeck.com/hgsgtk/container-based-application-design-reference-and-practice-number-do
    ckertokyo

    View Slide

  15. =
    ● Health Check Response Format for HTTP APIs (IETF)
    ○ https://tools.ietf.org/id/draft-inadarei-api-health-check-02.html
    ● ヘルスチェックのためのJSONレスポンスの共通フォーマットの議論
    ○ “This document proposes a service health check response format for HTTP APIs.”
    ● 進行中のIssues
    ○ https://github.com/inadarei/rfc-healthcheck/issues
    15
    Health Check Response Format for HTTP APIs

    View Slide

  16. =
    ● API Health Response
    ○ https://tools.ietf.org/id/draft-inadarei-api-health-check-02.html#api-health-response
    ● format
    ○ status
    ○ version (optional)
    ○ releaseId (optional)
    ○ notes (optional)
    ○ output (optional)
    ○ details (optional) - The Details Object
    ○ links (optional)
    ○ serviceId (optional)
    ○ description (optional) - human readable
    16
    API Health Response Format (draft)

    View Slide

  17. formal example
    https://tools.ietf.org/id/draft-inadarei-
    api-health-check-02.html#example-out
    put
    17

    View Slide

  18. =
    次のどれかの値を設定する
    ● “pass”:
    ○ healthy (acceptable aliases: “ok” to support Node’s Terminius and “up” for Java’s
    SpringBoot)
    ● “fail”:
    ○ unhealthy (acceptable aliases: “error” to support Node’s Terminius and “down” for Java’s
    SpringBoot)
    ● “warn”:
    ○ healthy, with some concerns.
    18
    抜粋:Status

    View Slide

  19. =
    ● アプリケーションの状態監視としてのHealth endpoint pattern
    ● 議論が進行中の ”Health Check Response Format for HTTP APIs”
    ● 「こういう情報はどう扱うのがいいんだろう?」という迷いが出たら参考にしてみ
    ると良さそう。
    ● 運用を意識したアプリケーション設計のためにも、監視のパターンは知っておく
    と良い。
    ● 「入門 監視」は最高。
    19
    Summary

    View Slide