3

我有一个 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>

应用程序.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 是可访问的,但它试图针对 发布的事实让/我感到困惑。我错过了什么?

4

1 回答 1

0

由于某种原因,micrometer-registry-elastic导致问题的版本。降级到版本后,1.1.4一切都按预期工作。

于 2019-09-06T09:17:11.497 回答