I have a simple spring boot 2.1.7.RELEASE project using micrometer Elasticsearch registry (using Elasticsearch 7.2.0). The project is available here on github. It has only two classes and looks like this
pom.xml has the following dependencies:
<dependencies>
<dependency>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.springframework.boot</groupId>
</dependency>
<dependency>
<artifactId>spring-boot-starter-actuator</artifactId>
<groupId>org.springframework.boot</groupId>
</dependency>
<dependency>
<artifactId>micrometer-registry-elastic</artifactId>
<groupId>io.micrometer</groupId>
</dependency>
</dependencies>
and two classes: MicrometerElasticApplication:
@SpringBootApplication
public class MicrometerElasticApplication {
public static void main(final String[] args) {
SpringApplication.run(MicrometerElasticApplication.class, args);
}
}
and TestController
@RestController
public class TestController {
@ResponseStatus(HttpStatus.OK)
@GetMapping("/test")
public void sendMessage() {
System.out.println("Received a test message");
}
}
Once I start the app, I can see in the logs
i.m.elastic.ElasticMeterRegistry : publishing metrics to elastic every 1m
which means metrics are sent, but then when I check what is indexed in the Elasticsearch, I can only see documents like this one
{
"_index": "metrics-2019-08",
"_type": "_doc",
"_id": "nWuMdWwBxBoi4XILEHVK",
"_score": 1.0
}
so no fields, just document metadata. Even after hitting the /test
endpoint server times, nothing changes in the metrics
index.
My understanding from reading the official documentation here and checking the common properties here is that Spring by default is going to add metrics for JVM, CPU... and even measure timings for all MVC requests. Right now, I'm not getting anything of those, just empty documents. Setting the property management.metrics.web.server.auto-time-requests
to true does not change anything.
Anyone see what I'm missing here?
UPDATE
I put a break point to ElasticMeterRegistry.publish
method and the request sent to Elaticsearch /_bulk
API looks good to me
POST http://localhost:9200/metrics-2019-08/_bulk
{ "index" : {} }
{"@timestamp":"2019-08-09T10:49:18.826Z","name":"jvm_memory_max","type":"gauge","area":"heap","id":"PS Survivor Space","value":1.5204352E7}
{ "index" : {} }
{"@timestamp":"2019-08-09T10:49:18.826Z","name":"jvm_threads_states","type":"gauge","state":"terminated","value":0.0}
...
When I send this request using Postman, all documents are saved as empty docs, although
Elasticsearch does not report any errors, "errors": false
in the response
{
"took": 8,
"errors": false,
"items": [
...
]
}