Here you will find instructions for configuring Spring Cloud Gateway instances to expose tracing (with Zipkin and Grafana) and to generate a set of metrics to help understand behavior in aggregate.
To expose metrics to Wavefront we need to create a Secret with the following data: wavefront.api-token and wavefront.uri, representing Wavefront's API token and Wavefront's URI endpoint respectively. For example:
apiVersion: v1
kind: Secret
metadata:
name: metrics-wavefront-secret
data:
wavefront.api-token: "NWU3ZCFmNjYtODlkNi00N2Y5LWE0YTMtM2U3OTVmM2Y3MTZk"
wavefront.uri: "aHR0cHM6Ly92bAdhcmUud2F2ZWZyb250LmNvbQ=="
Then, in the SpringCloudGateway kind, reference the secret created in the step before under the metrics section. For example:
apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGateway
metadata:
name: test-gateway-metrics
spec:
observability:
metrics:
wavefront:
enabled: true
wavefront:
secret: metrics-wavefront-secret
source: my-source
application: my-shopping-application
service: gateway-service
After applying the configuration, Wavefront will start receiving the metrics provided by default by Spring Cloud Gateway.
Spring Cloud Gateway for Kubernetes has a pre-built dashboard you can use in Wavefront.
If you are using VMware's Wavefront, then you can clone and customize the already created Spring Cloud Gateway for Kubernetes Dashboard.
Alternatively, you can use the Wavefront template which resides in a dashboards folder inside Spring Cloud Gateway for Kubernetes release artifacts.
To import it, you must create an API Token. See the Wavefront documentation. Then execute the following command:
curl -XPOST 'https://vmware.wavefront.com/api/v2/dashboard' --header "Authorization: Bearer ${WAVEFRONT_API_TOKEN}" --header "Content-Type: application/json" -d "@wavefront-spring-cloud-gateway-for-kubernetes.json"

To expose metrics to Prometheus we need to add a prometheus section in the SpringCloudGateway kind and if we want scrapping annotations to be added into the gateway pods, for example:
apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGateway
metadata:
name: test-gateway-metrics
spec:
observability:
metrics:
prometheus:
enabled: true
After applying the configuration, the Prometheus actuator endpoint will be available.
If, in addition to this, we want the scrapping annotations to be added to all the Spring Cloud Gateway Pods, we should create our Prometheus configurations with annotations set to true, for example:
apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGateway
metadata:
name: test-gateway-metrics-with-annotations
spec:
observability:
metrics:
prometheus:
enabled: true
annotations:
enabled: true
This will add the following annotations to every Spring Cloud Gateway Pod:
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/actuator/prometheus"
prometheus.io/port: "8090"
You can find a dashboards folder inside Spring Cloud Gateway for Kubernetes release artifacts which contains a Grafana template.
To import it, follow the instructions in the Grafana documentation.

To expose tracing to Wavefront we need to create a Secret with the following data: wavefront.api-token and wavefront.uri, representing Wavefront's API token and Wavefront's URI endpoint respectively. For example:
apiVersion: v1
kind: Secret
metadata:
name: tracing-wavefront-secret
data:
wavefront.api-token: "NWU3ZCFmNjYtODlkNi00N2Y5LWE0YTMtM2U3OTVmM2Y3MTZk"
wavefront.uri: "aHR0cHM6Ly92bAdhcmUud2F2ZWZyb250LmNvbQ=="
Then, in the SpringCloudGateway kind, reference the secret created in the step before under the tracing section. For example:
apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGateway
metadata:
name: test-gateway-tracing
spec:
observability:
tracing:
wavefront:
enabled: true
wavefront:
secret: tracing-wavefront-secret
source: my-source
application: my-shopping-application
service: gateway-service
After applying the configuration, Wavefront will start receiving the traces. See the Wavefront Tracing Basics
Note: By default, the trace context is propagated via B3 Propagation. You configure this by setting the environment variable management.tracing.propagation.type to either b3 or w3c.
Note: By default, only 10% of requests are sampled. You configure this by setting the environment variable management.tracing.sampling.probability to a float between 0 and 1.0.

To expose tracing to Zipkin by providing the Zipkin url under the observability spec:
apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGateway
metadata:
name: test-gateway-tracing
spec:
observability:
tracing:
zipkin:
enabled: true
url: "http://zipkin.default.svc.cluster.local:9411/api/v2/spans"
Note: There is currently no supported authentication mechanisms.
Note: By default, the trace context is propagated via B3 Propagation. You configure this by setting the environment variable management.tracing.propagation.type to either b3 or w3c.
Note: By default, only 10% of requests are sampled. You configure this by setting the environment variable management.tracing.sampling.probability to a float between 0 and 1.0.