springdashboard环境搭建
2024-08-21 16:53:26
SpringCloud Hystrix Dashboard
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。
监控服务pom配置文件
<!--系统注册与监控服务-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!--hystrix仪表盘-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
application.properties
server.port=
spring.application.name=claimdashboard eureka.client.service-url.defaultZone=http://localhost:8091/eureka/
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
@SpringBootApplication
@EnableHystrixDashboard
public class ClaimdashboardApplication {
/*
启动输入http://localhost:8070/hystrix
再输入某个需要监控的服务 http://localhost:8030/hystrix.stream
*/ public static void main(String[] args) {
SpringApplication.run(ClaimdashboardApplication.class, args);
}
}
被监控服务的配置
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
#服务名称
spring.application.name=claimaudit
#配置服务中心注册地址
eureka.client.service-url.defaultZone=http://localhost:8091/eureka/
eureka.client.instance.lease-renewal-interval-in-seconds=
feign.hystrix.enabled=true
@SpringBootApplication
@EnableDiscoveryClient //注册服务
@EnableFeignClients //开启feign
@EnableHystrix //开启断路器
@EnableCircuitBreaker
public class ClaimauditApplication {
public static void main(String[] args) {
SpringApplication.run(ClaimauditApplication.class, args); }
}
主要是下面这段代码,如果不添加监控服务会报连接不上的错误
@Configuration
public class HystrixConfig { @Bean
public HystrixMetricsStreamServlet hystrixMetricsStreamServlet(){
return new HystrixMetricsStreamServlet();
} @Bean
public ServletRegistrationBean registration(HystrixMetricsStreamServlet servlet){
ServletRegistrationBean registrationBean = new ServletRegistrationBean();
registrationBean.setServlet(servlet);
//是否启用该registrationBean
registrationBean.setEnabled(true);
registrationBean.addUrlMappings("/hystrix.stream");
return registrationBean;
}
}
最新文章
- 关于ReSharper
- js常用的封装函数
- PHP不到100行代码实现SSO单点登录
- 微信小程序购物商城系统开发系列
- [转载代码]VB.NET 中查询 Linq to SQL 执行时的SQL语句
- PostgreSQL中,database,schema,table之间关系
- 【转】#ifdef __cplusplus深度剖析
- void类型及void指针
- Java图片上传压缩处理
- server-send event object
- 忘记了SqlServer的SA密码怎么办
- HTML框架集之Frameset与Iframe简单应用
- node基础篇二:模块、路由、全局变量课堂(持续)
- Java中的String类型
- HTML与CSS的一些知识(四)
- 使用nginx搭建rtmp服务器
- pip安装第三方库镜像源选择
- 火币网API文档——REST 行情、交易API简介
- P3605 [USACO17JAN]Promotion Counting晋升者计数
- C++中cin的用法汇总