标签: actuator

在弹簧启动执行器中设置endpoints.health.sensitive = false时无效

在我的application.yml中:

endpoints:
  restart:
    enabled: true
  shutdown:
    enabled: true
  health:
    sensitive: false
Run Code Online (Sandbox Code Playgroud)

但是当我要求/健康时,我总是得到:

{"status":"UP"}
Run Code Online (Sandbox Code Playgroud)

有什么想法获取更多信息吗?

spring spring-boot actuator

5
推荐指数
2
解决办法
5001
查看次数

Spring Boot Actuator + Hal-Browser 和 DevTools 都不工作

更新:附加pom.xmlapplication.property更多错误/警告消息。

嗨,我对 Spring Boot 非常陌生,只是在 Udemy 上学习了一些课程。

在学习课程时,我通过 spring.io 创建了一个入门项目,并添加了执行器和 Hal 浏览器依赖项,包括开发工具。

刚刚运行我的应用程序并尝试转到localhost:8080/application& /browser,但我得到 404。

我究竟做错了什么?

我写了一个简单的 bean,它返回一个硬编码的值,然后打印出来,我改变了这个值来测试开发工具,但它没有重新启动资源,我不得不杀死并重新启动应用程序以反映新的变化..

我怎样才能检查出什么问题?

如果需要,我可以提供控制台抓取。

请帮忙。

更新:我不知道以下内容的重要性,所以把它放在这里。

在 XML 编辑器中,hal 是红色下划线,悬停时带有以下 msg:

托管版本为 3.0.5.RELEASE 神器在 org.springframework.data:spring-data-releasetrain:Kay-SR5 中管理

在 XML 编辑器中,devtools 是红色下划线,悬停时带有以下味精:

托管版本为 2.0.0.RELEASE 工件托管在 org.springframework.boot:spring-boot-dependencies:2.0.0.RELEASE

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

    <groupId>com.myoxigen.training.springboot</groupId>
    <artifactId>library</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>library</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository …
Run Code Online (Sandbox Code Playgroud)

browser spring hal spring-boot actuator

5
推荐指数
2
解决办法
4709
查看次数

是否可以更改弹簧执行器执行健康脉冲的频率?

我试图环顾四周,看看如何修改我的执行器端点(特别是健康状况)以限制其频率。我想看看是否可以将其设置为针对特定数据集(前邮件)每分钟触发一次,但留给其他人使用?

到目前为止,我似乎无法在任何地方找到这种逻辑。我能想到的唯一已知方法是创建自己的健康服务器:

@Component
@RefreshScope
public class HealthCheckService implements HealthIndicator, Closeable {
@Override
public Health health() {
    // check if things are stale
    if (System.currentTimeMillis() - this.lastUpdate.get() > this.serviceProperties.getMonitorFailedThreshold()) {
        String errMsg = '[' + this.serviceName + "] health status has not been updated in over ["
                + this.serviceProperties.getMonitorFailedThreshold() + "] milliseconds.  Last updated: ["
                + this.lastUpdate.get() + ']';
        log.error(errMsg);
        return Health.down().withDetail(this.serviceName, errMsg).build();
    }

    // trace level since this could be called a lot.

    if (this.detailMsg != null) {
        Health.status(this.status);
    } …
Run Code Online (Sandbox Code Playgroud)

spring actuator

5
推荐指数
0
解决办法
545
查看次数

java中promtheus的错误(spring acuator)

我在 Spring Boot 应用程序中启用并配置了带有 Prometheus 端点的 Spring Actuator。但是我收到一个错误,即 Prometheus 要求所有具有相同名称的仪表都具有相同的标签键集。但不幸的是,Spring Actuator 不会为jvm_gc_pause_seconds.

我正在使用:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.1.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

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

....

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-core</artifactId>
    <version>1.5.1</version>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
    <version>1.5.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

这是我的错误信息:

java.lang.IllegalArgumentException: Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter named 'jvm_gc_pause_seconds'  ?
?     at io.micrometer.prometheus.PrometheusMeterRegistry.lambda$applyToCollector$17(PrometheusMeterRegistry.java:429)                                                                       ?
?     at java.base/java.util.concurrent.ConcurrentHashMap.compute(Unknown Source)                                                                                                            ?
?     at io.micrometer.prometheus.PrometheusMeterRegistry.applyToCollector(PrometheusMeterRegistry.java:413)                                                                                 ?
?     at io.micrometer.prometheus.PrometheusMeterRegistry.newTimer(PrometheusMeterRegistry.java:196)                                                                                         ? …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot-actuator prometheus actuator

5
推荐指数
1
解决办法
561
查看次数

Spring Boot 2自定义执行器端点

Spring Noob:好的。我首先从STS Spring Starter项目/ Maven / Java 8 / Spring Boot 2.0开始,然后选择Web和Actuator依赖项。它的构建和运行良好,并响应http:// localhost:8080 / actuator / health。我在主应用程序类中添加了“端点”,因此它看起来像这样。

package com.thumbsup;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class YourStash11Application {

    public static void main(String[] args) {
        SpringApplication.run(YourStash11Application.class, args);
    }

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

}
Run Code Online (Sandbox Code Playgroud)

我尝试启用application.properties中的所有内容:

management.endpoints.enabled-by-default=true
management.endpoint.conditions.enabled=true
management.endpoint.mypoint.enabled=true
management.endpoints.web.exposure.include=*
Run Code Online (Sandbox Code Playgroud)

但是在构建时,没有对映射/ actuator / mypoint的引用,并且
http:// localhost:8080 / actuator / mypoint
http:// localhost:8080 / application …

java spring endpoint spring-boot actuator

3
推荐指数
2
解决办法
5177
查看次数

Spring Boot 2.0 未注册自定义执行器端点 Bean

我正在尝试在 Spring Boot 2.0.2.RELEASE 应用程序中添加自定义执行器端点。我正在遵循官方指南官方迁移指南这篇文章

我能够通过属性配置所有内容:隐藏/公开端点、更改基本路径等。一切正常,除了我的自定义端点 bean 没有被WebMvcEndpointHandlerMapping. 它根本没有出现在这些著名的日志记录行中:

EndpointLinksResolver        : Exposing 2 endpoint(s) beneath base path '/actuator'
WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
Run Code Online (Sandbox Code Playgroud)

这三行是我得到的全部。我可以访问/actuator/health/actuator/info没有任何问题,但不是我的自定义端点。我显然得到 404。

到目前为止我尝试过的:

  • 检查我的端点类是否在上下文中注册为 bean。
  • 通过 yaml 配置显式公开它。
  • 通过暴露一切 management.endpoints.web.exposure.include=*
  • 完全删除了所有的管理配置,因为它应该是默认可用的。
  • 三重检查端点 ID。
  • 重命名端点 ID。

我至少可以研究什么的任何想法?到目前为止,我发现的所有问题最终都没有意识到他们也需要 …

java spring-boot spring-boot-actuator actuator

3
推荐指数
1
解决办法
4100
查看次数

有没有办法记录假客户端的响应时间

@FeignClient(...)
public interface SomeClient {
@RequestMapping(value = "/someUrl", method = POST, consumes = "application/json")
    ResponseEntity<String> createItem(...);

}
Run Code Online (Sandbox Code Playgroud)

有没有办法找到 createItem api 调用的响应时间?我们正在使用弹簧靴、执行器、普罗米修斯。

metrics spring-boot actuator spring-cloud-feign openfeign

3
推荐指数
1
解决办法
5749
查看次数

弹簧启动执行器健康终点

我已经创建了一个像这样的PostgreSQL运行状况指示器:

@Component
public class PostgresHealthIndicator extends AbstractHealthIndicator {

    @Autowired
    DataSource postgresDataSource;

    public DataSourceHealthIndicator dbHealthIndicator() {
        DataSourceHealthIndicator indicator = new DataSourceHealthIndicator(postgresDataSource);
        return indicator;
    }

    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        Health h = dbHealthIndicator().health();
        Status status = h.getStatus();
        if (status != null && "DOWN".equals(status.getCode())) {
            builder.down();
        } else {
            builder.up();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的Application.java中,我正在为此组件扫描此包:

@ComponentScan({"com.bp.health"})
Run Code Online (Sandbox Code Playgroud)

在我的application.properties中,我有以下设置:

endpoints.health.sensitive=false
endpoints.health.id=health
endpoints.health.enabled=true
Run Code Online (Sandbox Code Playgroud)

当我点击{url}/health时,我看到:

{ "地位": "DOWN"}

我需要做什么才能显示自定义健康指标?

spring spring-boot spring-boot-actuator actuator

1
推荐指数
1
解决办法
1万
查看次数

如何禁用 configserver Health 页面检查默认标签 git

我有简单的配置服务器实现,当我浏览/health端点时,我得到:

{ 
  status:"UP",
  "details":{
    "configserver":{
       "status":"UP",
       "details":{
        "repositories":[
           {
              ...
Run Code Online (Sandbox Code Playgroud)

如何在我的配置服务器再次检查配置服务器运行状况的情况下停止此操作。这导致配置服务器多次调用 git,这在我的场景中是不需要的。

spring-boot spring-cloud spring-boot-actuator actuator configserver

1
推荐指数
1
解决办法
552
查看次数