使用https://start.spring.io/ 生成demo。
pom 文件增加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.9.0</version>
</dependency>
server.port=9091
management.endpoints.enabled-by-default=true # 启用所有管理端点,默认情况下所有的管理端点都是开启的。
management.endpoints.web.exposure.include=* # 暴露所有web端点
management.metrics.tags.application=spring-boot-demo # tag
mvn clean package -Dmaven.test.skip=true
java -jar target/sprint-boot-demo-0.0.1-SNAPSHOT.jar
# skywalking
java -javaagent:`pwd`/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=spring-boot-demo -Dskywalking.collector.backend_service=127.0.0.1:11800 -jar target/sprint-boot-demo-0.0.1-SNAPSHOT.jar
# prometheus
http://localhost:9091/actuator/prometheus
# health
http://localhost:9091/actuator/health
# hello
http://localhost:9091/hello
# 引入jar包
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-logback-1.x</artifactId>
<version>8.6.0</version>
</dependency>
# 配置logback.xml 文件
见配置文件
# 启动
java -javaagent:`pwd`/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=spring-boot-demo -Dskywalking.collector.backend_service=127.0.0.1:11800 -jar target/sprint-boot-demo-0.0.1-SNAPSHOT.jar
链路
相关日志