Spring Boot Actutor web metrics - disable (or group) http_server_requests_seconds_sum - spring

I have a service which handles quite a big amount of REST requests (arount 500k per hour). Most of these calls are GET request with diffrent URLs. To grab metrics from the service I'm using Spring Boot Actuator (services are writen with spring boot 2.0 ) with micrometer and prometheus. So on path: /actuator/prometheus I have all metrics for prometheus.
Now after around 10 min my services stop serving metric, and it could be because there are a lot of different URLs which cause a lot of http_server_requests_seconds_sum metrics.
I want to disable this metric, or maybe group it for all endpoints.

You could disable http metrics
management.metrics.enable.http=false

I found settings to disable this metric: auto-time-requests
But to make it work with reactive endpoint I need also to upgrade Spring Boot to 2.1.0.
There is side effect i don't know any information how many RQ handle my service.
Maybe now i change the question - is there any way to group this metric ?

Related

Ratelimit Specific path using Spring gateway

I was trying to migrate my project to the Latest spring gateway, previously I was using zuul rate limiter which has the flexibility to the specific exact path to rate limit ex "/api/xxx/yyy" but using the latest spring gateway, especially if I have service discovery, I have to apply rate-limiting on the whole service, is there a way to work around this?

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.

adding end points in prometheus integration

How to add/integrate rest api end points in prometheus. For eg in splunk we are monitoring micro services transactions and logs.
Lets say below spring boot:-
/abc/v1/something
/abce/v1/something2
In one line :-how can we add above micro services end points to prometheus for motioning
When using Spring Boot 2, you can easily expose your application metrics for Prometheus. See here. You'd add spring-boot-starter-actuator and the Prometheus support with micrometer-registry-prometheus to your dependencies.
This will expose the metrics under /actuator/prometheus in the Prometheus exposition format to be scraped by your Prometheus instance.
Assumung you are using Spring WebMvc, then you'll get out-of-the-box metrics for your HTTP endpoints. (Jersey support is also provided with an extra module/dependency.)

How does the Spring Boot Actuator work together with the Netflix Servo?

There are Spring Boot project that uses a Netflix Servo to collect metrics and send to Graphite.
I want to send metrics with the Spring Boot Actuator on Graphite, such as number request per every endpoint and time of response for every request, instead of creating custom metric.
But I ran into the problem. When I use the library only spring-boot-starter-actuator, then the desired parameters displays:
but when I apply library spring-cloud-starter-eureka, displayed only time of response from servo:
If someone faced with this problem, can you explain why it happens and how to solve it?
I use such version Spring Boot - 1.5.9.RELEASE and Spring Cloud - Edgware.SR1.
I will be glad to any response)
Link to test project: https://github.com/rmartseniuk/spring-metric

How to collect Metrics in Spring-Cloud Zuul

We have created our application with Spring-Cloud Eureka and Spring-Cloud Zuul with multiple core / support micro services registering to Eureka and accessed via Zuul, everything works fine.
We wanted to collect metrics of the APIs that is accessed via ZUUL.
For example, API - ".../extract" need to know how many times its accessed in 5,15 and 60min time period.
We did some analysis and found various metrics library like Netflix Servo, Dropwiard Metrics, Spring Boot Actuator. Everything points to implementation at the service or API level. We wanted our metrics to be captured at ZUUL itself so that a simple counter is implemented in ZUUL and that would provide us the required metrics. Any suggestion in how to implement this would be helpful.

Resources