Prometheus報(bào)錯(cuò)Error refreshing service Unexpected response code: 503解決辦法

2019年11月20日20:02:19 1 10,231 ℃

今天終于把這個(gè)擱置了幾個(gè)月沒(méi)有解決的問(wèn)題解決了,真的是找遍了Google、百度文檔,沒(méi)有找到一個(gè)解決方案,這里分享一下解決辦法。

公司項(xiàng)目使用的是spring cloud,注冊(cè)中心使用的Eureka,監(jiān)控方面經(jīng)過(guò)一番的調(diào)研,最終選擇了對(duì)微服務(wù)監(jiān)控比較方便的prometheus,由于服務(wù)較多,就考慮了服務(wù)自發(fā)現(xiàn),經(jīng)過(guò)一番的摸索,發(fā)現(xiàn)eureka-consul-adapter依賴可以適配prometheus的consul_sd_config配置。

prometheus整個(gè)部署過(guò)程雖然遇到的問(wèn)題不少,但是網(wǎng)上文檔也比較多,都一一解決了。監(jiān)控起初,并沒(méi)有什么異常,grafana各類(lèi)監(jiān)控顯示也正常,突然有一天發(fā)現(xiàn)服務(wù)器根目錄快滿了,于是去排查了下,發(fā)現(xiàn)是docker的問(wèn)題(prometheus用的docker部署的),再進(jìn)一步排查,發(fā)現(xiàn)是prometheus這個(gè)容器日志占用了大量的磁盤(pán)容量,docker tail -f 看了下,發(fā)現(xiàn)全是類(lèi)似下面的報(bào)錯(cuò):

prometheus      | level=error ts=2019-11-20T09:54:18.313Z caller=consul.go:477 component="discovery manager scrape" discovery=consul msg="Error refreshing service" service=serviceA tags="unsupported value type" err="Unexpected response code: 503 ({\"timestamp\":1574243658309,\"status\":503,\"error\":\"Service Unavailable\",\"exception\":\"org.springframework.web.context.request.async.AsyncRequestTimeoutException\",\"message\":\"No message available\",\"path\":\"/v1/catalog/service/serviceA \"})"

prometheus      | level=error ts=2019-11-20T09:54:25.314Z caller=consul.go:477 component="discovery manager scrape" discovery=consul msg="Error refreshing service" service=serviceB tags="unsupported value type" err="Unexpected response code: 503 ({\"timestamp\":1574243665310,\"status\":503,\"error\":\"Service Unavailable\",\"exception\":\"org.springframework.web.context.request.async.AsyncRequestTimeoutException\",\"message\":\"No message available\",\"path\":\"/v1/catalog/service/serviceB\"})"

prometheus      | level=error ts=2019-11-20T09:54:25.314Z caller=consul.go:477 component="discovery manager scrape" discovery=consul msg="Error refreshing service" service=serviceC tags="unsupported value type" err="Unexpected response code: 503 ({\"timestamp\":1574243665310,\"status\":503,\"error\":\"Service Unavailable\",\"exception\":\"org.springframework.web.context.request.async.AsyncRequestTimeoutException\",\"message\":\"No message available\",\"path\":\"/v1/catalog/service/serviceC\"})"

然后馬上根據(jù)報(bào)錯(cuò)信息訪問(wèn)了下/v1/catalog/service/serviceC地址,可以正常訪問(wèn)。

Prometheus報(bào)錯(cuò)Error refreshing service Unexpected response code: 503解決辦法

然后又去Google了下相關(guān)報(bào)錯(cuò),盡然只有幾篇相關(guān)的文章,還有是重復(fù)了,一下就不知所措了,然后去prometheus 技術(shù)群請(qǐng)教了一些大神,不過(guò)很遺憾,都沒(méi)有人遇到過(guò)類(lèi)似的問(wèn)題,然后去github看了下prometheus consul.go的源代碼,也就是正常訪問(wèn)consul接口返回的報(bào)錯(cuò),雖然使用的是eureka-consul-adapter依賴去適配的,但是consul接口訪問(wèn)都是正常的,前前后后研究了一周,實(shí)在沒(méi)有找到解決方案。

于是只能從其他方面去解決,首先把docker目錄遷移到了數(shù)據(jù)盤(pán),然后給docker日志做了大小限制,雖然一直報(bào)錯(cuò),但是現(xiàn)在不會(huì)對(duì)磁盤(pán)空間造成影響,然后就把這個(gè)問(wèn)題方下了。

過(guò)了兩個(gè)月左右,也就是最近在部署elasticsearch的時(shí)候,無(wú)意間又發(fā)現(xiàn)了prometheus容器一直報(bào)錯(cuò),以為出什么問(wèn)題了(把之前沒(méi)處理的事情搞忘記了),然后又去排查原因,找了半天還是和之前一樣沒(méi)有結(jié)果,這時(shí)突然想起之前prometheus技術(shù)群里,有人說(shuō)這個(gè)報(bào)錯(cuò),應(yīng)該是java端拋出來(lái)的,于是仔細(xì)一看日志內(nèi)容果然有個(gè)java的報(bào)錯(cuò):

org.springframework.web.context.request.async.AsyncRequestTimeoutException

大概意思就是,異步請(qǐng)求超時(shí),然后馬上去項(xiàng)目里面找了下看有沒(méi)有async的相關(guān)設(shè)置,很遺憾項(xiàng)目并沒(méi)有使用async。

又分析了下,由于prometheus是去請(qǐng)求的consul接口,應(yīng)該是eureka server 的問(wèn)題,此時(shí)慢慢思路才清醒起來(lái),再一分析,eureka主要就引用了eureka-consul-adapter依賴,只有看一下eureka-consul-adapter.jar的代碼內(nèi)容就知道的,馬上通過(guò)反編譯工具把下載到本地eureka-consul-adapter.jar包打開(kāi)一看,果然有相關(guān)的引用。

Prometheus報(bào)錯(cuò)Error refreshing service Unexpected response code: 503解決辦法

于是馬上搜索了下springboot 關(guān)于async的超時(shí)時(shí)間的設(shè)置,根據(jù)建議在eureka server的配置文件添加了spring.mvc.async.request-timeout=-1,馬上發(fā)布測(cè)試,果然就沒(méi)有了報(bào)錯(cuò)。

現(xiàn)在再回頭去看,其實(shí)一開(kāi)始問(wèn)題方向就錯(cuò)了,一直在prometheus方面找問(wèn)題,其實(shí)問(wèn)題根本就在eureka server,現(xiàn)在再去看grafana eureka的監(jiān)控視圖,http請(qǐng)求,一直持續(xù)的有http-5xx錯(cuò)誤,而url正是prometheus錯(cuò)誤日志的path,而這些異常一開(kāi)始并沒(méi)有引起我的注意。

Prometheus報(bào)錯(cuò)Error refreshing service Unexpected response code: 503解決辦法

Prometheus報(bào)錯(cuò)Error refreshing service Unexpected response code: 503解決辦法

雖然已經(jīng)沒(méi)有超時(shí)報(bào)錯(cuò),但還是需要觀察幾天,這個(gè)設(shè)置是否對(duì)性能和服務(wù)是否有影響。

轉(zhuǎn)載請(qǐng)注明:Prometheus報(bào)錯(cuò)Error refreshing service Unexpected response code: 503解決辦法 - 阿湯博客 http://www.zhongjima.net/atang_4306.html

【騰訊云】云服務(wù)器、云數(shù)據(jù)庫(kù)、COS、CDN、短信等云產(chǎn)品特惠熱賣(mài)中

發(fā)表評(píng)論

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前評(píng)論:1   其中:訪客  0   博主  0

    • avatar 婚書(shū)網(wǎng) 0

      已加入收藏夾,時(shí)不時(shí)的來(lái)看看有沒(méi)有更新博文!