2017-04-04 16:33:22 +00:00
---
layout: api
page_title: Health - HTTP API
description: |-
The /health endpoints query health-related information for services and checks
in Consul.
---
# Health HTTP Endpoint
The `/health` endpoints query health-related information. They are provided
separately from the `/catalog` endpoints since users may prefer not to use the
optional health checking mechanisms. Additionally, some of the query results
from the health endpoints are filtered while the catalog endpoints provide the
raw entries.
2022-07-27 21:03:06 +00:00
To modify health check registration or information,
2023-01-25 16:52:43 +00:00
use the [`/agent/check`](/consul/api-docs/agent/check) endpoints.
2022-07-27 21:03:06 +00:00
2017-04-04 16:33:22 +00:00
## List Checks for Node
This endpoint returns the checks specific to the node provided on the path.
2022-03-19 20:32:38 +00:00
@include 'http_api_results_filtered_by_acls.mdx'
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | -------------------- | ------------------ |
| `GET` | `/health/node/:node` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------ |
| `YES` | `all` | `none` | `node:read,service:read` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
2017-04-04 16:33:22 +00:00
- `node` `(string: <required>)` - Specifies the name or ID of the node to query.
2022-05-10 15:51:11 +00:00
### Query Parameters
2017-04-04 16:33:22 +00:00
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
2022-05-10 15:51:11 +00:00
the datacenter of the agent being queried.
2017-04-04 16:33:22 +00:00
2019-04-16 16:00:15 +00:00
- `filter` `(string: "")` - Specifies the expression used to filter the
queries results prior to returning the data.
2020-04-06 20:27:35 +00:00
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the checks you lookup.
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2019-04-16 16:00:15 +00:00
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
2022-01-12 23:05:01 +00:00
--header "X-Consul-Namespace: *" \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/health/node/my-node
2017-04-04 16:33:22 +00:00
```
### Sample Response
```json
[
{
"ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
"Node": "foobar",
"CheckID": "serfHealth",
"Name": "Serf Health Status",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "",
2017-04-27 23:03:05 +00:00
"ServiceName": "",
2019-12-10 02:26:41 +00:00
"ServiceTags": [],
"Namespace": "default"
2017-04-04 16:33:22 +00:00
},
{
"ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
"Node": "foobar",
"CheckID": "service:redis",
"Name": "Service 'redis' check",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "redis",
2017-04-27 23:03:05 +00:00
"ServiceName": "redis",
2019-12-10 02:26:41 +00:00
"ServiceTags": ["primary"],
"Namespace": "foo"
2017-04-04 16:33:22 +00:00
}
]
```
2019-04-16 16:00:15 +00:00
### Filtering
The filter will be executed against each health check in the results list with
the following selectors and filter operations being supported:
2019-07-23 18:45:20 +00:00
| Selector | Supported Operations |
| ------------- | -------------------------------------------------- |
| `CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Name` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Output` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceTags` | In, Not In, Is Empty, Is Not Empty |
| `Status` | Equal, Not Equal, In, Not In, Matches, Not Matches |
2019-04-16 16:00:15 +00:00
2017-04-04 16:33:22 +00:00
## List Checks for Service
This endpoint returns the checks associated with the service provided on the
path.
2022-03-19 20:32:38 +00:00
@include 'http_api_results_filtered_by_acls.mdx'
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | ------------------------- | ------------------ |
| `GET` | `/health/checks/:service` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------ |
| `YES` | `all` | `none` | `node:read,service:read` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
2017-04-04 16:33:22 +00:00
- `service` `(string: <required>)` - Specifies the service to list checks for.
2022-05-10 15:51:11 +00:00
### Query Parameters
2017-04-04 16:33:22 +00:00
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
2022-05-10 15:51:11 +00:00
the datacenter of the agent being queried.
2017-04-04 16:33:22 +00:00
- `near` `(string: "")` - Specifies a node name to sort the node list in
ascending order based on the estimated round trip time from that node. Passing
2022-05-10 15:51:11 +00:00
`?near=_agent` uses the agent's node for the sort. This is specified as
2017-04-04 16:33:22 +00:00
part of the URL as a query parameter.
2021-02-17 18:10:05 +00:00
- `node-meta` `(string: "")` - Specifies a desired node metadata key/value pair
2017-04-04 16:33:22 +00:00
of the form `key:value`. This parameter can be specified multiple times, and
2022-05-10 15:51:11 +00:00
filters the results to nodes with the specified key/value pairs. This is
2017-04-04 16:33:22 +00:00
specified as part of the URL as a query parameter.
2019-04-16 16:00:15 +00:00
- `filter` `(string: "")` - Specifies the expression used to filter the
queries results prior to returning the data.
2020-04-06 20:27:35 +00:00
2020-04-23 22:13:18 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the service.
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2019-04-16 16:00:15 +00:00
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
2019-12-10 02:26:41 +00:00
http://127.0.0.1:8500/v1/health/checks/my-service?ns=default
2017-04-04 16:33:22 +00:00
```
### Sample Response
```json
[
{
"Node": "foobar",
"CheckID": "service:redis",
"Name": "Service 'redis' check",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "redis",
2017-04-27 23:03:05 +00:00
"ServiceName": "redis",
2020-04-06 20:27:35 +00:00
"ServiceTags": ["primary"],
2019-12-10 02:26:41 +00:00
"Namespace": "default"
2017-04-04 16:33:22 +00:00
}
]
```
2019-04-16 16:00:15 +00:00
### Filtering
The filter will be executed against each health check in the results list with
the following selectors and filter operations being supported:
2019-07-23 18:45:20 +00:00
| Selector | Supported Operations |
| ------------- | -------------------------------------------------- |
| `CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Name` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Output` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceTags` | In, Not In, Is Empty, Is Not Empty |
| `Status` | Equal, Not Equal, In, Not In, Matches, Not Matches |
2019-04-16 16:00:15 +00:00
2021-06-08 17:48:56 +00:00
## List Service Instances for Service ((#list-nodes-for-service))
2017-04-04 16:33:22 +00:00
2021-05-03 21:43:26 +00:00
This endpoint returns the service instances providing the service indicated on the path.
2017-04-04 16:33:22 +00:00
Users can also build in support for dynamic load balancing and other features by
incorporating the use of health checks.
2022-03-19 20:32:38 +00:00
@include 'http_api_results_filtered_by_acls.mdx'
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | -------------------------- | ------------------ |
| `GET` | `/health/service/:service` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2021-06-08 17:48:56 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| -------------------- | ----------------- | -------------------- | ------------------------ |
| `YES` <sup>1</sup> | `all` | `background refresh` | `node:read,service:read` |
<p>
2023-06-29 19:19:03 +00:00
<sup>1</sup>some query parameters will use the <a href="/consul/api-docs/features/blocking#streaming-backend">streaming backend</a> for blocking queries.
2021-06-08 17:48:56 +00:00
</p>
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
2017-04-04 16:33:22 +00:00
- `service` `(string: <required>)` - Specifies the service to list services for.
2022-05-10 15:51:11 +00:00
### Query Parameters
2017-04-04 16:33:22 +00:00
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
2022-05-10 15:51:11 +00:00
the datacenter of the agent being queried.
2017-04-04 16:33:22 +00:00
- `near` `(string: "")` - Specifies a node name to sort the node list in
ascending order based on the estimated round trip time from that node. Passing
2022-05-10 15:51:11 +00:00
`?near=_agent` uses the agent's node for the sort.
2022-06-16 20:25:44 +00:00
~> **Note:** Using `near` will ignore
2023-01-25 16:52:43 +00:00
[`use_streaming_backend`](/consul/docs/agent/config/config-files#use_streaming_backend) and always
2021-04-19 18:34:30 +00:00
use blocking queries, because the data required to sort the results is not available
to the streaming backend.
2017-04-04 16:33:22 +00:00
2020-11-23 22:30:30 +00:00
- `tag` `(string: "")` **Deprecated** - Use `filter` with the `Service.Tags` selector instead.
This parameter will be removed in a future version of Consul.
2022-05-10 15:51:11 +00:00
Specifies the tag to filter the list.
You can use this parameter multiple times to
return only the results that include all of the tag values provided.
2017-04-04 16:33:22 +00:00
2020-11-23 22:30:30 +00:00
- `node-meta` `(string: "")` **Deprecated** - Use `filter` with the `Node.Meta` selector instead.
This parameter will be removed in a future version of Consul.
Specifies a desired node metadata key/value pair
2017-04-04 16:33:22 +00:00
of the form `key:value`. This parameter can be specified multiple times, and
2022-05-10 15:51:11 +00:00
filters the results to nodes with the specified key/value pairs.
2017-04-04 16:33:22 +00:00
2021-02-17 18:10:05 +00:00
- `passing` `(bool: false)` - Specifies that the server should return only nodes
2017-04-04 16:33:22 +00:00
with all checks in the `passing` state. This can be used to avoid additional
filtering on the client side.
2019-04-16 16:00:15 +00:00
- `filter` `(string: "")` - Specifies the expression used to filter the
queries results prior to returning the data.
2020-04-06 20:27:35 +00:00
2022-06-16 20:25:44 +00:00
- `peer` `(string: "")` - Specifies the imported service's peer. Applies only to imported services.
2022-09-16 21:48:03 +00:00
- `merge-central-config` - Include this flag in a request for `connect-proxy` kind or `*-gateway` kind
services to return a fully resolved service definition that includes merged values from the
2023-01-25 16:52:43 +00:00
[proxy-defaults/global](/consul/docs/connect/config-entries/proxy-defaults) and
[service-defaults/:service](/consul/docs/connect/config-entries/service-defaults) config entries.
2022-09-16 21:48:03 +00:00
Returning a fully resolved service definition is useful when a service was registered using the
2023-01-25 16:52:43 +00:00
[/catalog/register](/consul/api-docs/catalog#register_entity) endpoint, which does not automatically merge config entries.
2022-09-16 21:48:03 +00:00
2020-04-23 22:13:18 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the service.
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2019-04-16 16:00:15 +00:00
2024-09-18 19:36:27 +00:00
- `sg` `(string: "")` <EnterpriseAlert inline /> - Specifies the sameness group the service is a member of to
facilitate requests to identical services in other peers or partitions.
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
2019-12-10 02:26:41 +00:00
http://127.0.0.1:8500/v1/health/service/my-service?ns=default
2017-04-04 16:33:22 +00:00
```
### Sample Response
```json
[
{
"Node": {
"ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
"Node": "foobar",
"Address": "10.1.10.12",
2017-04-18 12:02:24 +00:00
"Datacenter": "dc1",
2017-04-04 16:33:22 +00:00
"TaggedAddresses": {
"lan": "10.1.10.12",
"wan": "10.1.10.12"
},
"Meta": {
"instance_type": "t2.medium"
}
},
"Service": {
"ID": "redis",
"Service": "redis",
2017-04-27 23:03:05 +00:00
"Tags": ["primary"],
2017-04-04 16:33:22 +00:00
"Address": "10.1.10.12",
2019-06-17 14:51:50 +00:00
"TaggedAddresses": {
"lan": {
"address": "10.1.10.12",
"port": 8000
},
"wan": {
"address": "198.18.1.2",
"port": 80
}
},
2018-03-28 14:04:50 +00:00
"Meta": {
2018-02-11 13:12:41 +00:00
"redis_version": "4.0"
},
2018-10-19 08:49:09 +00:00
"Port": 8000,
"Weights": {
"Passing": 10,
"Warning": 1
2019-12-10 02:26:41 +00:00
},
"Namespace": "default"
2017-04-04 16:33:22 +00:00
},
"Checks": [
{
"Node": "foobar",
"CheckID": "service:redis",
"Name": "Service 'redis' check",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "redis",
2017-04-27 23:03:05 +00:00
"ServiceName": "redis",
2019-12-10 02:26:41 +00:00
"ServiceTags": ["primary"],
"Namespace": "default"
2017-04-04 16:33:22 +00:00
},
{
"Node": "foobar",
"CheckID": "serfHealth",
"Name": "Serf Health Status",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "",
2017-04-27 23:03:05 +00:00
"ServiceName": "",
2019-12-10 02:26:41 +00:00
"ServiceTags": [],
"Namespace": "default"
2017-04-04 16:33:22 +00:00
}
]
}
]
```
2019-04-16 16:00:15 +00:00
### Filtering
The filter will be executed against each entry in the top level results list with the
following selectors and filter operations being supported:
2021-04-16 19:50:02 +00:00
| Selector | Supported Operations |
| ----------------------------------------------------- | -------------------------------------------------- |
| `Checks` | Is Empty, Is Not Empty |
| `Checks.CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Checks.Name` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Checks.Node` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Checks.Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Checks.Output` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Checks.ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Checks.ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Checks.ServiceTags` | In, Not In, Is Empty, Is Not Empty |
| `Checks.Status` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node.Address` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node.Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node.ID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node.Meta` | Is Empty, Is Not Empty, In, Not In |
| `Node.Meta.<any>` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node.Node` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node.TaggedAddresses` | Is Empty, Is Not Empty, In, Not In |
| `Node.TaggedAddresses.<any>` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Address` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Connect.Native` | Equal, Not Equal |
| `Service.EnableTagOverride` | Equal, Not Equal |
| `Service.ID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Kind` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Meta` | Is Empty, Is Not Empty, In, Not In |
| `Service.Meta.<any>` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Port` | Equal, Not Equal |
| `Service.Proxy.DestinationServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.DestinationServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.LocalServiceAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.LocalServicePort` | Equal, Not Equal |
| `Service.Proxy.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.TransparentProxy.OutboundListenerPort` | Equal, Not Equal |
| `Service.Proxy.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.Upstreams` | Is Empty, Is Not Empty |
| `Service.Proxy.Upstreams.Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.Upstreams.DestinationName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.Upstreams.DestinationNamespace` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.Upstreams.DestinationType` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.Upstreams.LocalBindAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Proxy.Upstreams.LocalBindPort` | Equal, Not Equal |
| `Service.Proxy.Upstreams.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.Service` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.TaggedAddresses` | Is Empty, Is Not Empty, In, Not In |
| `Service.TaggedAddresses.<any>.Address` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Service.TaggedAddresses.<any>.Port` | Equal, Not Equal |
| `Service.Tags` | In, Not In, Is Empty, Is Not Empty |
| `Service.Weights.Passing` | Equal, Not Equal |
| `Service.Weights.Warning` | Equal, Not Equal |
2019-04-16 16:00:15 +00:00
2023-05-05 17:41:40 +00:00
## List Service Instances for Mesh-enabled Service
2018-07-20 15:50:28 +00:00
2021-05-03 21:43:26 +00:00
This endpoint returns the service instances providing a
2023-05-05 17:41:40 +00:00
[mesh-capable](/consul/docs/connect) service in a given datacenter.
2018-07-20 15:50:28 +00:00
This will include both proxies and native integrations. A service may
2023-05-05 17:41:40 +00:00
register both mesh-capable and incapable services at the same time,
so this endpoint may be used to filter only the mesh-capable endpoints.
2018-07-20 15:50:28 +00:00
2022-03-19 20:32:38 +00:00
@include 'http_api_results_filtered_by_acls.mdx'
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | -------------------------- | ------------------ |
| `GET` | `/health/connect/:service` | `application/json` |
2018-07-20 15:50:28 +00:00
Parameters and response format are the same as
2023-01-25 16:52:43 +00:00
[`/health/service/:service`](/consul/api-docs/health#list-nodes-for-service).
2018-07-20 15:50:28 +00:00
2021-06-08 17:48:56 +00:00
## List Service Instances for Ingress Gateways Associated with a Service
2020-07-10 17:36:46 +00:00
-> **1.8.0+:** This API is available in Consul versions 1.8.0 and later.
2021-06-08 17:48:56 +00:00
This endpoint returns the service instances providing an [ingress
2023-01-25 16:52:43 +00:00
gateway](/consul/docs/connect/gateways/ingress-gateway) for a service in a given datacenter.
2020-07-10 17:36:46 +00:00
2022-03-19 20:32:38 +00:00
@include 'http_api_results_filtered_by_acls.mdx'
2020-07-10 17:36:46 +00:00
| Method | Path | Produces |
| ------ | -------------------------- | ------------------ |
| `GET` | `/health/ingress/:service` | `application/json` |
Parameters and response format are the same as
2023-01-25 16:52:43 +00:00
[`/health/service/:service`](/consul/api-docs/health#list-nodes-for-service).
2020-07-10 17:36:46 +00:00
2022-06-16 20:25:44 +00:00
~> **Note:** Unlike `/health/connect/:service` and `/health/service/:service` this
2023-01-25 16:52:43 +00:00
endpoint does not support the `peer` query parameter and the [streaming backend](/consul/api-docs/features/blocking#streaming-backend).
2021-05-03 21:40:07 +00:00
2017-04-04 16:33:22 +00:00
## List Checks in State
This endpoint returns the checks in the state provided on the path.
2022-03-19 20:32:38 +00:00
@include 'http_api_results_filtered_by_acls.mdx'
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | ---------------------- | ------------------ |
| `GET` | `/health/state/:state` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------ |
| `YES` | `all` | `none` | `node:read,service:read` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
2017-04-04 16:33:22 +00:00
2018-03-19 16:56:00 +00:00
- `state` `(string: <required>)` - Specifies the state to query. Supported states
2017-04-04 16:33:22 +00:00
are `any`, `passing`, `warning`, or `critical`. The `any` state is a wildcard
that can be used to return all checks.
2022-05-10 15:51:11 +00:00
### Query Parameters
2017-04-04 16:33:22 +00:00
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
2022-05-10 15:51:11 +00:00
the datacenter of the agent being queried.
2017-04-04 16:33:22 +00:00
- `near` `(string: "")` - Specifies a node name to sort the node list in
ascending order based on the estimated round trip time from that node. Passing
2022-05-10 15:51:11 +00:00
`?near=_agent` uses the agent's node for the sort.
2017-04-04 16:33:22 +00:00
- `node-meta` `(string: "")` - Specifies a desired node metadata key/value pair
of the form `key:value`. This parameter can be specified multiple times, and
2022-05-10 15:51:11 +00:00
filters the results to nodes with the specified key/value pairs.
2017-04-04 16:33:22 +00:00
2019-04-16 16:00:15 +00:00
- `filter` `(string: "")` - Specifies the expression used to filter the
queries results prior to returning the data.
2020-04-06 20:27:35 +00:00
2020-04-23 22:13:18 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace to query.
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2019-04-16 16:00:15 +00:00
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
2019-12-10 02:26:41 +00:00
http://127.0.0.1:8500/v1/health/state/passing?ns=default
2017-04-04 16:33:22 +00:00
```
### Sample Response
```json
[
{
"Node": "foobar",
"CheckID": "serfHealth",
"Name": "Serf Health Status",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "",
2017-04-27 23:03:05 +00:00
"ServiceName": "",
2019-12-10 02:26:41 +00:00
"ServiceTags": [],
"Namespace": "default"
2017-04-04 16:33:22 +00:00
},
{
"Node": "foobar",
"CheckID": "service:redis",
"Name": "Service 'redis' check",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "redis",
2017-04-27 23:03:05 +00:00
"ServiceName": "redis",
2020-04-06 20:27:35 +00:00
"ServiceTags": ["primary"],
2019-12-10 02:26:41 +00:00
"Namespace": "default"
2017-04-04 16:33:22 +00:00
}
]
```
2019-04-16 16:00:15 +00:00
### Filtering
The filter will be executed against each health check in the results list with
the following selectors and filter operations being supported:
2019-07-23 18:45:20 +00:00
| Selector | Supported Operations |
| ------------- | -------------------------------------------------- |
| `CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Name` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Output` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceTags` | In, Not In, Is Empty, Is Not Empty |
| `Status` | Equal, Not Equal, In, Not In, Matches, Not Matches |
2022-05-10 15:51:11 +00:00
2023-10-23 11:41:24 +00:00
## Methods to specify namespace <EnterpriseAlert inline />
2022-05-10 15:51:11 +00:00
The health endpoints
support several methods for specifying the namespace of resources
with the following order of precedence:
1. `ns` query parameter
1. `X-Consul-Namespace` request header
1. Namespace is inherited from the namespace of the request's ACL token (if any)
1. The `default` namespace