我从1.5.10移动到Spring Boot 2.0.0 RC1,我在最新版本中遇到了执行器.如何启用公开并启用所有执行器端点?
暴露的唯一端点是:
{
"_links": {
"self": {
"href": "http://127.0.0.1:8080/actuator",
"templated": false
},
"health": {
"href": "http://127.0.0.1:8080/actuator/health",
"templated": false
},
"info": {
"href": "http://127.0.0.1:8080/actuator/info",
"templated": false
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的application.properties档案.有任何想法吗?
#The three first ones seem to be obsolete
endpoints.configprops.enabled=true
endpoints.beans.enabled=true
endpoints.shutdown.enabled=true
management.endpoints.enabled-by-default=true
management.endpoints.sensitive=false
management.endpoints.enabled=true
management.endpoint.configprops.enabled=true
management.endpoint.beans.enabled=true
management.endpoint.shutdown.enabled=true
management.endpoints.web.exposure.include=*
Run Code Online (Sandbox Code Playgroud) 在 Spring Boot 2.2.0 中,“httptrace”Actuator 端点不再存在。我怎样才能恢复这个功能?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这将为您的应用程序添加几个有用的端点.其中之一是/健康.当您启动应用程序并导航到/ health端点时,您将看到它已返回一些数据.
{
"status":"UP",
"diskSpace": {
"status":"UP",
"free":56443746,
"threshold":1345660
}
}
Run Code Online (Sandbox Code Playgroud)
如何在spring boot health中添加自定义运行状况检查?
我已经将Spring Boot应用程序从1.4.x更新到1.5.1,Spring Actuator端点现在返回不同的MIME类型:
例如,/health现在application/vnd.spring-boot.actuator.v1+json简单地说application/json.
我怎么能改回来?
我能够访问端点一样http://localhost:8081/health,/status,/env,/metrics,/shutdown 但没有 /actuator或/loginfo端点.
低于例外.
{"timestamp":1455929182552,"status":404,"error":"Not Found","message":"No message available","path":"/actuator"}
Run Code Online (Sandbox Code Playgroud)
如何访问http:// localhost:8081 /执行器端点?
在我设置的Spring Boot App(2.0.0.M7)application.properties中
management.endpoint.metrics.enabled=true
Run Code Online (Sandbox Code Playgroud)
但是,当我击中时
localhost:8080/actuator/metrics
Run Code Online (Sandbox Code Playgroud)
我得到404.
什么是解决方案?
是否有一种简单的方法可以为所有Actuator端点添加前缀?
/env -> /secure/env
/health -> /secure/health
/info -> /secure/info
...
Run Code Online (Sandbox Code Playgroud) 我正在使用 springboot 2.4.0,并添加了以下依赖项以启用 prometheus 指标:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
然后在我的 application.properties 我有以下属性
management.endpoints.web.exposure.include=*
management.metrics.enable.all=true
Run Code Online (Sandbox Code Playgroud)
我正在尝试运行一个简单的集成测试,以查看我的自定义指标出现在 /actuator/prometheus 端点上。代码下方
package com.example.demo;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import static io.restassured.RestAssured.given;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class IntegrationTest {
@LocalServerPort
private int port;
private String baseUrl;
@BeforeEach
public void setup() {
baseUrl = "http://localhost:" + port;
}
@Test
public void metricsEndpoint() throws Exception {
given().when().get(baseUrl + "/demo/actuator/prometheus")
.then()
.statusCode(200);
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里得到的错误是
java.lang.AssertionError: 1 expectation failed.
Expected status …Run Code Online (Sandbox Code Playgroud) java metrics spring-boot-actuator spring-boot-test spring-micrometer
关于 Spring Boot、一些有用的默认指标以及如何在 Grafana 中正确使用它们的小问题。
目前,Spring Boot 2.5.1+(适用于 2.xx 的问题)具有 Actuator + Micrometer + Prometheus 依赖项,有许多开箱即用的非常方便的默认指标。
我看到很多很多都有图案_max _count _sum。
举几个例子:
spring_data_repository_invocations_seconds_max
spring_data_repository_invocations_seconds_count
spring_data_repository_invocations_seconds_sum
reactor_netty_http_client_data_received_bytes_max
reactor_netty_http_client_data_received_bytes_count
reactor_netty_http_client_data_received_bytes_sum
http_server_requests_seconds_max
http_server_requests_seconds_count
http_server_requests_seconds_sum
Run Code Online (Sandbox Code Playgroud)
不幸的是,我不知道如何处理它们,如何正确使用它们,并且感觉我的无知让我错过了一些很棒的应用程序见解。
在网上搜索时,我看到一些使用这样的方法来计算 Grafana 的平均值:
irate(http_server_requests_seconds::sum{exception="None", uri!~".*actuator.*"}[5m]) / irate(http_server_requests_seconds::count{exception="None", uri!~".*actuator.*"}[5m])
Run Code Online (Sandbox Code Playgroud)
但不确定这是否是使用它们的正确方法。
请问在处理 type 的指标时通常会使用什么类型的查询_max _count _sum?
谢谢
Spring Boot Actuator Trace可以很好地捕获输入/输出HTTP参数,标题,用户等.我想扩展它以捕获HTTP响应的主体,这样我就可以全面了解即将发生的事情进出网络层.看着,TraceProperties看起来并不像有一种方法来配置响应体捕获.是否有一种"安全"的方式来捕获响应主体而不会弄乱它发回的任何字符流?