diff --git a/2.1.x/multi/multi__gatewayfilter_factories.html b/2.1.x/multi/multi__gatewayfilter_factories.html index 97b822ba..d91a332a 100644 --- a/2.1.x/multi/multi__gatewayfilter_factories.html +++ b/2.1.x/multi/multi__gatewayfilter_factories.html @@ -354,7 +354,9 @@ using something like - Path=/name/** filters: - StripPrefix=2

-

When a request is made through the gateway to /name/bar/foo the request made to nameservice will look like http://nameservice/foo.

5.25 Retry GatewayFilter Factory

The Retry GatewayFilter Factory takes retries, statuses, methods, and series as parameters.

application.yml.  +

When a request is made through the gateway to /name/bar/foo the request made to nameservice will look like http://nameservice/foo.

5.25 Retry GatewayFilter Factory

The Retry GatewayFilter Factory support following set of parameters:

The following defaults are configured for Retry filter if enabled:

application.yml. 

spring:
   cloud:
     gateway:
@@ -367,7 +369,12 @@ using something like         - name: Retry
           args:
             retries: 3
-            statuses: BAD_GATEWAY

+ statuses: BAD_GATEWAY + backoff: + firstBackoff: 10ms + maxBackoff: 50ms + factor: 2 + basedOnPreviousValue: false

[Note]Note

The retry filter does not currently support retrying with a body (e.g. for POST or PUT requests with a body).

[Note]Note

When using the retry filter with a forward: prefixed URL, the target endpoint should be written carefully so that in case of an error it does not do anything that could result in a response being sent to the client and committed. For example, if the target endpoint is an annotated controller, the target controller method should not return ResponseEntity with an error status code. Instead it should throw an Exception, or signal an error, e.g. via a Mono.error(ex) return value, which the retry filter can be configured to handle by retrying.

5.26 RequestSize GatewayFilter Factory

The RequestSize GatewayFilter Factory can restrict a request from reaching the downstream service , when the request size is greater than the permissible limit. The filter takes RequestSize as parameter which is the permissible size limit of the request defined in bytes.

application.yml. 

spring:
   cloud:
diff --git a/2.1.x/multi/multi__global_filters.html b/2.1.x/multi/multi__global_filters.html
index 50a6764d..c133c39e 100644
--- a/2.1.x/multi/multi__global_filters.html
+++ b/2.1.x/multi/multi__global_filters.html
@@ -63,7 +63,7 @@ route URL will override the ServiceInstance configu
         uri: ws://localhost:3001
         predicates:
         - Path=/websocket/**

-

6.8 Gateway Metrics Filter

To enable Gateway Metrics add spring-boot-starter-actuator as a project dependency. Then, by default, the Gateway Metrics Filter runs as long as the property spring.cloud.gateway.metrics.enabled is not set to false. This filter adds a timer metric named "gateway.requests" with the following tags:

These metrics are then available to be scraped from /actuator/metrics/gateway.requests and can be easily integated with Prometheus to create a Grafana dashboard.

[Note]Note

To enable the pometheus endpoint add micrometer-registry-prometheus as a project dependency.

6.9 Marking An Exchange As Routed

After the Gateway has routed a ServerWebExchange it will mark that exchange as "routed" by adding gatewayAlreadyRouted +

6.8 Gateway Metrics Filter

To enable Gateway Metrics add spring-boot-starter-actuator as a project dependency. Then, by default, the Gateway Metrics Filter runs as long as the property spring.cloud.gateway.metrics.enabled is not set to false. This filter adds a timer metric named "gateway.requests" with the following tags:

These metrics are then available to be scraped from /actuator/metrics/gateway.requests and can be easily integrated with Prometheus to create a Grafana dashboard.

[Note]Note

To enable the prometheus endpoint add micrometer-registry-prometheus as a project dependency.

6.9 Marking An Exchange As Routed

After the Gateway has routed a ServerWebExchange it will mark that exchange as "routed" by adding gatewayAlreadyRouted to the exchange attributes. Once a request has been marked as routed, other routing filters will not route the request again, essentially skipping the filter. There are convenience methods that you can use to mark an exchange as routed or check if an exchange has already been routed.

\ No newline at end of file diff --git a/2.1.x/single/spring-cloud-gateway.html b/2.1.x/single/spring-cloud-gateway.html index 94d95c74..ee0efa76 100644 --- a/2.1.x/single/spring-cloud-gateway.html +++ b/2.1.x/single/spring-cloud-gateway.html @@ -479,7 +479,9 @@ using something like - Path=/name/** filters: - StripPrefix=2

-

When a request is made through the gateway to /name/bar/foo the request made to nameservice will look like http://nameservice/foo.

5.25 Retry GatewayFilter Factory

The Retry GatewayFilter Factory takes retries, statuses, methods, and series as parameters.

application.yml.  +

When a request is made through the gateway to /name/bar/foo the request made to nameservice will look like http://nameservice/foo.

5.25 Retry GatewayFilter Factory

The Retry GatewayFilter Factory support following set of parameters:

The following defaults are configured for Retry filter if enabled:

application.yml. 

spring:
   cloud:
     gateway:
@@ -492,7 +494,12 @@ using something like         - name: Retry
           args:
             retries: 3
-            statuses: BAD_GATEWAY

+ statuses: BAD_GATEWAY + backoff: + firstBackoff: 10ms + maxBackoff: 50ms + factor: 2 + basedOnPreviousValue: false

[Note]Note

The retry filter does not currently support retrying with a body (e.g. for POST or PUT requests with a body).

[Note]Note

When using the retry filter with a forward: prefixed URL, the target endpoint should be written carefully so that in case of an error it does not do anything that could result in a response being sent to the client and committed. For example, if the target endpoint is an annotated controller, the target controller method should not return ResponseEntity with an error status code. Instead it should throw an Exception, or signal an error, e.g. via a Mono.error(ex) return value, which the retry filter can be configured to handle by retrying.

5.26 RequestSize GatewayFilter Factory

The RequestSize GatewayFilter Factory can restrict a request from reaching the downstream service , when the request size is greater than the permissible limit. The filter takes RequestSize as parameter which is the permissible size limit of the request defined in bytes.

application.yml. 

spring:
   cloud:
@@ -611,7 +618,7 @@ route URL will override the ServiceInstance configu
         uri: ws://localhost:3001
         predicates:
         - Path=/websocket/**

-

6.8 Gateway Metrics Filter

To enable Gateway Metrics add spring-boot-starter-actuator as a project dependency. Then, by default, the Gateway Metrics Filter runs as long as the property spring.cloud.gateway.metrics.enabled is not set to false. This filter adds a timer metric named "gateway.requests" with the following tags:

These metrics are then available to be scraped from /actuator/metrics/gateway.requests and can be easily integated with Prometheus to create a Grafana dashboard.

[Note]Note

To enable the pometheus endpoint add micrometer-registry-prometheus as a project dependency.

6.9 Marking An Exchange As Routed

After the Gateway has routed a ServerWebExchange it will mark that exchange as "routed" by adding gatewayAlreadyRouted +

6.8 Gateway Metrics Filter

To enable Gateway Metrics add spring-boot-starter-actuator as a project dependency. Then, by default, the Gateway Metrics Filter runs as long as the property spring.cloud.gateway.metrics.enabled is not set to false. This filter adds a timer metric named "gateway.requests" with the following tags:

These metrics are then available to be scraped from /actuator/metrics/gateway.requests and can be easily integrated with Prometheus to create a Grafana dashboard.

[Note]Note

To enable the prometheus endpoint add micrometer-registry-prometheus as a project dependency.

6.9 Marking An Exchange As Routed

After the Gateway has routed a ServerWebExchange it will mark that exchange as "routed" by adding gatewayAlreadyRouted to the exchange attributes. Once a request has been marked as routed, other routing filters will not route the request again, essentially skipping the filter. There are convenience methods that you can use to mark an exchange as routed or check if an exchange has already been routed.

7. TLS / SSL

The Gateway can listen for requests on https by following the usual Spring server configuration. Example:

application.yml.  diff --git a/2.1.x/spring-cloud-gateway.xml b/2.1.x/spring-cloud-gateway.xml index 027b3d55..f8c0c078 100644 --- a/2.1.x/spring-cloud-gateway.xml +++ b/2.1.x/spring-cloud-gateway.xml @@ -1093,7 +1093,7 @@ using something like

Retry GatewayFilter Factory -The Retry GatewayFilter Factory takes retries, statuses, methods, and series as parameters. +The Retry GatewayFilter Factory support following set of parameters: retries: the number of retries that should be attempted @@ -1107,6 +1107,32 @@ using something like series: the series of status codes to be retried, represented using org.springframework.http.HttpStatus.Series + +exceptions: list of exceptions thrown that should be retried + + +backoff: configured exponential backoff for the retries. Retries are performed after a backoff interval of firstBackoff * (factor ^ n) where n is the iteration. +If maxBackoff is configured, the maximum backoff applied will be limited to maxBackoff. +If basedOnPreviousValue is true, backoff will be calculated using prevBackoff * factor. + + +The following defaults are configured for Retry filter if enabled: + + +retries — 3 times + + +series — 5XX series + + +methods — GET method + + +exceptions — IOException and TimeoutException + + +backoff — disabled + application.yml @@ -1123,7 +1149,12 @@ using something like - name: Retry args: retries: 3 - statuses: BAD_GATEWAY + statuses: BAD_GATEWAY + backoff: + firstBackoff: 10ms + maxBackoff: 50ms + factor: 2 + basedOnPreviousValue: false @@ -1369,9 +1400,9 @@ route URL will override the ServiceInstance configuration.httpMethod: The Http method used for the request -These metrics are then available to be scraped from /actuator/metrics/gateway.requests and can be easily integated with Prometheus to create a Grafana dashboard. +These metrics are then available to be scraped from /actuator/metrics/gateway.requests and can be easily integrated with Prometheus to create a Grafana dashboard. -To enable the pometheus endpoint add micrometer-registry-prometheus as a project dependency. +To enable the prometheus endpoint add micrometer-registry-prometheus as a project dependency.