Getting Started with Prometheus and Grafana with Spring Boot - spring

I am constructing an application on Spring Boot that consumes a REST API endpoint as nested JSON. Then I want to extract my recommendation results based on that data, as graphic dashboards using Grafana and Prometheus.
I want your recommendations about where to start with the fundamentals since I am totally new to this.

Related

Use GraphQL with in existing spring boot rest api

We have few existing rest apis written in spring boot to fetch different data in our project? Now we are exploring options to use GraphQL. But we don't want rest endpoints & response to change since it is being consumed by many UI/backend applications. Can anyone suggest proper way to use GraphQL within existing API without changing rest endpoints and Response type?

How to store a JSON object in couchbase using springboot

I am new to spring boot and I am developing a simple spring boot API to store data to a couchbase db. Storing JSON objects have different formats.Is there any suitable method to achieve this?
Couchbase has given support for the JAVA SDK's that can help you easily integrate the couchbase api's and access the couchbase server to perform CRUD operation's here is the tutorial available : JAVA SDK
And also please take a look at this blog couchbase with Spring Boot sample example

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

Spring MVC App Metrics Frameworks

I have a REST webservice written using Spring MVC 4.latest
The service will be deployed on AWS Opsworks.
I want to have graph showing metrics like: tp90, total requests per second/hour/day, detailed by request uri if possible.
Also if possible DB queries response time.
I would like this to be put in something like Cloudwatch or maybe Ganglia (?)
Is there a framework that does this already?
Any other suggestions on how to achieve this?

Using SolrJ REST-API to query data in a Spring Application

I have solr running at http://localhost:8983/solr/ . I have a Spring MVC app running at http://localhost:8080/login.jsp .
I would like to be able to Query only the solr data from my spring app. What is the best way to go about this? Does someone have a simple running example?
Integrate Solr with Spring using SolrJ.
SolrJ is the Solr Java Client Library which will allow you to query Solr and get back the results in java objects which you can use as Model objects with Spring MVC.
You can easily create a Repository which interacts with Solr using Solrj.
Also, secure the Solr Collections so that no one can access Solr from direct URL without authentication.
The Solrj Client with the Spring MVC app can query SOlr with Authentication.
You can also use spring-data-solr to do so. It should integrate quite nicely into an existing spring MVC application.

Resources