Files
spring-cloud-static/Greenwich.SR4/multi/multi__actuator_api.html
2019-11-19 16:34:05 +01:00

59 lines
20 KiB
HTML

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>120.&nbsp;Actuator API</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_gateway.html" title="Part&nbsp;XV.&nbsp;Spring Cloud Gateway"><link rel="prev" href="multi__cors_configuration.html" title="119.&nbsp;CORS Configuration"><link rel="next" href="multi_troubleshooting.html" title="121.&nbsp;Troubleshooting"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">120.&nbsp;Actuator API</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__cors_configuration.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XV.&nbsp;Spring Cloud Gateway</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi_troubleshooting.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_actuator_api" href="#_actuator_api"></a>120.&nbsp;Actuator API</h2></div></div></div><p>The <code class="literal">/gateway</code> actuator endpoint allows to monitor and interact with a Spring Cloud Gateway application. To be remotely accessible, the endpoint has to be <a class="link" href="https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-endpoints-enabling-endpoints" target="_top">enabled</a> and <a class="link" href="https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-endpoints-exposing-endpoints" target="_top">exposed via HTTP or JMX</a> in the application properties.</p><p><b>application.properties.&nbsp;</b>
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">management.endpoint.gateway.enabled</span>=true <span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment"># default value</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">management.endpoints.web.exposure.include</span>=gateway</pre><p>
</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_verbose_actuator_format" href="#_verbose_actuator_format"></a>120.1&nbsp;Verbose Actuator Format</h2></div></div></div><p>A new, more verbose format has been added to Gateway. This adds more detail to each route allowing to view the predicates and filters associated to each route along with any configuration that is available.</p><p><code class="literal">/actuator/gateway/routes</code></p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">[</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"predicate"</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"(Hosts: [**.addrequestheader.org] &amp;&amp; Paths: [/headers], match trailing slash: true)"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"route_id"</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"add_request_header_test"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"filters"</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">[</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[[AddResponseHeader X-Response-Default-Foo = 'Default-Bar'], order = 1]"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[[AddRequestHeader X-Request-Foo = 'Bar'], order = 1]"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[[PrefixPath prefix = '/httpbin'], order = 2]"</span>
]<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"uri"</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"lb://testservice"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"order"</span>: <span class="hl-number">0</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">]</span></pre><p>To enable this feature, set the following property:</p><p><b>application.properties.&nbsp;</b>
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">spring.cloud.gateway.actuator.verbose.enabled</span>=true</pre><p>
</p><p>This will default to true in a future release.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_retrieving_route_filters" href="#_retrieving_route_filters"></a>120.2&nbsp;Retrieving route filters</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_global_filters_2" href="#_global_filters_2"></a>120.2.1&nbsp;Global Filters</h3></div></div></div><p>To retrieve the <a class="link" href="">global filters</a> applied to all routes, make a <code class="literal">GET</code> request to <code class="literal">/actuator/gateway/globalfilters</code>. The resulting response is similar to the following:</p><pre class="screen">{
"org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5": 10100,
"org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@4f6fd101": 10000,
"org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@32d22650": -1,
"org.springframework.cloud.gateway.filter.ForwardRoutingFilter@106459d9": 2147483647,
"org.springframework.cloud.gateway.filter.NettyRoutingFilter@1fbd5e0": 2147483647,
"org.springframework.cloud.gateway.filter.ForwardPathFilter@33a71d23": 0,
"org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@135064ea": 2147483637,
"org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@23c05889": 2147483646
}</pre><p>The response contains details of the global filters in place. For each global filter is provided the string representation of the filter object (e.g., <code class="literal">org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5</code>) and the corresponding <a class="link" href="multi__global_filters.html#_combined_global_filter_and_gatewayfilter_ordering" title="115.1&nbsp;Combined Global Filter and GatewayFilter Ordering">order</a> in the filter chain.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_route_filters" href="#_route_filters"></a>120.2.2&nbsp;Route Filters</h3></div></div></div><p>To retrieve the <a class="link" href="">GatewayFilter factories</a> applied to routes, make a <code class="literal">GET</code> request to <code class="literal">/actuator/gateway/routefilters</code>. The resulting response is similar to the following:</p><pre class="screen">{
"[AddRequestHeaderGatewayFilterFactory@570ed9c configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
"[SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]": null,
"[SaveSessionGatewayFilterFactory@4449b273 configClass = Object]": null
}</pre><p>The response contains details of the GatewayFilter factories applied to any particular route. For each factory is provided the string representation of the corresponding object (e.g., <code class="literal">[SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]</code>). Note that the <code class="literal">null</code> value is due to an incomplete implementation of the endpoint controller, for that it tries to set the order of the object in the filter chain, which does not apply to a GatewayFilter factory object.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_refreshing_the_route_cache" href="#_refreshing_the_route_cache"></a>120.3&nbsp;Refreshing the route cache</h2></div></div></div><p>To clear the routes cache, make a <code class="literal">POST</code> request to <code class="literal">/actuator/gateway/refresh</code>. The request returns a 200 without response body.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_retrieving_the_routes_defined_in_the_gateway" href="#_retrieving_the_routes_defined_in_the_gateway"></a>120.4&nbsp;Retrieving the routes defined in the gateway</h2></div></div></div><p>To retrieve the routes defined in the gateway, make a <code class="literal">GET</code> request to <code class="literal">/actuator/gateway/routes</code>. The resulting response is similar to the following:</p><pre class="screen">[{
"route_id": "first_route",
"route_object": {
"predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@1e9d7e7d",
"filters": [
"OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.PreserveHostHeaderGatewayFilterFactory$$Lambda$436/674480275@6631ef72, order=0}"
]
},
"order": 0
},
{
"route_id": "second_route",
"route_object": {
"predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@cd8d298",
"filters": []
},
"order": 0
}]</pre><p>The response contains details of all the routes defined in the gateway. The following table describes the structure of each element (i.e., a route) of the response.</p><div class="informaltable"><table class="informaltable" style="border-collapse: collapse;border-top: 1px solid ; border-bottom: 1px solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"></colgroup><thead><tr><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">Path</th><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">Type</th><th style="border-bottom: 1px solid ; " align="left" valign="top">Description</th></tr></thead><tbody><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">route_id</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>String</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>The route id.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">route_object.predicate</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>Object</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>The route predicate.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">route_object.filters</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>Array</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>The <a class="link" href="">GatewayFilter factories</a> applied to the route.</p></td></tr><tr><td style="border-right: 1px solid ; " align="left" valign="top"><p><code class="literal">order</code></p></td><td style="border-right: 1px solid ; " align="left" valign="top"><p>Number</p></td><td style="" align="left" valign="top"><p>The route order.</p></td></tr></tbody></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_retrieving_information_about_a_particular_route" href="#_retrieving_information_about_a_particular_route"></a>120.5&nbsp;Retrieving information about a particular route</h2></div></div></div><p>To retrieve information about a single route, make a <code class="literal">GET</code> request to <code class="literal">/actuator/gateway/routes/{id}</code> (e.g., <code class="literal">/actuator/gateway/routes/first_route</code>). The resulting response is similar to the following:</p><pre class="screen">{
"id": "first_route",
"predicates": [{
"name": "Path",
"args": {"_genkey_0":"/first"}
}],
"filters": [],
"uri": "https://www.uri-destination.org",
"order": 0
}]</pre><p>The following table describes the structure of the response.</p><div class="informaltable"><table class="informaltable" style="border-collapse: collapse;border-top: 1px solid ; border-bottom: 1px solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"></colgroup><thead><tr><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">Path</th><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">Type</th><th style="border-bottom: 1px solid ; " align="left" valign="top">Description</th></tr></thead><tbody><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">id</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>String</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>The route id.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">predicates</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>Array</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>The collection of route predicates. Each item defines the name and the arguments of a given predicate.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">filters</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>Array</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>The collection of filters applied to the route.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">uri</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>String</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>The destination URI of the route.</p></td></tr><tr><td style="border-right: 1px solid ; " align="left" valign="top"><p><code class="literal">order</code></p></td><td style="border-right: 1px solid ; " align="left" valign="top"><p>Number</p></td><td style="" align="left" valign="top"><p>The route order.</p></td></tr></tbody></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_creating_and_deleting_a_particular_route" href="#_creating_and_deleting_a_particular_route"></a>120.6&nbsp;Creating and deleting a particular route</h2></div></div></div><p>To create a route, make a <code class="literal">POST</code> request to <code class="literal">/gateway/routes/{id_route_to_create}</code> with a JSON body that specifies the fields of the route (see the previous subsection).</p><p>To delete a route, make a <code class="literal">DELETE</code> request to <code class="literal">/gateway/routes/{id_route_to_delete}</code>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_recap_list_of_all_endpoints" href="#_recap_list_of_all_endpoints"></a>120.7&nbsp;Recap: list of all endpoints</h2></div></div></div><p>The table below summarises the Spring Cloud Gateway actuator endpoints. Note that each endpoint has <code class="literal">/actuator/gateway</code> as the base-path.</p><div class="informaltable"><table class="informaltable" style="border-collapse: collapse;border-top: 1px solid ; border-bottom: 1px solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"></colgroup><thead><tr><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">ID</th><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">HTTP Method</th><th style="border-bottom: 1px solid ; " align="left" valign="top">Description</th></tr></thead><tbody><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">globalfilters</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>GET</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>Displays the list of global filters applied to the routes.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">routefilters</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>GET</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>Displays the list of GatewayFilter factories applied to a particular route.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">refresh</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>POST</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>Clears the routes cache.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">routes</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>GET</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>Displays the list of routes defined in the gateway.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">routes/{id}</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>GET</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>Displays information about a particular route.</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p><code class="literal">routes/{id}</code></p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>POST</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>Add a new route to the gateway.</p></td></tr><tr><td style="border-right: 1px solid ; " align="left" valign="top"><p><code class="literal">routes/{id}</code></p></td><td style="border-right: 1px solid ; " align="left" valign="top"><p>DELETE</p></td><td style="" align="left" valign="top"><p>Remove an existing route from the gateway.</p></td></tr></tbody></table></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__cors_configuration.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_gateway.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi_troubleshooting.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">119.&nbsp;CORS Configuration&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;121.&nbsp;Troubleshooting</td></tr></table></div></body></html>