From b7ab3af7813654bcc9ed30d581c9401154e4fba3 Mon Sep 17 00:00:00 2001 From: Ashutosh Tripathi <39340292+ashucoder9@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:10:03 +0530 Subject: [PATCH] Update health api Signed-off-by: Ashutosh Tripathi <39340292+ashucoder9@users.noreply.github.com> --- api/health/service.md | 125 +++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 74 deletions(-) diff --git a/api/health/service.md b/api/health/service.md index 7f6a787f44fe..345c906f531d 100644 --- a/api/health/service.md +++ b/api/health/service.md @@ -1,64 +1,47 @@ --- -tags: [AvalancheGo APIs] +title: Health API description: This page is an overview of the Health API associated with AvalancheGo. This API can be used for measuring node health. -sidebar_label: Health API -pagination_label: Health API --- -# Health API +} > +This page was generated by a plugin that directly references this [file](https://github.com/ava-labs/avalanchego/tree/master/api/health/service.md) in the AvalancheGo GitHub repository. + This API can be used for measuring node health. -:::info - -This API set is for a specific node; it is unavailable on the [public server](/tooling/rpc-providers.md). - -::: + +This API set is for a specific node; it is unavailable on the [public server](/tooling/rpc-providers). + ## Health Checks The node periodically runs all health checks, including health checks for each chain. -The frequency at which health checks are run can be specified with the [--health-check-frequency](/nodes/configure/avalanchego-config-flags.md) flag. +The frequency at which health checks are run can be specified with the [\--health-check-frequency](/nodes/configure/configs-flags) flag. ## Filterable Health Checks -The health checks that are run by the node are filterable. You can specify which health checks -you want to see by using `tags` filters. Returned results will only include health checks that -match the specified tags and global health checks like `network`, `database` etc. -When filtered, the returned results will not show the full node health, -but only a subset of filtered health checks. -This means the node can still be unhealthy in unfiltered checks, even if the returned results show that the node is healthy. -AvalancheGo supports using subnetIDs as tags. +The health checks that are run by the node are filterable. You can specify which health checks you want to see by using `tags` filters. Returned results will only include health checks that match the specified tags and global health checks like `network`, `database` etc. When filtered, the returned results will not show the full node health, but only a subset of filtered health checks. This means the node can still be unhealthy in unfiltered checks, even if the returned results show that the node is healthy. AvalancheGo supports using subnetIDs as tags. ## GET Request -To get an HTTP status code response that indicates the node’s health, make a `GET` request. -If the node is healthy, it will return a `200` status code. -If the node is unhealthy, it will return a `503` status code. -In-depth information about the node's health is included in the response body. +To get an HTTP status code response that indicates the node's health, make a `GET` request. If the node is healthy, it will return a `200` status code. If the node is unhealthy, it will return a `503` status code. In-depth information about the node's health is included in the response body. ### Filtering -To filter GET health checks, add a `tag` query parameter to the request. -The `tag` parameter is a string. -For example, to filter health results by subnetID `29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL`, -use the following query: +To filter GET health checks, add a `tag` query parameter to the request. The `tag` parameter is a string. For example, to filter health results by subnetID `29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL`, use the following query: -```sh +``` curl 'http://localhost:9650/ext/health?tag=29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL' ``` -In this example returned results will contain global health checks and health checks that are -related to subnetID `29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL`. +In this example returned results will contain global health checks and health checks that are related to subnetID `29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL`. -**Note:** This filtering can show healthy results even if the node is unhealthy in other Chains/Subnets. +**Note**: This filtering can show healthy results even if the node is unhealthy in other Chains/Avalanche L1s. -In order to filter results by multiple tags, use multiple `tag` query parameters. -For example, to filter health results by subnetID `29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL` and -`28nrH5T2BMvNrWecFcV3mfccjs6axM1TVyqe79MCv2Mhs8kxiY` use the following query: +In order to filter results by multiple tags, use multiple `tag` query parameters. For example, to filter health results by subnetID `29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL` and `28nrH5T2BMvNrWecFcV3mfccjs6axM1TVyqe79MCv2Mhs8kxiY` use the following query: -```sh +``` curl 'http://localhost:9650/ext/health?tag=29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL&tag=28nrH5T2BMvNrWecFcV3mfccjs6axM1TVyqe79MCv2Mhs8kxiY' ``` @@ -68,34 +51,28 @@ The returned results will include health checks for both subnetIDs as well as gl The available endpoints for GET requests are: -- `/ext/health` returns a holistic report of the status of the node. - **Most operators should monitor this status.** +- `/ext/health` returns a holistic report of the status of the node. **Most operators should monitor this status.** - `/ext/health/health` is the same as `/ext/health`. - `/ext/health/readiness` returns healthy once the node has finished initializing. - `/ext/health/liveness` returns healthy once the endpoint is available. ## JSON RPC Request -### Format - -This API uses the `json 2.0` RPC format. For more information on making JSON RPC calls, see -[here](/reference/standards/guides/issuing-api-calls.md). +### Format[​] -### Endpoint +This API uses the `json 2.0` RPC format. For more information on making JSON RPC calls, see [here](/api-reference/standards/guides/issuing-api-calls). -```text -/ext/health -``` +### Endpoint[​] -### Methods +### Methods[​] -#### `health.health` +#### `health.health`[​] This method returns the last set of health check results. -**Example Call:** +**Example Call**: -```sh +``` curl -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "id" :1, @@ -106,9 +83,9 @@ curl -H 'Content-Type: application/json' --data '{ }' 'http://localhost:9650/ext/health' ``` -**Example Response:** +**Example Response**: -```json +``` { "jsonrpc": "2.0", "result": { @@ -210,24 +187,24 @@ curl -H 'Content-Type: application/json' --data '{ In this example response, every check has passed. So, the node is healthy. -**Response Explanation:** +**Response Explanation**: - `checks` is a list of health check responses. - - A check response may include a `message` with additional context. - - A check response may include an `error` describing why the check failed. - - `timestamp` is the timestamp of the last health check. - - `duration` is the execution duration of the last health check, in nanoseconds. - - `contiguousFailures` is the number of times in a row this check failed. - - `timeOfFirstFailure` is the time this check first failed. + - A check response may include a `message` with additional context. + - A check response may include an `error` describing why the check failed. + - `timestamp` is the timestamp of the last health check. + - `duration` is the execution duration of the last health check, in nanoseconds. + - `contiguousFailures` is the number of times in a row this check failed. + - `timeOfFirstFailure` is the time this check first failed. - `healthy` is true all the health checks are passing. -#### `health.readiness` +#### `health.readiness`[​] This method returns the last evaluation of the startup health check results. -**Example Call:** +**Example Call**: -```sh +``` curl -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "id" :1, @@ -238,9 +215,9 @@ curl -H 'Content-Type: application/json' --data '{ }' 'http://localhost:9650/ext/health' ``` -**Example Response:** +**Example Response**: -```json +``` { "jsonrpc": "2.0", "result": { @@ -259,24 +236,24 @@ curl -H 'Content-Type: application/json' --data '{ In this example response, every check has passed. So, the node has finished the startup process. -**Response Explanation:** +**Response Explanation**: - `checks` is a list of health check responses. - - A check response may include a `message` with additional context. - - A check response may include an `error` describing why the check failed. - - `timestamp` is the timestamp of the last health check. - - `duration` is the execution duration of the last health check, in nanoseconds. - - `contiguousFailures` is the number of times in a row this check failed. - - `timeOfFirstFailure` is the time this check first failed. + - A check response may include a `message` with additional context. + - A check response may include an `error` describing why the check failed. + - `timestamp` is the timestamp of the last health check. + - `duration` is the execution duration of the last health check, in nanoseconds. + - `contiguousFailures` is the number of times in a row this check failed. + - `timeOfFirstFailure` is the time this check first failed. - `healthy` is true all the health checks are passing. -#### `health.liveness` +#### `health.liveness`[​] This method returns healthy. -**Example Call:** +**Example Call**: -```sh +``` curl -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "id" :1, @@ -284,9 +261,9 @@ curl -H 'Content-Type: application/json' --data '{ }' 'http://localhost:9650/ext/health' ``` -**Example Response:** +**Example Response**: -```json +``` { "jsonrpc": "2.0", "result": { @@ -299,7 +276,7 @@ curl -H 'Content-Type: application/json' --data '{ In this example response, the node was able to handle the request and mark the service as healthy. -**Response Explanation:** +**Response Explanation**: - `checks` is an empty list. - `healthy` is true.