一、受监控的项目添加依赖,之前遇到的问题:访问流的连接一直获取不到数据,结果是版本问题。
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
<version>1.5.12</version>
</dependency>
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-metrics-event-stream</artifactId>
<version>1.5.12</version>
</dependency>
二、监控面板配置:
1、启动hystrix-dashboard监控面板
java -jar -DserverPort=7979 -DbindAddress=localhost standalone-hystrix-dashboard-1.5.3-all.jar
注意:其中的serverPort、bindAddress是可选参数,若不添加,默认是7979和localhost
2、浏览器输入http://localhost:7979/hystrix-dashboard/,出现小熊页面就是正确了。
三、turbine集合监控流
turbine下载:https://github.com/downloads/Netflix/Turbine/turbine-web-1.0.0.war(或者搜turbine-web-1.0.0.war)
1、配置tomcat(192.33.33.33)的webapps下的turbine/WEB-INF/classes/config.properties
InstanceDiscovery.impl=com.netflix.turbine.discovery.ConfigPropertyBasedDiscovery
#cluster
turbine.aggregator.clusterConfig=default
#turbine.aggregator.clusterConfig=myboot
turbine.instanceUrlSuffix=:8001/hystrix.stream //受监控项目hystrix流地址后缀
turbine.ConfigPropertyBasedDiscovery.default.instances=192.11.11.11,192.22.22.22 //受监控项目ip地址
说明:turbine.aggregator.clusterConfig=default与turbine.ConfigPropertyBasedDiscovery.default.instances中的default对应。
2、启动turbine
- 如果需要tomcat的关闭过程可能不会关闭干净,使用ps -ef | grep tomcat,之后进行kill就好。
3、分别启动两台机器上的hystrix项目192.11.11.11,192.22.22.22
4、浏览器输入
- 在上面启动的监控面板"localhost:7979/hystrix-dashboard"中添加"192.33.33.33:8080/turbine/turbine.stream"进行监控