how to use redismetricrepository in spring boot - spring-boot

I am working on spring boot actuator and able to see the metrics of my application. But I want to store these metrics to some db. In Spring doc it has been mentioned that RedisMetricRepository provides option for storing metrics to redis db. But I dont how to make use of this RedisMetricRepository to store metrics to redis db.Kindly help me out how to use RedisMetricRepository for storing metrics to redis db.

You can just create a #Bean of type RedisMetricRepository. I suspect that will just store the metrics in Redis immediately. I prefer to buffer in memory and export to Redis periodically. Here's a sample using #Scheduled to export to Redis every 5s): https://github.com/scratches/aggregator/blob/master/generator/src/main/java/demo/GeneratorApplication.java#L61.

Related

Spring Boot application with Redis cache without database

I am using Spring Boot application , I have below requirement.
I would like to cache all the rows from a particular table(here I have to convert the row into a particular xml format and maintain that in cache) and then also if any updates happens to that row by another application then in my application I will receive an message from Kafka topic. So I want to update the existing xml in the cache with the latest xml message from Kafka topic.
Here I want to use Redis cache, so far what ever the examples I saw are dealing with database only. So I want to know how I can populate cache from a Kafka topic message(or any xml message).Is it possible to cache an xml message in spring boot using Redis cache? Can some body share idea or any practical example?

Spring Boot Micrometer Influxdb custom data insert

I have a Spring Boot Application which consumes data from kafka topic. I am using Micrometer and Influxdb for monitoring purpose. I read in documentation that, By adding micrometer-registry-influx we automatically enable exporting data to InfluxDB. I have some below questions on this -
What kind of data micrometer automatically adds to InfluxDB?
Can we add custom data to InfluxDB according to my application?
How can I publish custom or my application specific data to InfluxDB?
How can I disable adding default data to InfluxDB?
As I understand from the documentation, the standard output set is described here
Adding your own metrics
Metrics filter (here you can exclude standard metrics accordingly)

How to expose Prometheus metrics with RedisCacheManager?

I have a Spring Boot 2 application that has caching with Caffeine cache manager already implemented. Caching is implemented in a standard way with #Cacheable, #CacheEvict, #CachePut annotations.
I migrated the app for using Redis to have caching distributed between pods.
The problem now is with metrics. Before migration Caffeine exposed cache metrics like cache_puts_total, cache_gets_total, etc. and now there is nothing. Is there something implemented for metrics in RedisCacheManager? I can not find anything.
Unfortunately as you can see in the Spring Boot documentation: 52. Metrics, Spring Boot does not provide cache statistics for Redis by default:
By default, Spring Boot provides cache statistics for EhCache, Hazelcast, Infinispan, JCache and Guava. You can add additional CacheStatisticsProvider beans if your favourite caching library isn’t supported out of the box.
As another alternative to implementing this yourself, you can use Redisson. This Redis client comes with an integration with Spring that exposes Prometheus metrics. Your metrics will look just like you hint:
# HELP cache_gets_total the number of times cache lookup methods have returned an uncached (newly loaded) value, or null
# TYPE cache_gets_total counter
cache_gets_total{cache="...",cacheManager="...",name="...",result="miss",} 0.0
cache_gets_total{cache="...",cacheManager="...",name="...",result="hit",} 0.0
# HELP cache_puts_total The number of entries added to the cache
# TYPE cache_puts_total counter
cache_puts_total{cache="...",cacheManager="...",name="...",} 0.0

How to use Apache Ignite as a layer between Spring Boot app and MongoDB?

I have a Spring Boot application that uses MongoDB. My plan is to store data in a distributed caching system before it gets inserted into Mongo. If the database fails, the caching will have a queue and send to the DB once it is up. So, the plan is to make the caching layer in between the application and Mongo.
Can you suggest some ideas on how to implement this using Apache Ignite?
Take a look at write-behind cache store mode. It retries writing to the underlying database if insertion to the underlying DB fails. Let me know how it works for you.
You can also implement a custom CacheStore for an Ignite cache that will do the caching and enable write through for it. If the connection is lost, then you'll be able to collect entries in a buffer, while retrying to establish the connection back.
See more: https://apacheignite.readme.io/docs/3rd-party-store

Spring Boot (Spring Data JPA) - configure PostgreSQL Read Replicas

What is the simplest way to configure read replicas with Spring Boot and Spring Data JPA? I'm searching a lot and cannot find solution.
AWS RDS Aurora Postgresql gives 2 endpoints:
master (write)
replicas (read)
I want to configure my application to use this endpoints.
Why do you need to configure the read replica with Spring Boot, I am guessing that you just need to connect with the read replica, right?
Have you looked the aws sdk for java?
You need to look over a class there named DescribeDBClusterEndpointsResult.

Resources