diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepository.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepository.java index 61453a6c3e..7b49db3aff 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepository.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepository.java @@ -32,8 +32,11 @@ import org.springframework.util.Assert; /** * A {@link MetricRepository} implementation for a redis backend. Metric values are stored - * as regular hash values against a key composed of the metric name prefixed with a - * constant (default "spring.metrics."). + * as zset values plus a regular hash value for the timestamp, both against a key composed + * of the metric name prefixed with a constant (default "spring.metrics."). If you have + * multiple metrics repositories all point at the same instance of Redis, it may be useful + * to change the prefix to be unique (but not if you want them to contribute to the same + * metrics). * * @author Dave Syer */ diff --git a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 89b60e2a7d..5547e0e941 100644 --- a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -658,12 +658,19 @@ http://matt.aimonetti.net/posts/2013/06/26/practical-guide-to-graphite-monitorin Metric service implementations are usually bound to a {sc-spring-boot-actuator}/metrics/repository/MetricRepository.{sc-ext}[`MetricRepository`]. A `MetricRepository` is responsible for storing and retrieving metric information. Spring -Boot provides an `InMemoryMessageRespository` and a `RedisMetricRepository` out of the +Boot provides an `InMemoryMetricRespository` and a `RedisMetricRepository` out of the box (the in-memory repository is the default) but you can also write your own. The `MetricRepository` interface is actually composed of higher level `MetricReader` and `MetricWriter` interfaces. For full details refer to the {dc-spring-boot-actuator}/metrics/repository/MetricRepository.{dc-ext}[Javadoc]. +There's nothing to stop you hooking a `MetricRepository` with back-end storage directly +into your app, but we recommend using the default `InMemoryMetricRespository` +(possibly with a custom `Map` instance if you are worried about heap usage) and +populating a back-end repository through a scheduled export job. In that way you get +some buffering in memory of the metric values and you can reduce the network +chatter by exporting less frequently or in batches. Spring Boot provides +an `Exporter` interface and a few basic implementations for you to get started with that. [[production-ready-code-hale-metrics]]