Spring Cloud Gateway with Actuator API

Reading Time: 2 minutes


Actuator is a library which is provides many beneficial features and are production-ready to be utilised in our application. The main features of this library include monitoring of the application, collection of metrics, traffic flow or the status of the database.The actuator mainly works in exposing operational information about the running application. It uses HTTP endpoints or JMX beans to enable the interaction.

Actuator API

The /gateway actuator endpoint monitor and interact with a Spring Cloud Gateway application. To be remotely accessible, the endpoint has to be enabled and exposed over HTTP or JMX in the application properties. Below are the configurations to be done over the application.properties file:

management.endpoint.gateway.enabled=true # default value

Verbose Actuator Format

In Spring Cloud Gateway, a new and more verbose format has been added. It provides functionality such as more details to each route and letting us view the predicates and filters associated with each route along with any configuration that is available. Below example demonstrates configuration for /actuator/gateway/routes :

    "predicate": "(Hosts: [**.addrequestheader.org] && Paths: [/headers], match trailing slash: true)",
    "route_id": "add_request_header_test",
    "filters": [
      "[[AddResponseHeader X-Response-Default-Foo = 'Default-Bar'], order = 1]",
      "[[AddRequestHeader X-Request-Foo = 'Bar'], order = 1]",
      "[[PrefixPath prefix = '/httpbin'], order = 2]"
    "uri": "lb://testservice",
    "order": 0

This feature is enabled by default, for disabling it set the following property:


Retrieving Route Filters

There are two ways to retrieve route filters :

  • Global Filters
  • [gateway-route-filters]

Global Filters

To retrieve the global filters applied to all routes, make a GET requestto /actuator/gateway/globalfilters. The results are similar to below:

  "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

The response contains the details of the global filters that are in place. For each global filter, there is a string representation of the filter object (for example, org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5) and the corresponding order in the filter chain.}

Route Filters

To retrieve the GatewayFilter factories applied to routes, make a GET request to /actuator/gateway/routefilters. The results looks similar to below:

  "[AddRequestHeaderGatewayFilterFactory@570ed9c configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
  "[SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]": null,
  "[SaveSessionGatewayFilterFactory@4449b273 configClass = Object]": null

The response contains the details of the GatewayFilter factories applied to any particular route. For each factory there is a string representation of the corresponding object (for example, [SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]).

Note that the null value is due to an incomplete implementation of the endpoint controller, because it tries to set the order of the object in the filter chain, which does not apply to a GatewayFilter factory object.


The integration of Actuator API with Spring Cloud Gateway provides great opportunities to the developers to keep in check of the application with the production ready features. The monitoring of the applications become smooth and developers can also find ways and act beforehand on the application whenever they encounter that the stats of the application are unusual.