【问题标题】:How to activate JMX monitoring in spring boot standalone app如何在 Spring Boot 独立应用程序中激活 JMX 监控
【发布时间】:2018-09-22 15:44:23
【问题描述】:

我浏览了几乎所有文档,但都无法掌握这些神秘的东西。 所以我的问题 - 我可以使用我的独立 Spring Boot 应用程序 通过 http jmx url 监控我的应用程序的运行状况和其他指标吗?我需要为此配置其他东西吗? 我在启动应用程序中添加了以下依赖项。

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jolokia</groupId>
        <artifactId>jolokia-core</artifactId>
    </dependency>

我还在配置文件中配置了以下属性。

management.endpoints.web.exposure.include=*
management.endpoints.jmx.unique-names=true
management.server.port=8080
management.server.ssl.enabled=false

当我尝试点击 URL:http://localhost:8080/actuator/jolokia/health 时,我看不到任何结果。

还尝试添加如下自定义端点,但不起作用。

@Endpoint(id="mypoint")
    @Component
    public class myPointEndPoint {
        @ReadOperation
        public String mypoint(){
            return "Hello" ;
        }

带有附加属性
management.endpoint.mypoint.enabled=true

【问题讨论】:

    标签: java spring-boot jmx jolokia


    【解决方案1】:

    问题是您尝试调用的 url。 首先,使用以下命令检索可能的 mbean:http://localhost:8080/actuator/jolokia/list

    查看 Health mbean 时,必须提供唯一名称和操作 (op)。

    就我而言,它看起来像:http://localhost:8080/actuator/jolokia/exec/org.springframework.boot:type=Endpoint,name=Health,identity=4200098/health

    同时查看 Jolokia 文档:https://jolokia.org/reference/html/index.html

    【讨论】:

    • 谢谢。这意味着它可以在没有网络应用程序的情况下工作。我将尝试上述解决方案并回复您
    • 获取列表的第一个 URL 不起作用。从 doc 中尝试更多的东西。
    • 我推送了我使用的示例:github.com/mydeveloperplanet/myspringactuatorplanet/tree/… 最后一次提交显示了我为使其正常工作所做的更改。我还在 application.properties 中添加了一些东西,但我不确定它是否真的有必要。
    • 谢谢。我去看看。
    • 我通过代码查看了 starter-web 依赖项。因为我需要 JMx 在独立应用程序中工作,所以我不想添加它。或者如果我只是为了 JMX 目的添加它(不是我的应用程序中的主要功能,而是想作为补充添加),这有意义吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-03
    • 1970-01-01
    • 2016-07-04
    相关资源
    最近更新 更多