• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Consul
  • Install
  • Tutorials
  • Documentation
  • API
  • CLI
  • Try Cloud(opens in new tab)
  • Sign up
Consul Home

API

Skip to main content
  • API
  • API Structure

  • Admin Partitions
  • Catalog
  • Cluster Peering
  • Config
  • Coordinates
  • Discovery Chain
  • Events
  • Health
  • KV Store
  • Namespaces
  • Prepared Queries
  • Sessions
  • Snapshots
  • Status
  • Transactions

  • Libraries & SDKs

  • Resources

  • Tutorial Library
  • Certifications
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Consul
  3. API
  4. Health
  • Consul
  • v1.13.x
  • v1.12.x
  • v1.11.x
  • v1.10.x
  • v1.9.x
  • v1.8.x

ยป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.

To modify health check registration or information, use the /agent/check endpoints.

List Checks for Node

This endpoint returns the checks specific to the node provided on the path.

The HTTP response includes the X-Consul-Results-Filtered-By-ACLs: true header if the response array excludes results due to ACL policy configuration. Refer to the HTTP API documentation for more information.

MethodPathProduces
GET/health/node/:nodeapplication/json

The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.

Blocking QueriesConsistency ModesAgent CachingACL Required
YESallnonenode:read,service:read

Path Parameters

  • node (string: <required>) - Specifies the name or ID of the node to query.

Query Parameters

  • dc (string: "") - Specifies the datacenter to query. This will default to the datacenter of the agent being queried.

  • filter (string: "") - Specifies the expression used to filter the queries results prior to returning the data.

  • ns (string: "")

    Enterprise
    - Specifies the namespace of the checks you lookup. You can also specify the namespace through other methods.

Sample Request

$ curl \
    --header "X-Consul-Namespace: *" \
    http://127.0.0.1:8500/v1/health/node/my-node

Sample Response

[
  {
    "ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
    "Node": "foobar",
    "CheckID": "serfHealth",
    "Name": "Serf Health Status",
    "Status": "passing",
    "Notes": "",
    "Output": "",
    "ServiceID": "",
    "ServiceName": "",
    "ServiceTags": [],
    "Namespace": "default"
  },
  {
    "ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
    "Node": "foobar",
    "CheckID": "service:redis",
    "Name": "Service 'redis' check",
    "Status": "passing",
    "Notes": "",
    "Output": "",
    "ServiceID": "redis",
    "ServiceName": "redis",
    "ServiceTags": ["primary"],
    "Namespace": "foo"
  }
]

Filtering

The filter will be executed against each health check in the results list with the following selectors and filter operations being supported:

SelectorSupported Operations
CheckIDEqual, Not Equal, In, Not In, Matches, Not Matches
NameEqual, Not Equal, In, Not In, Matches, Not Matches
NodeEqual, Not Equal, In, Not In, Matches, Not Matches
NotesEqual, Not Equal, In, Not In, Matches, Not Matches
OutputEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceIDEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceNameEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceTagsIn, Not In, Is Empty, Is Not Empty
StatusEqual, Not Equal, In, Not In, Matches, Not Matches

List Checks for Service

This endpoint returns the checks associated with the service provided on the path.

The HTTP response includes the X-Consul-Results-Filtered-By-ACLs: true header if the response array excludes results due to ACL policy configuration. Refer to the HTTP API documentation for more information.

MethodPathProduces
GET/health/checks/:serviceapplication/json

The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.

Blocking QueriesConsistency ModesAgent CachingACL Required
YESallnonenode:read,service:read

Path Parameters

  • service (string: <required>) - Specifies the service to list checks for.

Query Parameters

  • dc (string: "") - Specifies the datacenter to query. This will default to the datacenter of the agent being queried.

  • 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 ?near=_agent uses the agent's node for the sort. This is specified as part of the URL as a query parameter.

  • node-meta (string: "") - Specifies a desired node metadata key/value pair of the form key:value. This parameter can be specified multiple times, and filters the results to nodes with the specified key/value pairs. This is specified as part of the URL as a query parameter.

  • filter (string: "") - Specifies the expression used to filter the queries results prior to returning the data.

  • ns (string: "")

    Enterprise
    - Specifies the namespace of the service. You can also specify the namespace through other methods.

Sample Request

$ curl \
    http://127.0.0.1:8500/v1/health/checks/my-service?ns=default

Sample Response

[
  {
    "Node": "foobar",
    "CheckID": "service:redis",
    "Name": "Service 'redis' check",
    "Status": "passing",
    "Notes": "",
    "Output": "",
    "ServiceID": "redis",
    "ServiceName": "redis",
    "ServiceTags": ["primary"],
    "Namespace": "default"
  }
]

Filtering

The filter will be executed against each health check in the results list with the following selectors and filter operations being supported:

SelectorSupported Operations
CheckIDEqual, Not Equal, In, Not In, Matches, Not Matches
NameEqual, Not Equal, In, Not In, Matches, Not Matches
NodeEqual, Not Equal, In, Not In, Matches, Not Matches
NotesEqual, Not Equal, In, Not In, Matches, Not Matches
OutputEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceIDEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceNameEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceTagsIn, Not In, Is Empty, Is Not Empty
StatusEqual, Not Equal, In, Not In, Matches, Not Matches

List Service Instances for Service

This endpoint returns the service instances providing the service indicated on the path. Users can also build in support for dynamic load balancing and other features by incorporating the use of health checks.

The HTTP response includes the X-Consul-Results-Filtered-By-ACLs: true header if the response array excludes results due to ACL policy configuration. Refer to the HTTP API documentation for more information.

MethodPathProduces
GET/health/service/:serviceapplication/json

The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.

Blocking QueriesConsistency ModesAgent CachingACL Required
YES 1allbackground refreshnode:read,service:read

1some query parameters will use thestreaming backend

Path Parameters

  • service (string: <required>) - Specifies the service to list services for.

Query Parameters

  • dc (string: "") - Specifies the datacenter to query. This will default to the datacenter of the agent being queried.

  • 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 ?near=_agent uses the agent's node for the sort. ~> Note: Using near will ignore use_streaming_backend and always use blocking queries, because the data required to sort the results is not available to the streaming backend.

  • tag (string: "") Deprecated - Use filter with the Service.Tags selector instead. This parameter will be removed in a future version of Consul. 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.

  • 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 of the form key:value. This parameter can be specified multiple times, and filters the results to nodes with the specified key/value pairs.

  • passing (bool: false) - Specifies that the server should return only nodes with all checks in the passing state. This can be used to avoid additional filtering on the client side.

  • filter (string: "") - Specifies the expression used to filter the queries results prior to returning the data.

  • peer (string: "") - Specifies the imported service's peer. Applies only to imported services.

  • 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 proxy-defaults/global and service-defaults/:service config entries. Returning a fully resolved service definition is useful when a service was registered using the /catalog/register endpoint, which does not automatically merge config entries.

  • ns (string: "")

    Enterprise
    - Specifies the namespace of the service. You can also specify the namespace through other methods.

Sample Request

$ curl \
    http://127.0.0.1:8500/v1/health/service/my-service?ns=default

Sample Response

[
  {
    "Node": {
      "ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
      "Node": "foobar",
      "Address": "10.1.10.12",
      "Datacenter": "dc1",
      "TaggedAddresses": {
        "lan": "10.1.10.12",
        "wan": "10.1.10.12"
      },
      "Meta": {
        "instance_type": "t2.medium"
      }
    },
    "Service": {
      "ID": "redis",
      "Service": "redis",
      "Tags": ["primary"],
      "Address": "10.1.10.12",
      "TaggedAddresses": {
        "lan": {
          "address": "10.1.10.12",
          "port": 8000
        },
        "wan": {
          "address": "198.18.1.2",
          "port": 80
        }
      },
      "Meta": {
        "redis_version": "4.0"
      },
      "Port": 8000,
      "Weights": {
        "Passing": 10,
        "Warning": 1
      },
      "Namespace": "default"
    },
    "Checks": [
      {
        "Node": "foobar",
        "CheckID": "service:redis",
        "Name": "Service 'redis' check",
        "Status": "passing",
        "Notes": "",
        "Output": "",
        "ServiceID": "redis",
        "ServiceName": "redis",
        "ServiceTags": ["primary"],
        "Namespace": "default"
      },
      {
        "Node": "foobar",
        "CheckID": "serfHealth",
        "Name": "Serf Health Status",
        "Status": "passing",
        "Notes": "",
        "Output": "",
        "ServiceID": "",
        "ServiceName": "",
        "ServiceTags": [],
        "Namespace": "default"
      }
    ]
  }
]

Filtering

The filter will be executed against each entry in the top level results list with the following selectors and filter operations being supported:

SelectorSupported Operations
ChecksIs Empty, Is Not Empty
Checks.CheckIDEqual, Not Equal, In, Not In, Matches, Not Matches
Checks.NameEqual, Not Equal, In, Not In, Matches, Not Matches
Checks.NodeEqual, Not Equal, In, Not In, Matches, Not Matches
Checks.NotesEqual, Not Equal, In, Not In, Matches, Not Matches
Checks.OutputEqual, Not Equal, In, Not In, Matches, Not Matches
Checks.ServiceIDEqual, Not Equal, In, Not In, Matches, Not Matches
Checks.ServiceNameEqual, Not Equal, In, Not In, Matches, Not Matches
Checks.ServiceTagsIn, Not In, Is Empty, Is Not Empty
Checks.StatusEqual, Not Equal, In, Not In, Matches, Not Matches
Node.AddressEqual, Not Equal, In, Not In, Matches, Not Matches
Node.DatacenterEqual, Not Equal, In, Not In, Matches, Not Matches
Node.IDEqual, Not Equal, In, Not In, Matches, Not Matches
Node.MetaIs Empty, Is Not Empty, In, Not In
Node.Meta.<any>Equal, Not Equal, In, Not In, Matches, Not Matches
Node.NodeEqual, Not Equal, In, Not In, Matches, Not Matches
Node.TaggedAddressesIs Empty, Is Not Empty, In, Not In
Node.TaggedAddresses.<any>Equal, Not Equal, In, Not In, Matches, Not Matches
Service.AddressEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Connect.NativeEqual, Not Equal
Service.EnableTagOverrideEqual, Not Equal
Service.IDEqual, Not Equal, In, Not In, Matches, Not Matches
Service.KindEqual, Not Equal, In, Not In, Matches, Not Matches
Service.MetaIs Empty, Is Not Empty, In, Not In
Service.Meta.<any>Equal, Not Equal, In, Not In, Matches, Not Matches
Service.PortEqual, Not Equal
Service.Proxy.DestinationServiceIDEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.DestinationServiceNameEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.LocalServiceAddressEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.LocalServicePortEqual, Not Equal
Service.Proxy.ModeEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.TransparentProxy.OutboundListenerPortEqual, Not Equal
Service.Proxy.MeshGateway.ModeEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.UpstreamsIs Empty, Is Not Empty
Service.Proxy.Upstreams.DatacenterEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.Upstreams.DestinationNameEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.Upstreams.DestinationNamespaceEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.Upstreams.DestinationTypeEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.Upstreams.LocalBindAddressEqual, Not Equal, In, Not In, Matches, Not Matches
Service.Proxy.Upstreams.LocalBindPortEqual, Not Equal
Service.Proxy.Upstreams.MeshGateway.ModeEqual, Not Equal, In, Not In, Matches, Not Matches
Service.ServiceEqual, Not Equal, In, Not In, Matches, Not Matches
Service.TaggedAddressesIs Empty, Is Not Empty, In, Not In
Service.TaggedAddresses.<any>.AddressEqual, Not Equal, In, Not In, Matches, Not Matches
Service.TaggedAddresses.<any>.PortEqual, Not Equal
Service.TagsIn, Not In, Is Empty, Is Not Empty
Service.Weights.PassingEqual, Not Equal
Service.Weights.WarningEqual, Not Equal

List Service Instances for Connect-enabled Service

This endpoint returns the service instances providing a Connect-capable service in a given datacenter. This will include both proxies and native integrations. A service may register both Connect-capable and incapable services at the same time, so this endpoint may be used to filter only the Connect-capable endpoints.

The HTTP response includes the X-Consul-Results-Filtered-By-ACLs: true header if the response array excludes results due to ACL policy configuration. Refer to the HTTP API documentation for more information.

MethodPathProduces
GET/health/connect/:serviceapplication/json

Parameters and response format are the same as /health/service/:service.

List Service Instances for Ingress Gateways Associated with a Service

1.8.0+: This API is available in Consul versions 1.8.0 and later.

This endpoint returns the service instances providing an ingress gateway for a service in a given datacenter.

The HTTP response includes the X-Consul-Results-Filtered-By-ACLs: true header if the response array excludes results due to ACL policy configuration. Refer to the HTTP API documentation for more information.

MethodPathProduces
GET/health/ingress/:serviceapplication/json

Parameters and response format are the same as /health/service/:service.

Note: Unlike /health/connect/:service and /health/service/:service this endpoint does not support the peer query parameter and the streaming backend.

List Checks in State

This endpoint returns the checks in the state provided on the path.

The HTTP response includes the X-Consul-Results-Filtered-By-ACLs: true header if the response array excludes results due to ACL policy configuration. Refer to the HTTP API documentation for more information.

MethodPathProduces
GET/health/state/:stateapplication/json

The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.

Blocking QueriesConsistency ModesAgent CachingACL Required
YESallnonenode:read,service:read

Path Parameters

  • state (string: <required>) - Specifies the state to query. Supported states are any, passing, warning, or critical. The any state is a wildcard that can be used to return all checks.

Query Parameters

  • dc (string: "") - Specifies the datacenter to query. This will default to the datacenter of the agent being queried.

  • 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 ?near=_agent uses the agent's node for the sort.

  • node-meta (string: "") - Specifies a desired node metadata key/value pair of the form key:value. This parameter can be specified multiple times, and filters the results to nodes with the specified key/value pairs.

  • filter (string: "") - Specifies the expression used to filter the queries results prior to returning the data.

  • ns (string: "")

    Enterprise
    - Specifies the namespace to query. You can also specify the namespace through other methods.

Sample Request

$ curl \
    http://127.0.0.1:8500/v1/health/state/passing?ns=default

Sample Response

[
  {
    "Node": "foobar",
    "CheckID": "serfHealth",
    "Name": "Serf Health Status",
    "Status": "passing",
    "Notes": "",
    "Output": "",
    "ServiceID": "",
    "ServiceName": "",
    "ServiceTags": [],
    "Namespace": "default"
  },
  {
    "Node": "foobar",
    "CheckID": "service:redis",
    "Name": "Service 'redis' check",
    "Status": "passing",
    "Notes": "",
    "Output": "",
    "ServiceID": "redis",
    "ServiceName": "redis",
    "ServiceTags": ["primary"],
    "Namespace": "default"
  }
]

Filtering

The filter will be executed against each health check in the results list with the following selectors and filter operations being supported:

SelectorSupported Operations
CheckIDEqual, Not Equal, In, Not In, Matches, Not Matches
NameEqual, Not Equal, In, Not In, Matches, Not Matches
NodeEqual, Not Equal, In, Not In, Matches, Not Matches
NotesEqual, Not Equal, In, Not In, Matches, Not Matches
OutputEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceIDEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceNameEqual, Not Equal, In, Not In, Matches, Not Matches
ServiceTagsIn, Not In, Is Empty, Is Not Empty
StatusEqual, Not Equal, In, Not In, Matches, Not Matches

Methods to Specify Namespace
Enterprise

The health endpoints support several methods for specifying the namespace of resources with the following order of precedence:

  1. ns query parameter
  2. X-Consul-Namespace request header
  3. Namespace is inherited from the namespace of the request's ACL token (if any)
  4. The default namespace
Edit this page on GitHub

On this page

  1. Health HTTP Endpoint
  2. List Checks for Node
  3. List Checks for Service
  4. List Service Instances for Service
  5. List Service Instances for Connect-enabled Service
  6. List Service Instances for Ingress Gateways Associated with a Service
  7. List Checks in State
  8. Methods to Specify Namespace
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)