# ヘルスとcommitmentの遅れを見張る

> Participant NodeのヘルスをgRPCとHTTPとCanton Consoleで確かめ、遅いタスクを見つける設定と、自分と相手のcommitmentの遅れを見張るメトリクスを追います。

- URL: https://cardene.dev/diagrams/canton-node-health
- 公開日: 2026-11-24
- 更新日: 2026-11-24
- トピック: Blockchain
- タグ: Canton
- 親の図解: [ノードの観測](https://cardene.dev/diagrams/canton-ops-observability.md): ノードの健全さの確かめ方から、メトリクスとログとトレースの集め方、鍵の使用とcommitmentとSynchronizerの見張り方までを、章の中の図解で追います。

Participant Nodeは、ヘルスの状態を複数の形で出します。
障害を調べる時に手で確かめることも、大きな監視とオーケストレーションのシステムに組み込むこともできます。
この頁は、その形を追い、遅いタスクと止まったタスクを見つける設定を見ます。
そのあとで、自分と相手のACS commitmentの遅れを見張るメトリクスを見ます。

ACS commitmentの交わし方は、別の頁で見ました。

https://cardene.dev/diagrams/canton-acs-commitment-proof

ACS commitmentは、ある時点のある相手とのactiveなコントラクトの暗号のまとめです。
Cantonのメトリクスの全体は、前の頁までで見ました。
この頁は、Canton側の監視を扱い、Spliceのメトリクスは別の頁が追います。

https://cardene.dev/diagrams/canton-node-monitoring

## gRPCのヘルスサービスで確かめる

Participant Nodeは、gRPCのヘルスチェックの決まりを実装した、`grpc.health.v1.Health`のサービスを出します。
Kubernetesのコンテナのreadinessとlivenessのプローブに使えます。
既定のポートは、Ledger APIのポートです。

:::details gRPC
gRPCは、Googleが開発した、ネットワーク越しに別のプログラムの処理を呼び出すための通信の仕組みです。
:::

Kubernetesは、コンテナを複数のマシンで動かして管理する仕組みです。
資料のプローブの例は、次のとおりです。

```none
readinessProbe:
  grpc:
    port: <port>
```

gRPCのクライアントとNginxも、ヘルスサービスを見て、通信の管理と負荷の分散に使えます。
Nginxは、Webのサーバーのソフトウェアです。
手で確かめるには、`grpcurl -plaintext <host>:<port> grpc.health.v1.Health/Check`を打ちます。
grpcurlは、gRPCのサーバーのRPCを、JSONで呼び出すための道具です。

:::details JSON
JSONは、データを文字で表すための形式で、Webのプログラムどうしのデータのやり取りに広く使われています。
:::

次の表は、ヘルスサービスの2つの呼び出しです。

| 呼び出し | 返す物 |
|---|---|
| `Check` | 要求を受けられる状態なら`SERVING` |
| `Watch` | ストリーミングのヘルスチェック。今のヘルスをすぐ送り、ヘルスが変わるたびに新しいメッセージを送る |

Participant Nodeのレプリカを複数設定した時は、passiveなノードが`NOT_SERVING`を返します。
Participant Nodeのヘルスは、依存する部品のヘルスからなります。
`service`の欄に部品の名前を入れると、部品を個々に問い合わせられます。
`service`の欄が空か未設定なら、全ての部品をまとめたヘルスを返し、知らない名前はgRPCの`NOT_FOUND`のエラーになります。

この名前なしのまとめたヘルスへの問い合わせと、章の1頁目で見た`liveness`という名前のサービスは、別です。
`liveness`という名前のサービスは、常に`SERVING`を返します。

図は、Kubernetesがreadinessのプローブで、2つのレプリカのヘルスを確かめる流れを追います。
この図では、activeとpassiveの2つのレプリカに、それぞれCheckを送る形で描きます。
activeなレプリカは、依存する部品も含めて要求を受けられる例として描きます。
Participant Nodeのヘルスは、依存する部品のヘルスからなるので、activeなだけで提供中と返すとは限りません。

```dragon
sequence レプリカごとのヘルスチェック

box A as activeなParticipant Node [note: 要求を受けられる例, color: slate, icon: server]
box K as Kubernetes [note: readinessのプローブを打つ, color: blue, icon: app]
box P as passiveなParticipant Node [note: activeでないレプリカ, color: rose, icon: server]

step activeに確かめる
  say Kubernetesは、readinessのプローブで、activeなParticipant Nodeのヘルスサービスに、Checkを送ります。
  K -> A: ヘルスチェック
  source CantonのMonitoring Setup [url: https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup]

step activeは提供中と返す
  say この図の例では、activeなParticipant Nodeは、依存する部品も含めて要求を受けられる状態なので、提供中と返します。
  A -> K: 提供中
  source CantonのMonitoring Setup [url: https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup]

step passiveに確かめる
  say Kubernetesは、passiveなParticipant Nodeにも、同じCheckを送ります。
  K -> P: ヘルスチェック
  source CantonのMonitoring Setup [url: https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup]

step passiveは提供中でないと返す
  say レプリカを複数設定した時、passiveなノードは、提供中でないと返します。
  P -> K: 提供中でない
  source CantonのMonitoring Setup [url: https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup]
```

## HTTPで確かめる

HTTPでも、ヘルスを確かめられます。
gRPCのヘルスチェックの決まりを支えないフレームワークに向いています。
ノードの設定の`monitoring.http-health-server.port`を設定すると、`/health`のパスで、ヘルスを出します。

重要な情報は、HTTPの応答のステータスコードで報告されます。
次の表は、ステータスコードと意味です。

| ステータスコード | 意味 |
|---|---|
| `200` | gRPCのヘルスサービスの`SERVING`と同じ |
| `503` | `NOT_SERVING`と同じ |
| `500` | 他の理由で確認が失敗した |

章の1頁目で見た、健全でなければ500を返すという書き方は、この表の503を分けていません。
Participant Nodeについては、この表の503と500を使い分けます。

Kubernetesのreadinessのプローブにも、使えます。
資料のプローブの例は、次のとおりです。

```none
readinessProbe:
  httpGet:
    port: <port>
    path: /health
```

## Canton Consoleでヘルスの状態を見る

Canton Consoleでノードに`health.status`を呼ぶと、ノードの一般的な状態を表示します。
健全でないSynchronizerと依存と、ノードがactiveかと、ポートと、部品の状態と、版と、支えるプロトコルの版が出ます。
資料の例は、ポートがledgerの30145、adminの30146、jsonの30147です。

Participant NodeのAdmin APIは、同じデータを、構造化した形で出します。
`ParticipantStatusService`の`ParticipantStatus`の呼び出しです。

Canton Consoleの最上位で`health.status`を呼ぶと、リモートでつないだ物を含む、全てのノードの状態を出します。
SequencerとMediatorとParticipant Nodeが並びます。
Sequencerは、つないだParticipant Nodeと、Mediatorと、`Accepts admin changes`を示します。
Mediatorは、Sequencerの接続のpoolなどの部品を示します。

health dumpの取り方と渡し方は、この章の1頁目「ノードの健全さを確かめて報告する」で見ました。

https://cardene.dev/diagrams/canton-obs-health

## 遅いタスクと止まったタスクを見つける

一部の操作は、遅い時に、遅いことを報告できます。
`canton.monitoring.logging.log-slow-futures = yes`で有効にします。
予定より長くかかるタスクについて、完了まで`<task name> has not completed after <duration>`のログを定期に出します。
オーバーヘッドを減らすため、既定で無効です。

Cantonは、新しいタスクを時間内に実行予定に入れられるかを定期に試す仕組みも持ちます。
`canton.monitoring.deadlock-detection.enabled = yes`で有効にします。
問題が見つかると、`Task runner <name> is stuck or overloaded for <duration>`のログを出します。
CPUの過負荷や、小さすぎるExecution Contextや、詰まったタスクの多さを示すことがあります。

問題が自然に解ければ、`Task runner <name> is just overloaded, but operating correctly. Task got executed in the meantime`を出します。

delay loggingは、ノードがSequencerからのメッセージの処理に遅れると、過負荷を示す警告を出します。
`canton.monitoring.logging.delay-logging-threshold`の既定は20秒で、Cantonがコマンドの処理にかけてよい最大の遅延を設定します。

プロセスは、`systemd`やKubernetesのような、プロセスの監督の下で動かします。
監視と再起動を、監督に任せるためです。
Participant Nodeのプロセスは、既定で、致命的な故障で終了します。
`canton.parameters.exit-on-fatal-failures = no`にすると、致命的な故障の時も、ノードは終了せず、健全でない状態を返します。

## 自分のcommitmentを見張る

commitmentを時間内に送れないParticipant Nodeは、相手のParticipant Nodeにとって問題です。
相手は、状態が同じだという証明を持たないので、自分の状態をpruningできません。
pruningは、保持の幅より古いトランザクションを履歴から消す操作です。

commitmentの監視は、2つの役に立ちます。
1つ目は、commitmentの生成の性能の把握です。
メトリクスが性能の詰まりを示し、運用者はcommitmentの生成の設定の材料にできます。
2つ目は、相手のcommitmentの状態の把握です。

自分のcommitmentの生成のメトリクスは、次の3つです。

| メトリクス | 測る物 |
|---|---|
| `daml.participant.sync.commitments.compute` | 計算にかけた時間 |
| `daml.participant.sync.commitments.sequencing-time` | commitmentの期間の終わりから、Sequencerがcommitmentを見るまでの時間 |
| `daml.participant.sync.commitments.catchup-mode-enabled` | catch-up modeが起きた回数 |

## 相手のcommitmentを見張る

故障や遅いネットワークでcommitmentの生成が遅れた相手は、分岐を調べる必要がありうるので、Participant Nodeのpruningを妨げます。
運用者は、遅延のメトリクスで、遅い相手を見つけて、相手を遅いとみなす閾値を設定できます。

blacklistは、運用者が自分のParticipant Nodeのpruningで、遅い相手のcommitmentを待たない設定を選ぶ扱いです。
待たない設定にした相手は、pruningの時のnon-repudiationの保証から外れます。
どんな時に選ぶかと、保証がどう変わるかは、頁「commitmentの遅れに対処する」で見ました。
遅い相手を見つけても、常にblacklistに入れるとは限りません。

運用者は、相手のcommitmentの遅れを、3つの示し方で見張れます。
Individually monitoredは、相手ごとの遅延を示します。
DefaultとDistinguishedは、それぞれの示し方の中の最大の遅延だけを示します。
どの相手が遅いかは、調べる道具と、直接の監視で見分けます。

Distinguishedの相手とIndividually monitoredの相手は、重なることがあります。
Distinguishedの相手を、Individually monitoredにも追加すると、Distinguishedにも残り、相手ごとの遅延も示されます。

図は、3つの示し方と、それぞれが出すメトリクスを、枝と葉で並べます。

```dragon
mind 相手の遅れの3つの示し方

step 3つの示し方
  say 相手のcommitmentの遅れは、Default、Distinguished、Individually monitoredの3つの示し方で見張ります。Distinguishedの相手とIndividually monitoredの相手は、重なることがあります。
  idea root as "相手のcommitmentの遅れの示し方" [color: slate]
  idea g1 as "Default" of root [color: blue]
  idea g2 as "Distinguished" of root [color: blue]
  idea g3 as "Individually monitored" of root [color: blue]
  source CantonのMonitoring Setup [url: https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup]

step Defaultの示し方
  say Defaultは、Distinguishedにも、Individually monitoredにも入れていない全ての相手の、最大の遅延を1つ示します。最大の遅延は、閾値の数のcommitmentの周期より長く残るcommitmentで、単位はマイクロ秒です。
  idea g1a as "他に入れていない全ての相手" of g1 [color: blue]
  idea g1b as "最大の遅延を1つ示す" of g1 [color: blue]
  source CantonのMonitoring Setup [url: https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup]

step Distinguishedの示し方
  say Distinguishedには、大事な業務の関係を持つ相手などを追加できます。示すのは、追加した相手の最大の遅延で、閾値の数のcommitmentの周期より長く残るcommitmentが対象です。単位はマイクロ秒です。
  idea g2a as "大事な業務の関係を持つ相手" of g2 [color: blue]
  idea g2b as "最大の遅延を1つ示す" of g2 [color: blue]
  source CantonのMonitoring Setup [url: https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup]

step Individually monitoredの示し方
  say Individually monitoredは、相手ごとの遅延を、相手ごとのラベルで常に示します。Distinguishedの相手を追加しても、Distinguishedに残ります。Defaultの相手を追加すると、Defaultから外れます。
  idea g3a as "最近断続的に故障して回復した相手" of g3 [color: blue]
  idea g3b as "他の示し方の遅れの原因を探したい相手" of g3 [color: blue]
  idea g3c as "相手ごとの遅延を示す" of g3 [color: blue]
  idea g3d as "Distinguishedの相手はDistinguishedに残る" of g3 [color: blue]
  source CantonのMonitoring Setup [url: https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup]
```

次の表は、3つの示し方の対象の相手と、出すメトリクスです。

| 示し方 | 対象の相手 | メトリクス |
|---|---|---|
| Default | Distinguishedにも、Individually monitoredにも入れていない全ての相手 | `daml.participant.sync.commitments.largest-counter-participant-latency`。閾値の`thresholdDefault`の数のreconciliation intervalより長く残るcommitmentの最大の遅延で、単位はマイクロ秒 |
| Distinguished | 運用者が追加した相手。例は、大事な業務の関係を持つ相手 | `daml.participant.sync.commitments.largest-distinguished-counter-participant-latency`。`thresholdDistinguished`の数のreconciliation intervalより長く残るcommitmentの最大の遅延で、単位はマイクロ秒 |
| Individually monitored | 運用者が選んだ相手。例は、最近断続的に故障して回復した相手や、他の示し方の遅れの原因を探したい相手 | `daml.participant.sync.commitments.counter-participant-latency`。相手ごとのラベルを持ち、業務の関係に合わせて個別にアラートを設定できる |

reconciliation intervalは、commitmentを計算して交わす周期です。
遅い相手のメトリクスの設定のコマンドは、頁「commitmentの遅れに対処する」で見ました。

https://cardene.dev/diagrams/canton-acs-commitment-delays

## 相手を監視対象に追加して外す

Distinguishedへの追加と除外は、次の2つのコマンドで行います。
例では、`participant1`の運用者が、`synchronizer2Id`で相手の`participant4`を監視対象に追加し、`synchronizer1Id`で相手の`participant2`を外します。

```none
participant1.commitments.add_config_distinguished_slow_counter_participants(
  Seq(participant4Id),
  Seq(synchronizer2Id),
)
participant1.commitments.remove_config_distinguished_slow_counter_participants(
  Seq(participant2.id),
  Seq(synchronizer1Id),
)
```

Individually monitoredへの追加と除外は、`add_participant_to_individual_metrics`と`remove_participant_from_individual_metrics`で行います。
例では、`synchronizerId`で相手の`participant3`を追加し、外します。

```none
participant1.commitments.add_participant_to_individual_metrics(
  Seq(participant3.id),
  Seq(synchronizerId),
)
participant1.commitments.remove_participant_from_individual_metrics(
  Seq(participant3.id),
  Seq(synchronizerId),
)
```

DefaultとDistinguishedのどちらの相手も、Individually monitoredに追加できます。
Distinguishedの相手は、追加してもDistinguishedに残ります。
Defaultの相手は、追加するとDefaultから外れます。

運用者は、監視の設定を、複数のSynchronizerに一度に適用できます。
`SlowCounterParticipantSynchronizerConfig`に、5つの値を入れて、`set_config_for_slow_counter_participants`に渡します。

| 値 | 例 |
|---|---|
| `synchronizerIds` | `synchronizer1Id`と`synchronizer2Id` |
| `distinguishedParticipants` | `participant3.id` |
| `thresholdDistinguished` | 15 |
| `thresholdDefault` | 15 |
| `individuallyMonitored` | 空の列 |

```none
val update1Config = new SlowCounterParticipantSynchronizerConfig(
  synchronizerIds = Seq(synchronizer1Id, synchronizer2Id),
  distinguishedParticipants = Seq(participant3.id),
  thresholdDistinguished = 15,
  thresholdDefault = 15,
  individuallyMonitored = Seq.empty,
)
participant1.commitments.set_config_for_slow_counter_participants(Seq(update1Config))
```

## 次に読む頁

次の頁「Synchronizerの状態を見張る」は、SequencerとMediatorの状態をどう調べ、ヘルスチェックとwatchdogでどう見張り、verdictとtombstoneをどう読むかを追います。

https://cardene.dev/diagrams/canton-sync-monitoring

## 出典

https://docs.canton.network/global-synchronizer/production-operations/monitoring-setup
