輸出hystrix指標(biāo)到dropwizard metrics

對(duì)于分布式應(yīng)用來說驰怎,不可避免地要與系統(tǒng)周邊的服務(wù)打交道,這個(gè)時(shí)候春霍,需要對(duì)外部的服務(wù)調(diào)用進(jìn)行監(jiān)控,這里我們利用hystrix進(jìn)行監(jiān)控叶眉,并將其整合到dropwizard的metrics址儒,方便統(tǒng)一輸出到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;
    }

指標(biāo)實(shí)例

{
  "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輸出的指標(biāo)比較多衅疙,這個(gè)需要注意一下后端存儲(chǔ)容量莲趣。
hystrix除了輸出latencyTotal相關(guān)分布的響應(yīng)時(shí)間,還輸出了fallback觸發(fā)的相關(guān)數(shù)據(jù)饱溢,以及熔斷的次數(shù)喧伞,帶rolling前綴的為瞬時(shí)值,不帶的一般為累積量绩郎。這里講一下幾個(gè)指標(biāo):

  • countShortCircuited為累積量
  • rollingCountShortCircuited為瞬時(shí)值潘鲫,報(bào)警的時(shí)候,以后者為主肋杖,該值主要是上報(bào)間隔期間方法調(diào)用被熔斷的次數(shù)溉仑。
  • countFallbackSuccess為fallback成功執(zhí)行的次數(shù),累計(jì)量状植。
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末浊竟,一起剝皮案震驚了整個(gè)濱河市怨喘,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌振定,老刑警劉巖必怜,帶你破解...
    沈念sama閱讀 216,496評(píng)論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異后频,居然都是意外死亡梳庆,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,407評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門徘郭,熙熙樓的掌柜王于貴愁眉苦臉地迎上來靠益,“玉大人,你說我怎么就攤上這事残揉。” “怎么了抱环?”我有些...
    開封第一講書人閱讀 162,632評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵镇草,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我竖伯,道長(zhǎng),這世上最難降的妖魔是什么七婴? 我笑而不...
    開封第一講書人閱讀 58,180評(píng)論 1 292
  • 正文 為了忘掉前任打厘,我火速辦了婚禮贺辰,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘莽鸭。我一直安慰自己吃靠,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,198評(píng)論 6 388
  • 文/花漫 我一把揭開白布捺球。 她就那樣靜靜地躺著,像睡著了一般氮兵。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上卜高,一...
    開封第一講書人閱讀 51,165評(píng)論 1 299
  • 那天掺涛,我揣著相機(jī)與錄音疼进,去河邊找鬼。 笑死伞广,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的减拭。 我是一名探鬼主播区丑,決...
    沈念sama閱讀 40,052評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼沧侥,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了正什?” 一聲冷哼從身側(cè)響起号杏,我...
    開封第一講書人閱讀 38,910評(píng)論 0 274
  • 序言:老撾萬榮一對(duì)情侶失蹤盾致,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后罩驻,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體护赊,經(jīng)...
    沈念sama閱讀 45,324評(píng)論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡砾跃,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,542評(píng)論 2 332
  • 正文 我和宋清朗相戀三年抽高,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了翘骂。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,711評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡碳竟,死狀恐怖莹桅,靈堂內(nèi)的尸體忽然破棺而出固棚,到底是詐尸還是另有隱情,我是刑警寧澤此洲,帶...
    沈念sama閱讀 35,424評(píng)論 5 343
  • 正文 年R本政府宣布呜师,位于F島的核電站,受9級(jí)特大地震影響汁汗,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜祈争,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,017評(píng)論 3 326
  • 文/蒙蒙 一角寸、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧沮峡,春花似錦、人聲如沸邢疙。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,668評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽颁虐。三九已至,卻和暖如春瞬痘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背框全。 一陣腳步聲響...
    開封第一講書人閱讀 32,823評(píng)論 1 269
  • 我被黑心中介騙來泰國打工津辩, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人喘沿。 一個(gè)月前我還...
    沈念sama閱讀 47,722評(píng)論 2 368
  • 正文 我出身青樓蚜印,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國和親窄赋。 傳聞我的和親對(duì)象是個(gè)殘疾皇子楼熄,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,611評(píng)論 2 353

推薦閱讀更多精彩內(nèi)容