Consul doesn't show Health - spring-boot

I couldn't check health of my services after the new spring boot upgrade from 1.5x to 2.x. I tried to call /health endpoint which throws an error, then view some spring boot article which said I need to call /actuator/health, then it shows
{"status":"UP"}
I have added this property "management.endpoint.health.show-details=ALWAYS" then it shows something like this.
{"status":"UNKNOWN","details":{"binders":{"status":"UNKNOWN","details":{"consul":{"status":"UNKNOWN"}}},"diskSpace":{"status":"UP","details":{"total":254447448064,"free":149837242368,"threshold":10485760}},"db":{"status":"UP","details":"database":"Oracle","hello":"Hello"}},"refreshScope":{"status":"UP"},"discoveryComposite":{"status":"UNKNOWN","details":{"discoveryClient":{"status":"UP","details":{"services":[]}}}},"clientConfigServer":{"status":"UP","details":{"propertySources":[]}},"hystrix":{"status":"UP"}}}
Can some one let me know, what properties need to be added to see the status instead of "UNKNOWN". Thanks in advance.

Related

how to look at default configuration used for connecting to DB

Since SpringBoot is opinionated, it connects to my Oracle DB using configuration that I didn't have to do. Now, I want to see these config values, how can I do that?
I tried the "env" and "info" actuator endpoints, but they didn't have any information on this
TIA
In your app if you already exposed all actuator endpoints or specific configprops endpoint, you can use "configprops".
<host>/actuator/configprops
Other than the jdbc connection url is there any configuration you specificly wanted to see? perhaps you can try to look at the logging information but it will show a lot more than just configuration values, but if you try to find list of configuration that Spring Boot set here is the reference link

Spring boot metrics for rest api with PathVariables

In my spring boot project I would like to keep count of how many times the rest api endpoint responded with status 200. The spring boot actuator metrics endpoint came close to solving this issue for me out of the box.
However, the /metrics endpoint names provided the aggregate of responses by the endpoint method rather than each of the dynamic endpoints created through #PathVariable.
For example:
while I can get http://localhost:8084/myproject/actuator/metrics/http.server.requests?tag=status:200,uri:/api/users/{id}/books
I would like to do something like
http://localhost:8084/myproject/actuator/metrics/http.server.requests?tag=status:200,uri:/api/users/1/books
and
http://localhost:8084/myproject/actuator/metrics/http.server.requests?tag=status:200,uri:/api/users/2/books
and so on.
Is there an easy way to do this?
You can roll your own WebMvcTagsProvider. That's the place where you can hook into the tag generation. Have a look at DefaultWebMvcTagsProvider to get insight on how it is done for the default behaviour.
A note: The default tagging is done on purpose the way it is to hinder metrics explosion, because every metric name + tag combination is a new metric. So be aware of that.

How to produce metrics of URI correctly in spring boot 2 + webflux

I have a problem using spring boot 2.0.3 + spring webflux (functional endpoints) + metrics. According to the official doc:
The generated metrics of uri should be the request’s URI template prior to variable substitution
Which means instead of /api/person/123, the generated metrics of URI should be something like /api/person/{id}. However, when I query those metrics on my spring boot app with this link http://localhost:8080/actuator/metrics/http.server.requests, I got these URIs:
/api/person/2
/api/person/33
/api/person/12
To reproduce this issue, I put a sample code here: https://gitlab.com/itsleon/demo
Can someone please shed some light on this issue? Thanks in advance!
There's an open issue for that in Spring Boot.
Currently, Spring WebFlux fn doesn't provide the information about the URI pattern that matched for the current request, so there's no way to achieve that currently.
Your assessment is correct, currently the full request URIs are collected.

Spring Boot WebFlux remove Whitelabel

I am testing the new WebFlux framework and I would like to remove the default error view (Whitelabel Error Page). I have noticed that the default server for this framework is Netty and that it seems not to respond to the old server.error.whitelabel.enabled=false.
Is there any other way or am I doing something wrong?
This is a bug and it will be fixed in Spring Boot 2.0.1.RELEASE, see gh-12520.
In the meantime, you could:
exclude completely the ErrorWebFluxAutoConfiguration if you don't want any Spring Boot error handling support
add a error template/static file in your application to override the default view
Note that once it's supported (and without applying the other options I've just listed), your application will just send a raw HTTP error response (i.e. not a JSON response). Is that what you intend to have?

How to remove default Metrics data provided by Spring Actuator

I am trying to get Production metrics for my application. I am using Actuator on top of Spring Boot. Actuator exposes an endpoint for that "/metrics". I have Autowired CounterService class to get my own metrics data. I will be displaying the metrics data in one of our Application Management UI. The problem here is that I don't want all the default metrics data, as the Response JSON given back by the /metrics endpoint is kind off heavy for me to parse and most of the default metrics data are useless for me and give it to the UI. I have gone through the Spring Docs, I didn't get any help.
Appreciate your help on this!
Oh So I found a way to deal with the scenario. Actually Spring This GitHub Link pretty much solves my problem. Actuator Supports Reqex support to query for the data you need. So my url looks like this now : http://{{hostname}}/metrics/counter.*.count instead of this http://{{hostname}}/metrics/. Hope this helps.
Have you tried wrapping the response class from metrics, with a Custom class?

Resources