标签:cat -- add app map 一个 程序 style inf
1.平台搭建
新建一个工程:
cloud-consumer-hystrix-dashboard9001
pom必须引入actuator,所有需要被监控的服务都要引入actuator:
<!-- netflix dashboard --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
yml没什么要配置的就改一下端口:
server: port: 9001
主程序类:
@SpringBootApplication @EnableHystrixDashboard public class DashBoardMain9001 { public static void main(String[] args) { SpringApplication.run(DashBoardMain9001.class, args); } }
监控页面:
http://localhost:9001/hystrix
2.如何监控
在需要被监控的服务里加入以下代码:
不然会出现错误:
@Bean public ServletRegistrationBean getServlet() { HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; }
测试:
多调用几次这个接口:
http://localhost:8001/hystrix.stream
标签:cat -- add app map 一个 程序 style inf
原文地址:https://www.cnblogs.com/dayanjing/p/14817399.html