最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Sending custom metrics to Elasticsearch in Spring Boot - Stack Overflow

programmeradmin0浏览0评论

I am integrating my Spring Boot application to Kibana and followed these steps:

JDK: 17

step-1: Adding elastic-apm-agent

added elastic-apm-agent.jar(1.51.1) into dockerfile. And I see the APM on Kibana and micrometer metrics, but micrometer metrics was increased monotonically.

-javaagent:$ELASTIC_APM_PATH -Delastic.apm.application_packages=com.development -Delastic.apm.secret_token=ELASTIC_APM_TOKEN -Delastic.apm.server_url=http://xxxx:8200

question1

How was it able to send custom metrics before doing step-2?

step-2: Micrometer export configuration

I wanted to see the values in a certain time interval and decided to use ElasticMeterRegistery as shown below. Then, start to see the metrics as expected.

build.gradle.kts

implementation("io.micrometer:micrometer-registry-elastic:1.12.1")

application.yaml

elastic:
   metrics:
      export:
         host: http://xxxx:9200
         step: 1m
         enabled: true

I get this error:

failed to send metrics to elastic

with exception: java.SocketTimeoutException: Read timed out

question2

How can I fix this error?

I am integrating my Spring Boot application to Kibana and followed these steps:

JDK: 17

step-1: Adding elastic-apm-agent

added elastic-apm-agent.jar(1.51.1) into dockerfile. And I see the APM on Kibana and micrometer metrics, but micrometer metrics was increased monotonically.

-javaagent:$ELASTIC_APM_PATH -Delastic.apm.application_packages=com.development -Delastic.apm.secret_token=ELASTIC_APM_TOKEN -Delastic.apm.server_url=http://xxxx:8200

question1

How was it able to send custom metrics before doing step-2?

step-2: Micrometer export configuration

I wanted to see the values in a certain time interval and decided to use ElasticMeterRegistery as shown below. Then, start to see the metrics as expected.

build.gradle.kts

implementation("io.micrometer:micrometer-registry-elastic:1.12.1")

application.yaml

elastic:
   metrics:
      export:
         host: http://xxxx:9200
         step: 1m
         enabled: true

I get this error:

failed to send metrics to elastic

with exception: java.SocketTimeoutException: Read timed out

question2

How can I fix this error?

Share Improve this question edited Feb 3 at 8:43 Mark Rotteveel 109k229 gold badges156 silver badges220 bronze badges asked Feb 2 at 15:26 S.BalabanS.Balaban 1964 silver badges20 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The correct configuration key for setting the Elasticsearch host is management.elastic.metrics.export.host. You will probably need to configure management.elastic.metrics.export.api-key-credentials as well.

See https://docs.spring.io/spring-boot/appendix/application-properties/index.html#application-properties.actuator.management.elastic.metrics.export.host

发布评论

评论列表(0)

  1. 暂无评论