How to get spring boot cloud/actuator to support prometheus Exemplars? - spring-boot

The Exemplars support essentially adds the trace-id to metrics that are being scraped. I found a tutorial on how would it work with GoLang[1] but cannot figure out how to do this with spring boot libraries/functionalities. I know that Prometheus Java Client supports it as described at [2] but not sure how to get it to work with Springboot.
https://vbehar.medium.com/using-prometheus-exemplars-to-jump-from-metrics-to-traces-in-grafana-249e721d4192
https://github.com/prometheus/client_java/pull/615

Update: Exemplars are supported by Micrometer and Spring Cloud Sleuth.
I'm not 100% sure I get your question right: I'm assuming you are talking about the /actuator/prometheus endpoint.
The support for metrics in Spring is provided by Micrometer that also supports Prometheus and Spring Boot "just" sets up an actuator endpoint for it.
So the real question is: does Micrometer support exemplars? Right now it does not and we haven't had anyone asking for it so far (this issue is a little bit connected). So if you want this feature, please open an issue(Enhancement request) on GitHub.
Update: I opened an issue for this: https://github.com/micrometer-metrics/micrometer/issues/2672, please feel free to +1 or chime-in.
Adding exemplars support in Micrometer is not the end of the story, we need to add support for Spring Cloud Sleuth too and solve a few other potential issues.
Until this is implemented, I guess your best bet is using the prometheus client.

Related

What is prometheus-rsocket-proxy and how to use it?

I have a Spring Boot based short-live service.
Until now, I used PushGateway to send metrics to Prometheus.
I encountered this repository and I'm trying to understand how do I setup the proxy. It's not clear from the docs.
Thanks

Metrics of redis and solr in spring boot

I have services built in spring boot 2.0.2. I`m using redis and solrj.
Now if i want to get metrics of redis and solr. It don`t show in
http://localhost:8080/actuator/metrics
Is there any way e.g making custom endpoint to get redis and solr metrics?
Any help would be appreciated..
Yes, it should be possible.
Spring boot 2's default metrics framework is Micrometer
When this framework is integrated into spring boot application (via starter as usual), any metrics reported to micrometer will immediately appear in spring boot actuator.
So the question is whether the redis/solrj integration expose Metrics or not.
If they are not, you'll have to understand what exactly you want to measure and plug in the integration.
Here is the example:
import io.micrometer.core.annotation;
#Timed("my-redis-calls")
public void doSomethingInMyCode() {
//call redis here
}
Of course, there is also a programmatic interface, using annotations in not mandatory
The code shown in Mark Bramnik's answer doesn't specifically give you timing for Redis client calls, it gives you timing for doSomethingInMyCode method, which can be different.
Micrometer support seems to be available in the Lettuce 6.1 release.
MeterRegistry meterRegistry = …;
MicrometerOptions options = MicrometerOptions.create();
ClientResources resources = ClientResources.builder().commandLatencyRecorder(new MicrometerCommandLatencyRecorder(meterRegistry, options)).build();
RedisClient client = RedisClient.create(resources);
https://lettuce.io/core/release/reference/index.html#command.latency.metrics.micrometer

why we use jersey with spring? What are the benefits?

I want to know that why we use jersey with spring and what are the benefits of using it.
I have searched on google but not getting proper answer so i am asking this question here.Sorry because i know my question is old but i am very confused now.
Please suggest me the example of jersey with spring and hibernate.
Thanx in advance.
I use Jersey2 with Spring in one of my projects and in the other Spring MVC4. The advantage of Jersey is its simplicity. If you are creating only RESTful Web services - use Jersey, if you have to generate also some web pages for users, consider to use Spring MVC.
Additionally, I develop my applications on Google Cloud, so the warm up time is very important (if there is a traffic spike, many instances have to wake up in the background to be ready for incoming requests) - according to my tests Jersey is a bit faster than MVC.
Here you have an example of complete configuration:
Integrating Jersey 2 and Spring with Java Based Configuration

Is there a way of collecting metrics from Spring XD to Graphite?

While reading the documentation for Spring XD I seen that it has a model for collecting metrics.
But when I looked into the code, I have seen that this is a custom implementation for Spring XD. None the less in the project dependencies there is codahale's metrics.
No it would be pretty useful to be able to add reporters (like the Graphite reporter which is also in the libs of Spring XD ) to the collected metrics.
But I wasn't able to find anything in the documentation on wether this is possible or how this should be done.
Does somebody have a hint how to do it, or if it is possible at the moment?
Thanks,
Christoph
Spring XD runtime components (XD admin, container and single-node JVMs) use Spring Boot internally. Spring Boot supports collection of codahale's metrics:
http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html#production-ready-code-hale-metrics
Since the codahale metrics jars are available in $XD_HOME/lib, all these metrics are already exposed at the Spring XD management endpoint.
By default management endpoint is enabled on XD admin. You can access them:
http://localhost:9393/management/metrics
For the container JVM, you can set the management port explicitly by setting XD_MGMT_PORT and access from '/management/metrics' endpoint.
You can refer to monitoring-management section in Spring XD wiki for more detail.

Spring XD REST Service

I would like to have a REST service to expose the data read and processed from Spring XD. Similar to the one in the Analytics Server.
For example I would like my own functions which can be exposed similar to Counters and be able to access the data from a web browser.
Is there any tutorial? I have searched and found that Spring Boot is the one but I am looking for help on how I integrate it with Spring XD.
Would be very helpful if someone can point me to the instructions on how I can achieve this.
You can use trigger as a source with http-client as a processor processor to access any web browsers info regardless if it is a web service URL or not.
Moha.

Resources