标签: spring-boot-actuator

Spring Boot - 将/ health端点的位置更改为/ ping/me

我将endpoints.health.path属性设置为/ping/me.但我无法使用http:// localhost:9000/ping/me访问端点 它只适用于http:// localhost:9000/health.我错过了什么?这是app属性文件中的代码.

#Configuration for Health endpoint
endpoints.health.id=health
endpoints.health.path=/ping/me
endpoints.health.enabled=true
endpoints.health.sensitive=false

#Manage endpoints
management.port=9000
management.health.diskspace.enabled=false
Run Code Online (Sandbox Code Playgroud)

我得到的回应是:

{
"timestamp" : 1455736069839,
"status" : 404,
"error" : "Not Found",
"message" : "Not Found",
"path" : "/ping/me"
}
Run Code Online (Sandbox Code Playgroud)

spring health-monitoring spring-boot spring-boot-actuator

8
推荐指数
2
解决办法
9237
查看次数

在Spring Boot Actuator中为/ health端点启用CORS

我们希望为/health弹簧启动执行器提供的端点的所有GET请求启用Cors .

我们尝试添加以下bean但没有成功

@Bean
public WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping("/health").allowedMethods("GET");
        }
    };
}
Run Code Online (Sandbox Code Playgroud)

spring cors spring-boot spring-boot-actuator

8
推荐指数
2
解决办法
6521
查看次数

Spring Boot 执行器 - MAX 属性

我正在使用 Spring Boot Actuator 依赖项来获取应用程序的见解。为此,我使用了 Spring Boot Admin。客户端-服务器的配置工作正常。我必须测量将要执行的端点的计数、总时间和最大值。

uri:/user/asset/getAllAssets
TOTAL_TIME: 831ms
MAX: 0ms 

uri:/user/getEmployee/{employeeId}
TOTAL_TIME: 98ms
MAX: 0ms
Run Code Online (Sandbox Code Playgroud)

为什么MAX(时间)是0而TOTAL_TIME:是Xms

Spring Boot 管理镜像

当我执行泛化形式时

localhost:8889/actuator/metrics/http.server.requests我得到的MAX 为 3.00..

我还看到了生产就绪功能,但找不到任何有关 MAX 是如何计算或它代表什么的描述

注:随着请求数量的增加,COUNT、TOTAL_TIME 也会增加,但 MAX 有时会减少(具体参见请求 1、请求 2)

请求1:http.server.requests

 {
        "name": "http.server.requests",
        "description": null,
        "baseUnit": "seconds",
        "measurements": [
            {
                "statistic": "COUNT",
                "value": 597
            },
            {
                "statistic": "TOTAL_TIME",
                "value": 144.9057076
            },
            {
                "statistic": "MAX",
                "value": 3.0002913
            }
        ],
        "availableTags": [
            {
                "tag": "exception",
                "values": [
                    "None"
                ]
            },
            {
                "tag": "method",
                "values": …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot spring-boot-actuator spring-boot-admin

8
推荐指数
2
解决办法
6486
查看次数

Spring Boot 自定义运行状况指示器未显示

我相信遵循了互联网上几乎所有的教程并阅读了很多 SO 答案,但我仍然陷入困境。

1.简单的健康检查

@Component
public class HealthCheck implements HealthIndicator {

    @Override
    public Health health() {
        return Health.up().build();
    }

}
Run Code Online (Sandbox Code Playgroud)

2. Application.yaml 配置为显示所有详细信息:

management.endpoints.web.exposure.include: "*"
management.endpoint.health.show-details: ALWAYS
Run Code Online (Sandbox Code Playgroud)

3. Spring-boot-actuator 作为依赖项包含在内:

    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-web'
Run Code Online (Sandbox Code Playgroud)

4.最近发布的Spring Boot:

id 'org.springframework.boot' version '2.2.0.RELEASE'
Run Code Online (Sandbox Code Playgroud)

5. 主应用程序类注释为@SpringBootApplication(隐含地带有@ComponentScan)。

management.endpoints.web.exposure.include: "*"
management.endpoint.health.show-details: ALWAYS
Run Code Online (Sandbox Code Playgroud)

我的自定义运行状况检查必须测试 Apache Kafka,但为了简洁起见,我跳过了详细信息。尽管如此,调用/actuator/health端点我得到相同的默认结果:

{
    "status": "UP",
    "components": {
        "diskSpace": {
            "status": "UP",
            "details": {
                "total": 250685575168,
                "free": 99168997376,
                "threshold": 10485760
            }
        },
        "ping": {
            "status": "UP"
        }
    } …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot spring-boot-actuator

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

@Counted 在 Spring Boot 中如何工作?

@Counted 如何运作?我在控制器中的方法上添加了 @Counted 注释,并期望看到控制器有多少次点击。但我看不到添加到 URL http://localhost:8080/actuator/prometheus 上的指标。

 @Counted(value = "counted.success.test",description = "testCounter")
Run Code Online (Sandbox Code Playgroud)

health-monitoring spring-boot spring-boot-actuator prometheus spring-micrometer

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

从MaximumUriTagsReachedMeterFilter获得最大数量的URI标记

MaximumUriTagsReachedMeterFilter内部配置RestTemplateMetricsAutoConfiguration类记录警告并停止收集,因为我使用uriVariables严重.

问题是我必须使用uri变量和查询参数构建URI并将其传递给org.springframework.web.client.RestTemplate.exchange.例如:

String url = "http://foo.example/api/resources/{id}";

// omitting uriVariables and queryParams maps

URI uri = UriComponentsBuilder.fromUriString(url)
        .buildAndExpand(uriVariables)
        .toUri();
uri = UriComponentsBuilder
        .fromUri(uri)
        .queryParams(queryParams)
        .build()
        .toUri();

restTemplate.exchange(
   uri,
   HttpMethod.GET,
   requestEntity,
   new ParameterizedTypeReference<Entity>(){}
);
Run Code Online (Sandbox Code Playgroud)

我真的不知道如何restTemplate.exchange()与uri变量和查询参数一起传递给参数化字符串URI.这将使检测代码能够在uri变量扩展之前挂钩,只获取一次度量标准uri标记.

此外,我正在利用RestTemplate指标定制HealthIndicator.我真的需要解决这个问题.

java spring-boot spring-boot-actuator micrometer

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

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
查看次数