标签: spring-boot-actuator

Spring启动时重启数据源

我正在尝试更新Spring Boot中的数据源,当数据库名称,密码或主机名等数据库属性在spring配置文件或自定义数据库属性文件中更改时.当属性更改时,应用程序必须通过侦听属性更改来自行更新.

一旦数据库配置发生变化,我就会使用Spring执行器来重启bean.但是用户必须明确地发布重新启动的请求.必须通过监听更改并更新数据源来避免此步骤.

你能告诉我在Spring启动时做到这一点的最佳方法吗?

java spring spring-mvc spring-boot spring-boot-actuator

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

在springboot管理UI中注册Dropwizard(Spring MVC)应用程序

我有一个使用spring MVC和Dropwizard开发的REST API.我使用Dropwizard框架创建了健康检查.现在我看看如何将此API注册到Springboot管理员,以便我可以在管理UI上查看所有指标.

我有其他API使用Springboot开发.因此,将它们注册到Springboot管理员非常简单.但在另一个Dropwizard案例中,我无法注册,也不确定是否需要进行任何额外配置.

期待回应.谢谢

spring-mvc dropwizard spring-boot spring-boot-actuator spring-boot-admin

7
推荐指数
0
解决办法
178
查看次数

将"mean","min"或"百分位数"添加到Spring Boot 2指标中?

我在Spring Boot 2版本中使用了新的MicroMeter指标.2.0.0-RELEASE

通过/actuator/metrics/{metric.name}端点发布指标时,我得到以下内容:

对于DistributionSummary:

"name": "sources.ingestion.rate",
    "measurements": [
        {
           "statistic": "COUNT",
            "value": 5
        },
        {
            "statistic": "TOTAL",
            "value": 72169.44162067816
        },
        {
            "statistic": "MAX",
            "value": 17870.68010661754
        }
    ],
    "availableTags": []
}
Run Code Online (Sandbox Code Playgroud)

对于Timer:

{
    "name": "sources.ingestion",
    "measurements": [
        {
            "statistic": "COUNT",
            "value": 5
        },
        {
            "statistic": "TOTAL_TIME",
            "value": 65.700878648
        },
        {
            "statistic": "MAX",
            "value": 22.661545322
        }
    ],
    "availableTags": []
}
Run Code Online (Sandbox Code Playgroud)

是否可以丰富测量值以增加平均值,最小值百分位数度量? …

java spring-boot spring-boot-actuator micrometer

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

执行器普罗米修斯的自定义指标

我已经激活了弹簧执行器prometheus endpont /actuator/prometheus.通过添加千分尺和执行器的依赖关系并启用prometheus endpont.我如何获得自定义指标?

java metrics spring-boot spring-boot-actuator prometheus

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

未连接邮件服务器时 Jhipster Health Endpoint 失败

JHipster / Spring boot 提供了一个很好的端点/management/health,它聚合了 db、磁盘和邮件等子系统的健康信息。不幸的是,当与邮件服务器的连接失败时,整个端点都会失败。所以你没有得到失败的信息。

我得到这样的轨迹:

o.s.b.a.health.MailHealthIndicator       : Health check failed

com.sun.mail.util.MailConnectException: Couldn't connect to host, port: XXXX, NNNN25025; timeout -1
...
   at org.springframework.boot.actuate.health.MailHealthIndicator.doHealthCheck(MailHealthIndicator.java:40)
    at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:43)
    at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:68)
    at org.springframework.boot.actuate.endpoint.HealthEndpoint.invoke(HealthEndpoint.java:85)
    at org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.getCurrentHealth(HealthMvcEndpoint.java:177)
    at org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.getHealth(HealthMvcEndpoint.java:166)
    at org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(HealthMvcEndpoint.java:143)
Run Code Online (Sandbox Code Playgroud)

这是 spring boot 1.5.9 我应该在哪里解决这个问题,以便捕获异常并返回错误状态?

spring-boot jhipster spring-boot-actuator

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

将弹簧引导执行器运行状况端点更改为自定义端点

是否可以将弹簧靴执行器健康端点更改为自定义端点?像下面这样的东西。

http://localhost:8080/actuator/health

http://localhost:8080/myapp/apphealth

只想更改名称,而不是执行器/健康的响应。是否可以?

java spring-boot spring-boot-actuator

7
推荐指数
2
解决办法
5041
查看次数

RabbitHealthIndicator - 健康检查失败

和我们这里有类似的情况Spring Cloud Stream 和 RabbitMQ 健康检查

错误信息

2018-12-04 05:17:31.768 INFO 1 --- [nio-8080-exec-6] osarcCachingConnectionFactory :尝试连接到:[localhost:5672]
2018-12-04 05:17:31.775 WARN 1 --- [nio-8080-exec-6] osbahealth.RabbitHealthIndicator:健康检查失败

org.springframework.amqp.AmqpConnectException:java.net.ConnectException:连接被拒绝(连接被拒绝)
    在 org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:62) ~[spring-rabbit-1.7.9.RELEASE.jar:na]
    在 org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:387) ~[spring-rabbit-1.7.9.RELEASE.jar:na]
    在 org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:586) ~[spring-rabbit-1.7.9.RELEASE.jar:na]
    在 org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1436) ~[spring-rabbit-1.7.9.RELEASE.jar:na]
    在 org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1417) ~[spring-rabbit-1.7.9.RELEASE.jar:na]
    在 org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1393) ~[spring-rabbit-1.7.9.RELEASE.jar:na]
    在 org.springframework.boot.actuate.health.RabbitHealthIndicator.getVersion(RabbitHealthIndicator.java:49) ~[spring-boot-actuator-1.5.15.RELEASE.jar:1.5.15.RELEASE]
    在 org.springframework.boot.actuate.health.RabbitHealthIndicator.doHealthCheck(RabbitHealthIndicator.java:45) ~[spring-boot-actuator-1.5.15.RELEASE.jar:1.5.15.RELEASE]
    在 org.springframework.boot.actuate.health.Abs​​tractHealthIndicator.health(AbstractHealthIndicator.java:43) ~[spring-boot-actuator-1.5.15.RELEASE.jar:1.5.15.RELEASE]
    在 org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:68) [spring-boot-actuator-1.5.15.RELEASE.jar:1.5.15.RELEASE]
    在 org.springframework.boot.actuate.endpoint.HealthEndpoint.invoke(HealthEndpoint.java:86) [spring-boot-actuator-1.5.15.RELEASE.jar:1.5.15.RELEASE]
    在 org.springframework.boot.actuate.endpoint.HealthEndpoint.invoke(HealthEndpoint.java:36) [spring-boot-actuator-1.5.15.RELEASE.jar:1.5.15.RELEASE]
    在 org.springframework.boot.actuate.endpoint.mvc.AbstractEndpointMvcAdapter.invoke(AbstractEndpointMvcAdapter.java:56) [spring-boot-actuator-1.5.15.RELEASE.jar:1.5.15.RELEASE]
    在 org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke(EndpointMvcAdapter.java:42) [spring-boot-actuator-1.5.15.RELEASE.jar:1.5.15.RELEASE]
    在 sun.reflect.GeneratedMethodAccessor559.invoke(Unknown Source) ~[na:na]
    在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
    在 java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
    在 org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) [spring-web-4.3.18.RELEASE.jar:4.3.18.RELEASE]
    在 …

spring spring-boot spring-boot-actuator spring-integration-amqp

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

如何在 Spring Boot 2 中保护具有角色的执行器端点?

您能帮助保护 Spring Boot 2 中的执行器端点吗?我检查了迁移指南,但它对我没有帮助。

这是我的安全配置:

@Configuration
@EnableWebSecurity
public class SecConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                .requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("ADMIN")    
                .anyRequest().authenticated();
    }

}
Run Code Online (Sandbox Code Playgroud)

但是当我去http://localhost:8080/actuator/health它加载时无需登录。其他带有前缀的端点/actuator也不需要登录。我做错了什么?

我还使用此配置添加了 OAuth:

@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
    @Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
    clients
            .inMemory()
                .withClient("client-id")
                    .scopes("read", "write")
                    .authorizedGrantTypes("password")
                    .secret("xxxxxx")
                    .accessTokenValiditySeconds(6000);
}
}

@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
       http
            .sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS) …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot spring-boot-actuator

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

使用弹簧执行器(普罗米修斯)公开 kafka 流指标

我正在使用 Springboot 2 运行 Kafka Stream 应用程序。

我想让我的 kafka 流指标以普罗米修斯格式提供 host:8080/actuator/prometheus

我没办法拥有这个。我不确定我是否了解 kafka 流指标是如何导出的。能actuator得到这些JMX指标?有没有办法获取这些指标并以 Prometheus 格式公开它们?

PS:也没有与 java jmx_prometheus_agent 一起工作

有人有解决方案或示例吗?

谢谢

spring-boot-actuator apache-kafka-streams

7
推荐指数
2
解决办法
551
查看次数

Kafka 消费者指标从 Spring Boot 2.2.2 升级到 2.3.0

问题:

我们将 Spring Boot 版本从 2.2.2 升级到 2.3.0,2.2.2kafka_consumer_*中 Prometheus 端点中看到的所有指标在 2.3.0 中都看不到。

例如,缺少以下所有内容:

  • kafka_consumer_records_consumed_total_records_total
  • kafka_consumer_records_lag_records
  • kafka_consumer_fetch_latency_max_seconds
  • kafka_consumer_bytes_consumed_total_bytes_total

不确定我们是否缺少某种配置或文档中隐藏的东西......

已经尝试过的:

  • 梳理了 Spring Boot 2.3.0 发行说明、更新的千分尺文档和更新的 spring-kafka 文档,了解为什么会发生这种情况
  • 谷歌搜索到感觉就像地球的尽头
  • 尝试升级到 Spring Boot 2.2.7 并且 kafka 指标仍然存在,只有升级到 2.3.0 似乎会导致问题
  • 删除了我们项目代码中的任何不需要的依赖项/自定义,并且裸机只是连接到本地主机上的 kafka 容器,并且指标仍然没有出现

相关代码/详情:

  • 我们将 Red Hat AMQ Streams 用于我们的 kafka 代理(kafka 版本 2.1.1)
  • 我们在环境中唯一改变的是 Spring Boot 版本(以及自动拉入/更新的依赖项)以重新创建此问题

下面是我们build.gradle.kts改动前的:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "2.2.2.RELEASE"
    id("io.spring.dependency-management") version "1.0.9.RELEASE"
    kotlin("jvm") version "1.3.72"
    kotlin("plugin.spring") version "1.3.72"
}

group = "ourGroup"
version …
Run Code Online (Sandbox Code Playgroud)

spring-boot spring-boot-actuator prometheus spring-cloud-stream spring-kafka

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