我将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) 我们希望为/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 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
当我执行泛化形式时
localhost:8889/actuator/metrics/http.server.requests我得到的MAX 为 3.00..
我还看到了生产就绪功能,但找不到任何有关 MAX 是如何计算或它代表什么的描述
注:随着请求数量的增加,COUNT、TOTAL_TIME 也会增加,但 MAX 有时会减少(具体参见请求 1、请求 2)
{
"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
我相信遵循了互联网上几乎所有的教程并阅读了很多 SO 答案,但我仍然陷入困境。
@Component
public class HealthCheck implements HealthIndicator {
@Override
public Health health() {
return Health.up().build();
}
}
Run Code Online (Sandbox Code Playgroud)
management.endpoints.web.exposure.include: "*"
management.endpoint.health.show-details: ALWAYS
Run Code Online (Sandbox Code Playgroud)
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
Run Code Online (Sandbox Code Playgroud)
id 'org.springframework.boot' version '2.2.0.RELEASE'
Run Code Online (Sandbox Code Playgroud)
@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) @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
在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.我真的需要解决这个问题.
和我们这里有类似的情况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.AbstractHealthIndicator.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
您能帮助保护 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
我正在使用 Springboot 2 运行 Kafka Stream 应用程序。
我想让我的 kafka 流指标以普罗米修斯格式提供 host:8080/actuator/prometheus
我没办法拥有这个。我不确定我是否了解 kafka 流指标是如何导出的。能actuator得到这些JMX指标?有没有办法获取这些指标并以 Prometheus 格式公开它们?
PS:也没有与 java jmx_prometheus_agent 一起工作
有人有解决方案或示例吗?
谢谢
我们将 Spring Boot 版本从 2.2.2 升级到 2.3.0,2.2.2kafka_consumer_*中 Prometheus 端点中看到的所有指标在 2.3.0 中都看不到。
例如,缺少以下所有内容:
kafka_consumer_records_consumed_total_records_totalkafka_consumer_records_lag_recordskafka_consumer_fetch_latency_max_secondskafka_consumer_bytes_consumed_total_bytes_total不确定我们是否缺少某种配置或文档中隐藏的东西......
下面是我们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