在原有的基礎(chǔ)上增加Counter計數(shù)器:
namespace AppHttpMiddleware; use Closure; use IlluminateHttpRequest; use traumferienwohnungenPrometheusExporterMiddlewareAbstractResponseTimeMiddleware; class PrometheusMonitor extends AbstractResponseTimeMiddleware { protected function getRouteNames() { $routeNames = []; foreach (Route::getRoutes() as $route){ $routeNames[] = "/".ltrim($route->uri(), "/"); } return $routeNames; } /** * Handle an incoming request. * * @param IlluminateHttpRequest $request * @param Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { if (defined("LARAVEL_START")){ $start = LARAVEL_START; } elseif (defined("LUMEN_START")){ $start = LUMEN_START; } else { $start = microtime(true); } $this->request = $request; /** @var IlluminateHttpResponse $response */ $response = $next($request); $route_name = $this->getRouteName(); $method = $request->getMethod(); $status = $response->getStatusCode(); $duration = microtime(true) - $start; $duration_milliseconds = $duration * 1000.0; $this->countRequest($route_name, $method, $status, $duration_milliseconds); $this->initRequestMetrics($method, $status); return $response; } public function getRouteName(){ return request()->getRequestUri(); } public function initRequestMetrics($method, $status) { $namespace = config("prometheus_exporter.namespace_http_server"); $labelNames = $this->getRequestCounterLabelNames(); $name = "request_wuc"; $help = "http_requests count"; $counter = $this->registry->getOrRegisterCounter( $namespace, $name, $help, $labelNames ); $counter->incBy(1, [$this->getRouteName(), $method, $status]); } }
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://www.ezyhdfw.cn/yun/30923.html
摘要:根據(jù)配置文件,對接收到的警報進行處理,發(fā)出告警。在默認(rèn)情況下,用戶只需要部署多套,采集相同的即可實現(xiàn)基本的。通過將監(jiān)控與數(shù)據(jù)分離,能夠更好地進行彈性擴展。參考文檔本文為容器監(jiān)控實踐系列文章,完整內(nèi)容見 系統(tǒng)架構(gòu)圖 1.x版本的Prometheus的架構(gòu)圖為:showImg(https://segmentfault.com/img/remote/1460000018372350?w=14...
摘要:根據(jù)配置文件,對接收到的警報進行處理,發(fā)出告警。在默認(rèn)情況下,用戶只需要部署多套,采集相同的即可實現(xiàn)基本的。通過將監(jiān)控與數(shù)據(jù)分離,能夠更好地進行彈性擴展。參考文檔本文為容器監(jiān)控實踐系列文章,完整內(nèi)容見 系統(tǒng)架構(gòu)圖 1.x版本的Prometheus的架構(gòu)圖為:showImg(https://segmentfault.com/img/remote/1460000018372350?w=14...
摘要:微信支付的接入,如果不使用成熟的開發(fā)包,將是巨大的工作量。回調(diào)處理請見下文教程分鐘實現(xiàn)小程序微信支付接入下回調(diào)發(fā)貨邏輯已知異常如果你不添加,可能會報容器找不到這個應(yīng)用的報錯。 微信支付的接入,如果不使用成熟的開發(fā)包,將是巨大的工作量。 依賴 EasyWechat 先在 laravel 項目中依賴 easywechat 這個包 composer require overtrue/lara...
摘要:一背景和現(xiàn)狀在美團,基于構(gòu)建的傳統(tǒng)關(guān)系型數(shù)據(jù)庫服務(wù)已經(jīng)難于支撐公司業(yè)務(wù)的爆發(fā)式增長,促使我們?nèi)ヌ剿鞲侠淼臄?shù)據(jù)存儲方案和實踐新的運維方式。隨著近一兩年來分布式數(shù)據(jù)庫大放異彩,美團團隊聯(lián)合架構(gòu)存儲團隊,于年初啟動了分布式數(shù)據(jù)庫項目。 一、背景和現(xiàn)狀 在美團,基于 MySQL 構(gòu)建的傳統(tǒng)關(guān)系型數(shù)據(jù)庫服務(wù)已經(jīng)難于支撐公司業(yè)務(wù)的爆發(fā)式增長,促使我們?nèi)ヌ剿鞲侠淼臄?shù)據(jù)存儲方案和實踐新的運維方式。...
閱讀 3480·2021-11-22 13:53
閱讀 3527·2021-10-11 11:11
閱讀 1002·2019-08-30 14:12
閱讀 1308·2019-08-29 17:16
閱讀 745·2019-08-29 16:45
閱讀 3454·2019-08-29 12:56
閱讀 741·2019-08-28 17:55
閱讀 2154·2019-08-26 13:24