文档章节

输出hystrix指标到dropwizard metrics

go4it
 go4it
发布于 2017/04/08 22:02
字数 415
阅读 34
收藏 0

对于分布式应用来说,不可避免地要与系统周边的服务打交道,这个时候,需要对外部的服务调用进行监控,这里我们利用hystrix进行监控,并将其整合到dropwizard的metrics,方便统一输出到statsd。

##引入hystrix-codahale-metrics-publisher

       <dependency>
			<groupId>com.netflix.hystrix</groupId>
			<artifactId>hystrix-codahale-metrics-publisher</artifactId>
			<version>1.5.9</version>
		</dependency>

##配置

    @Bean
    HystrixMetricsPublisher hystrixMetricsPublisher() {
        HystrixCodaHaleMetricsPublisher publisher = new HystrixCodaHaleMetricsPublisher(metricRegistry);
        HystrixPlugins.getInstance().registerMetricsPublisher(publisher);
        return publisher;
    }

##指标实例

{
  "HystrixDemoController.hello.countBadRequests": 0,
  "HystrixDemoController.hello.countFallbackFailure": 0,
  "HystrixDemoController.hello.rollingCountTimeout": 2,
  "HystrixDemoController.hello.rollingCountFailure": 0,
  "HystrixThreadPool.HystrixDemoController.rollingMaxActiveThreads": 1,
  "HystrixDemoController.hello.latencyExecute_percentile_25": 0,
  "HystrixDemoController.hello.currentTime": 1491203675091,
  "HystrixDemoController.hello.rollingCountResponsesFromCache": 0,
  "HystrixThreadPool.HystrixDemoController.completedTaskCount": 26,
  "HystrixDemoController.hello.rollingCountFallbackMissing": 0,
  "HystrixThreadPool.HystrixDemoController.currentTime": 1491203675091,
  "HystrixDemoController.hello.latencyTotal_percentile_25": 0,
  "HystrixDemoController.hello.rollingCountFallbackSuccess": 8191,
  "HystrixThreadPool.HystrixDemoController.totalTaskCount": 26,
  "HystrixDemoController.hello.rollingCountSemaphoreRejected": 0,
  "HystrixDemoController.hello.countCollapsedRequests": 0,
  "HystrixDemoController.hello.latencyExecute_percentile_995": 0,
  "HystrixDemoController.hello.latencyTotal_percentile_50": 0,
  "HystrixDemoController.hello.propertyValue_executionIsolationSemaphoreMaxConcurrentRequests": 10,
  "HystrixDemoController.hello.propertyValue_circuitBreakerErrorThresholdPercentage": 50,
  "HystrixDemoController.hello.latencyTotal_percentile_90": 0,
  "HystrixDemoController.hello.countFallbackEmit": 0,
  "HystrixDemoController.hello.latencyTotal_percentile_995": 0,
  "HystrixDemoController.hello.countTimeout": 2,
  "HystrixThreadPool.HystrixDemoController.propertyValue_queueSizeRejectionThreshold": 5,
  "HystrixDemoController.hello.countSuccess": 6,
  "HystrixDemoController.hello.latencyTotal_percentile_75": 0,
  "HystrixThreadPool.HystrixDemoController.propertyValue_maximumSize": 10,
  "HystrixDemoController.hello.propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests": 10,
  "HystrixDemoController.hello.countEmit": 0,
  "HystrixDemoController.hello.executionSemaphorePermitsInUse": 0,
  "HystrixDemoController.hello.countFallbackSuccess": 8191,
  "HystrixThreadPool.HystrixDemoController.largestPoolSize": 10,
  "HystrixDemoController.hello.propertyValue_circuitBreakerSleepWindowInMilliseconds": 5000,
  "HystrixDemoController.hello.propertyValue_circuitBreakerRequestVolumeThreshold": 20,
  "HystrixDemoController.hello.latencyExecute_percentile_75": 0,
  "HystrixDemoController.hello.latencyExecute_percentile_90": 0,
  "HystrixDemoController.hello.latencyExecute_percentile_50": 0,
  "HystrixDemoController.hello.propertyValue_executionTimeoutInMilliseconds": 100,
  "HystrixDemoController.hello.latencyTotal_percentile_5": 0,
  "HystrixDemoController.hello.rollingCountFallbackFailure": 0,
  "HystrixDemoController.hello.latencyTotal_mean": 0,
  "HystrixDemoController.hello.propertyValue_rollingStatisticalWindowInMilliseconds": 10000,
  "HystrixThreadPool.HystrixDemoController.propertyValue_keepAliveTimeInMinutes": 1,
  "HystrixDemoController.hello.rollingCountFallbackRejection": 198,
  "HystrixDemoController.hello.countThreadPoolRejected": 0,
  "HystrixDemoController.hello.countFallbackMissing": 0,
  "HystrixDemoController.hello.rollingCountBadRequests": 0,
  "HystrixDemoController.hello.countResponsesFromCache": 0,
  "HystrixDemoController.hello.rollingCountSuccess": 6,
  "HystrixThreadPool.HystrixDemoController.queueSize": 0,
  "HystrixThreadPool.HystrixDemoController.threadActiveCount": 0,
  "HystrixDemoController.hello.countShortCircuited": 8387,
  "HystrixDemoController.hello.rollingCountExceptionsThrown": 198,
  "HystrixDemoController.hello.rollingCountFallbackEmit": 0,
  "HystrixDemoController.hello.rollingCountThreadPoolRejected": 0,
  "HystrixDemoController.hello.rollingCountShortCircuited": 8387,
  "HystrixThreadPool.HystrixDemoController.propertyValue_corePoolSize": 10,
  "HystrixDemoController.hello.latencyExecute_mean": 0,
  "HystrixDemoController.hello.countExceptionsThrown": 198,
  "HystrixDemoController.hello.propertyValue_executionIsolationThreadTimeoutInMilliseconds": 100,
  "HystrixThreadPool.HystrixDemoController.propertyValue_actualMaximumSize": 10,
  "HystrixDemoController.hello.latencyExecute_percentile_5": 0,
  "HystrixDemoController.hello.latencyTotal_percentile_99": 0,
  "HystrixDemoController.hello.errorPercentage": 25,
  "HystrixDemoController.hello.countFallbackRejection": 198,
  "HystrixThreadPool.HystrixDemoController.rollingCountThreadsExecuted": 6,
  "HystrixThreadPool.HystrixDemoController.propertyValue_maxQueueSize": -1,
  "HystrixDemoController.hello.latencyExecute_percentile_99": 0,
  "HystrixDemoController.hello.rollingCountEmit": 0,
  "HystrixDemoController.hello.rollingCountCollapsedRequests": 0,
  "HystrixThreadPool.HystrixDemoController.countThreadsExecuted": 7,
  "HystrixDemoController.hello.countFailure": 0,
  "HystrixThreadPool.HystrixDemoController.rollingCountCommandsRejected": 0,
  "HystrixDemoController.hello.countSemaphoreRejected": 0
}

hystrix输出的指标比较多,这个需要注意一下后端存储容量。 hystrix除了输出latencyTotal相关分布的响应时间,还输出了fallback触发的相关数据,以及熔断的次数,带rolling前缀的为瞬时值,不带的一般为累积量。这里讲一下几个指标:

  • countShortCircuited为累积量
  • rollingCountShortCircuited为瞬时值,报警的时候,以后者为主,该值主要是上报间隔期间方法调用被熔断的次数。
  • countFallbackSuccess为fallback成功执行的次数,累计量。

© 著作权归作者所有

共有 人打赏支持
go4it
粉丝 71
博文 797
码字总数 642065
作品 0
深圳
私信 提问
Storing Months of Historical Metrics from Hystrix in Graphite

摘要:RelatedMicroZoneResourcesWhyyouneedtoestablishaDevOpscultureHowtheEvernoteopsteamgetspeaceofmindfromPagerDuty'ssmartalerting&;on-callschedulingMetrics-DrivenDevelopmentNew......

xiaomin0322
04/24
0
0
Vert.x 3.4.0 发布,基于 JVM 的 Node 替代者

Vert.x 3.4.0 发布了。Vert.x 是一个用于下一代异步、可伸缩、并发应用的框架,旨在为JVM提供一个Node.js的替代方案。开发者可以通过它使用JavaScript、Ruby、Groovy、Java、甚至是混合语言来...

达尔文
2017/03/08
2.1K
12
基于dropwizard/metrics ,kafka,zabbix构建应用统计数据收集展示系统

想要实现的功能 应用可以用少量的代码,实现统计某类数据的功能 统计的数据可以很方便地展示 metrics metrics,按字面意思是度量,指标。 举具体的例子来说,一个web服务器: - 一分钟内请求...

xiaomin0322
05/08
0
0
聊聊HystrixMetricsPublisher

序 本文主要研究一下HystrixMetricsPublisher HystrixMetricsPublisher hystrix-core-1.5.12-sources.jar!/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.java getMetrics......

go4it
07/01
0
0
Vert.x 3.3.2 发布,基于 JVM 的 Node 替代者

Vert.x 3.3.2 发布了,更新如下: Vert.x Core HTTP/1.x keepalive connections don't clear the paused buffers at end -https://github.com/eclipse/vert.x/issues/1504 Vert.x Unit Add ......

oschina
2016/07/13
2.2K
9

没有更多内容

加载失败,请刷新页面

加载更多

小白带你认识netty(三)之NioEventLoop的线程(或者reactor线程)启动(一)

在第一章中,我们看关于NioEventLoopGroup的初始化,我们知道了NioEventLoopGroup对象中有一组EventLoop数组,并且数组中的每个EventLoop对象都对应一个线程FastThreadLocalThread,那么这个...

天空小小
今天
3
0
PHP动态扩展Redis模块

查看已有模块 [root@test-a ~]# /usr/local/php/bin/php -m[PHP Modules]bz2Core...zlib[Zend Modules] 下载包,解压,生成configure文件 [root@test-a ~]# cd /usr/local/src/[ro......

野雪球
今天
4
0
在Ignite中使用线性回归算法

在本系列前面的文章中,简单介绍了一下Ignite的机器学习网格,下面会趁热打铁,结合一些示例,深入介绍Ignite支持的一些机器学习算法。 如果要找合适的数据集,会发现可用的有很多,但是对于...

李玉珏
今天
5
0
Mybatis应用学习——简单使用示例

1. 传统JDBC程序中存在的问题 1. 一个简单的JDBC程序示例: public class JDBCDemo {public static void main(String[] args) {Connection con=null;PreparedStatement statemen...

江左煤郎
今天
4
0
使用JavaScript编写iOS应用业务逻辑

JSAUIKitCocoa使你可以使用JavaScript编写对性能要求不高但可能变动性很大的iOS应用的业务逻辑部分,View组件、需要多线程支持的Model等则直接使用原生对象。 编写方式与React Native相似,但...

neal01
今天
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部