gpt4 book ai didi

elasticsearch - 如何配置spring-boot micrometer插入elasticsearch?

转载 作者:行者123 更新时间:2023-12-02 22:35:16 24 4
gpt4 key购买 nike

我有一个 spring-boot 2 应用程序,它公开了它的执行器端点。这些值,我想导出到现有的 elasticsearch 实例。因此我使用了以下内容:

pom.xml

...

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
</parent>

<properties>
<java.version>11</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-elastic</artifactId>
<version>1.2.0</version>
</dependency>

...

</dependencies>

application.yml

management:
metrics:
export:
elastic:
enabled: true
host: http://192.168.23.43:9200/
auto-create-index: true
index: metrics
step: 1m

启动应用程序时,POST 抛出以下异常:

2019-09-04 11:20:42.498  WARN 2902 --- [       Thread-3] i.m.c.instrument.push.PushMeterRegistry  : Unexpected exception thrown while publishing metrics for ElasticMeterRegistry

java.lang.RuntimeException: java.lang.IllegalArgumentException: Unexpected response body: {"error":"Incorrect HTTP method for uri [/] and method [POST], allowed: [DELETE, GET, HEAD]","status":405}
at io.micrometer.elastic.ElasticMeterRegistry.determineMajorVersionIfNeeded(ElasticMeterRegistry.java:252) ~[micrometer-registry-elastic-1.2.0.jar:1.2.0]
at io.micrometer.elastic.ElasticMeterRegistry.publish(ElasticMeterRegistry.java:194) ~[micrometer-registry-elastic-1.2.0.jar:1.2.0]
at io.micrometer.core.instrument.push.PushMeterRegistry.publishSafely(PushMeterRegistry.java:48) ~[micrometer-core-1.1.4.jar:1.1.4]
at io.micrometer.core.instrument.push.PushMeterRegistry.close(PushMeterRegistry.java:83) ~[micrometer-core-1.1.4.jar:1.1.4]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:337) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:271) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:571) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:543) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1034) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:504) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1027) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1057) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1026) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:945) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
Caused by: java.lang.IllegalArgumentException: Unexpected response body: {"error":"Incorrect HTTP method for uri [/] and method [POST], allowed: [DELETE, GET, HEAD]","status":405}
at io.micrometer.elastic.ElasticMeterRegistry.getMajorVersion(ElasticMeterRegistry.java:260) ~[micrometer-registry-elastic-1.2.0.jar:1.2.0]
at io.micrometer.elastic.ElasticMeterRegistry.determineMajorVersionIfNeeded(ElasticMeterRegistry.java:250) ~[micrometer-registry-elastic-1.2.0.jar:1.2.0]
... 17 common frames omitted

我确保 elasticsearch 可以访问,但事实上,它试图针对 / 发布,这让我感到困惑。我错过了什么?

最佳答案

由于某种原因,micrometer-registry-elastic 的版本导致了这个问题。降级到版本 1.1.4 后一切正常。

关于elasticsearch - 如何配置spring-boot micrometer插入elasticsearch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57786384/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com