Health Actuator in Spring Boot routing to downstream - spring

I have a spring boot app with health actuator enabled. when i see my logs i can see few confusing stuff.
TRACE [Gateway,9909f15dd6d20d29,9909f15dd6d20d29,] - --- [or-http-epoll-3] remoteHost:10.456.7.2|URL:/actuator/health|Session:83d848e8-027f-4c25-bbb4-4b44f92649af|method: o.s.c.g.filter.GatewayMetricsFilter : spring.cloud.gateway.requests tags: [tag(httpMethod=GET),tag(httpStatusCode=200),tag(outcome=SUCCESSFUL),tag(routeId=device),tag(routeUri=http://device-service:7001),tag(status=OK)]
Why is GatewayMetricsFilter logging routeId and route URI for health actuator call. Spring cloud gateway should not route to downstream systems for health actuator.

Related

Spring Actuator to expose /trace or /tracing endpoint for traceId spanId and parentId

Small question regarding SpringBoot actuator and a possible /trace /tracing endpoint please.
I am referring to tracing, as in traceId, spanId and parentId please.
Currently, actuator can expose endpoints like /metrics or /prometheus for metrics (which are not traces).
While SpringBoot apps can send, "push" those metrics directly to a backend metrics server, a popular construct is to expose the /metrics or /prometheus endpoint, so some sort of "poll" system (similar to prometheus agent, metrics beat) which can periodically call the endpoint so the agent will then send it to the backend metrics server.
Some similar construct for /trace /tracing to expose open telemetry, open tracing information can be equality as interesting in my opinion.
What I tried:
I went to expose the /httptrace endpoint from actuator, and added micrometer-tracing to my classpath, hoping trace information would be available.
However, the /httptrace endpoint information is not related at all to traces (as in traceId, spanId parentId).
Question: what is the equivalent in order for actuator to expose trace, tracing information please?
Thank you
I think you can use this: "httptrace" endpoint of Spring Boot Actuator doesn't exist anymore with Spring Boot 2.2.0
Basically as a workaround, add this configuration to the Spring environment:
management.endpoints.web.exposure.include: httptrace
and provide an HttpTraceRepository bean like this:
#Configuration
// #Profile("actuator-endpoints")
// if you want: register bean only if profile is set
public class HttpTraceActuatorConfiguration {
#Bean
public HttpTraceRepository httpTraceRepository() {
return new InMemoryHttpTraceRepository();
}
}

fix different traceId with istio sidecar proxy and spring boot sleuth

Spring boot apps with Sleuth are deployed in pods with istio sidecar injected alongside.
istio virtual service ingresses traffic into the mesh and proxies the request to pods correctly.
Both logs are seen in kibana - one for istio-proxy (sidecar) and another for the spring app using logback + sleuth.
However I would like to see same traceId (x-request-id) header for both requests. Is this a good practice or is rather what is the right way to join/tie these request logs ?
I did one test and found out that istio-proxy is sending 'x-request-id' which corresponds to the value of traceId. However spring creates a new traceId and wondering if there is a way to make them same ?

Spring Boot actuator for backend application

I use Spring-boot 2.2.x for my backend application - spring-kafka + streams. My service will be deployed in Kubernetes as Docker image. I would like to add spring-boot-starter-acutator, but as I checked, from Spring-boot 2.x actuator requires spring-boog-starter-web. And there is a question what is a proper way to use actuator over http and use http server only actuator - management scope/context?
I know that I can use jmx instead of http but I would prefer http.

Is eureka spring version independent?

For a project I am using Spring Eureka. It works great with Spring boot 1.5. I want to upgrade to Spring boot 2. I see that with Spring boot 2 the health endpoints have moved. Does eureka know how to handle this change?
Out of curiosity, when spring registers to eureka does it pass on what the health url is so that eureka knows where to contact the health url?
I did the spring boot version upgrade recently. Eureka works fine with spring boot 2.
Does eureka know how to handle this change?
Yes, based on below configuration it will look for the default /actuator/health endpoint.
/**
* Default prefix for actuator endpoints
*/
private String actuatorPrefix = "/actuator";
private String healthCheckUrlPath = actuatorPrefix + "/health";
So, if we have actuator endpoint enable it tries to connect to the given endpoint for health check.
when spring registers to eureka does it pass on what the health url is so that eureka knows where to contact the health url?
Yes, we can provide the health check URLs while registering client to eureka server. In that case it will always do the health check from provided endpoint.
Here goes the property we can use to set the same-
eureka.instance.health-check-url-path= HEALTH_CHECK_URL_PATH
OR,
eureka:
instance:
healthCheckUrlPath: HEALTH_CHECK_URL

How to add servlet filters to Spring Boot Actuator management endpoints like health, metrics, jolokia?

How can I add servlet filters to Spring Boot Actuator management endpoints like health, metrics, jolokia etc.? Or do I have to use interceptors instead?
Background: I want to log requests that are sent to <IP>:<managementPort>/jolokia

Resources