Discovery Chain HTTP Endpoint
1.6.0+: The discovery chain API is available in Consul versions 1.6.0 and newer.
This is a low-level API primarily targeted at developers building external service mesh proxy integrations. Future high-level proxy integration APIs may obviate the need for this API over time.
The /discovery-chain
endpoint returns the compiled discovery
chain for a service.
This will fetch all related configuration entries and render them into a form suitable for use by a service mesh proxy implementation. This is a key component of L7 Traffic Management.
Read Compiled Discovery Chain
If overrides are needed they are passed as the JSON-encoded request body and
the POST
method must be used, otherwise GET
is sufficient.
Method | Path | Produces |
---|---|---|
GET | /discovery-chain/:service_name | application/json |
POST 1 | /discovery-chain/:service_name | application/json |
1 Both GET and POST are for read operations. GET requests do not permit request bodies so a POST is required if override parameters are needed.
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
YES | all | background refresh | service:read |
Path Parameters
service_name
(string: <required>)
- Specifies the service to query when compiling the discovery chain.
Query Parameters
compile-dc
(string: "")
- Specifies the datacenter to use as the basis of compilation. This will default to the datacenter of the agent being queried.This value comes from the
datacenter
parameter in an upstream configuration.ns
(string: "")
Enterprise - Specifies the source namespace you use as the basis of compilation. You can also specify the namespace through other methods.
JSON Request Body Schema
OverrideConnectTimeout
(duration: 0s)
- Overrides the final connect timeout for any service resolved in the compiled chain.This value comes from the
connect_timeout_ms
key in the opaqueconfig
field of the upstream configuration.OverrideProtocol
(string: "")
- Overrides the final protocol used in the compiled discovery chain.If the chain ordinarily would be TCP and an L7 protocol is passed here the chain will still not include Routers or Splitters. If the chain ordinarily would be L7 and TCP is passed here the chain will not include Routers or Splitters.
This value comes from the
protocol
key in an opaqueconfig
field of the upstream configuration.OverrideMeshGateway
(MeshGatewayConfig: <optional>)
- Overrides the final mesh gateway configuration for this any service resolved in the compiled chain.This value comes from the
mesh_gateway
parameter in either the proxy configuration or upstream configuration If both parameters are configured, Consul uses the value defined on the upstream.Mode
(string: "")
- One ofnone
,local
, orremote
.
Sample Compilations
Full documentation for the output fields is found on the discovery chain internals page.
Multi-Datacenter Failover
Config entries defined:
Request:
Response:
Datacenter Redirect with Overrides
Config entries defined:
Request:
Response:
Version Split For Alternate Datacenter
Config entries defined:
Request:
Response:
HTTP Path Routing
Config entries defined:
Request:
Response:
Methods to specify namespace Enterprise
The discovery chain endpoint supports several methods for specifying the namespace to use as the basis of discovery chain compilation with the following order of precedence:
ns
query parameterX-Consul-Namespace
request header- Namespace is inherited from the namespace of the request's ACL token (if any)
- The
default
namespace