今天,发现hystrix监控的hystrix-dashboard里没有数据,这个hystrix-dashboard监控的是turbine聚合过的turbine.stream。

一开始怀疑是turbine使用的上游hystrix.stream没有数据,我手动获取hystrix.stream:

curl http://demo.com/hystrix.stream

发现是有数据的。
然后我看日志也没有发现什么异常。就把com.netflix的日志级别调整成debug看下:

java -jar -Dlogging.level.com.netflix=DEBUG hystrix-dashboard.jar

发现是获取到了上游的hystrix的host,全部状态为up,没有问题。

但是日志一直有这个提示:

Skipping event to catch up to end of feed and reduce latency

跳过了事件,以此来追上stream和减少延迟。

为啥要跳过事件,看下代码

com.netflix.turbine.monitor.instance
currentTime = System.currentTimeMillis();
if (skipLineLogic.get() && currentTime < skipProcessingUntil) {
    if (logger.isDebugEnabled()) {
        logger.debug("Skipping event to catch up to end of feed and reduce latency");
    }
} else {
    line = line.trim();
    if (line.length() != 0) {
        break;
    }
}

原来处理从上游获取的stream时,会比较stream里的时间戳和本地时间戳,发现延迟超过指定延迟时间就抛弃该事件。

延迟时间可配置:

turbine.InstanceMonitor.eventStream.skipLineLogic.latencyThreshold

默认为2500毫秒。

于是,我看了下这台服务器的时间:

date

发现比上游hystrix.stream的服务器快了10秒,于是就找运维同时更新了ntp,果然就没有问题了。

标签: Java, turbine, hystrix

添加新评论