This article provides details on how to change ElasticSearch index names for Spring Boot Actuator metrics.
Spring Boot 2.x.x Actuator integration with Micrometer allows metrics data to be exported to ElasticSearch through the use of micrometer-registry-elastic library. For more details, please follow - Exporting Spring Boot Actuator Metrics to ElasticSearch.
However Spring Boot exports the metrics to ElasticSearch indexes with name format: metrics-yyyy-mm. In this article, we will see how to change index name and pattern of ElasticSearch for Spring Boot Actuator collected metrics.
Changing ElasticSearch Index Name for Spring Boot Actuator Metrics
We can simply chnage index names of Elastic for Spring Boot Actuator using following properties -
- management.metrics.export.elastic.index - Defines fixed part of index names. Default is set to metrics.
- management.metrics.export.elastic.indexDateFormat - Defines date format part of index name. Default is set to yyyy-MM.
In order to change index to start with boot-metrics and having different date metrics to different indexes, we need to use format: boot-metrics-yyyy-MM-dd. Here are the properties that need to be used for this -
That's all. You should now see your metrics data being exported to new indexes based on the updated format/pattern.
Thank you for reading through the tutorial. In case of any feedback/questions/concerns, you can communicate same to us through your comments and we shall get back to you as soon as possible.