服务监控
端口修改
server.port=19000
pom依赖:
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix-dashboard -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
启动类中增加#EnableHystrixDashboard注解
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
@EnableHystrixDashboard
public class ApplicationConsumerhystrixDashboard {
private static Logger logger = Logger.getLogger(ApplicationConsumerhystrixDashboard.class);
/**
* Start
*/
public static void main(String[] args) {
SpringApplication.run(ApplicationConsumerhystrixDashboard.class, args);
// logger.info("SpringBoot Start Success");
}
}
检查服务提供者是否增加了监控依赖
<!--actuator监控信息完善-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

验证服务启动ok

启动eureka集群

启动一个服务提供者


服务提供项目启动之后访问不到http://localhost:18084/hystrix.stream,添加以下配置及bean
#application.properties中
management.endpoints.web.exposure.include="*"
#启动类中注入bean
@Bean
public ServletRegistrationBean hystrixMetricsStreamServlet() {
ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
registration.addUrlMappings("/hystrix.stream");
return registration;
}
访问 http://localhost:18084/hystrix.stream 出现好多个ping

将这个地址添加到hystrixDashboard中,如下图:

点击monitor stream会出现如下展示:

访问服务提供者接口,如下图:

再次访问 http://localhost:18084/hystrix.stream 会看到有数据出现,如下图:

我们刷新dashboard的监控页面,会看到如下图:

如何看图
7色
一圈
一线
多次访问服务提供者,会发现折线图上升,绿色的实心圆不断变大

实心圆的两种含义
它通过颜色的变化代表了实力的健康程度,它的健康度从绿色<黄色<橙色<红色递减,红色代表服务基本不可用了。
该实心圆除了颜色的变化之外,它的大小也会根据实例的请求流量发生变化,流量越大,该实心圆就越大。所以通过该实心圆的展示,就可以在大量实例中快速的发现故障和高压力实例。
整图说明

网友评论