提交 9b43a901 编写于 作者: M Ming Deng

Change prometheus patter

上级 b7833fb2
......@@ -28,14 +28,15 @@ import (
func PrometheusMiddleWare(next http.Handler) http.Handler {
summaryVec := prometheus.NewSummaryVec(prometheus.SummaryOpts{
Name: beego.BConfig.AppName,
Name: "beego",
Subsystem: "http_request",
ConstLabels: map[string]string{
"server": beego.BConfig.ServerName,
"env": beego.BConfig.RunMode,
"server": beego.BConfig.ServerName,
"env": beego.BConfig.RunMode,
"appname": beego.BConfig.AppName,
},
Help: "The statics info for http request",
}, []string{"pattern", "method", "status"})
}, []string{"pattern", "method", "status", "duration"})
prometheus.MustRegister(summaryVec)
......@@ -68,5 +69,6 @@ func report(dur time.Duration, writer http.ResponseWriter, q *http.Request, vec
} else {
logs.Warn("we can not find the router info for this request, so request will be recorded as UNKNOWN: " + q.URL.String())
}
vec.WithLabelValues(ptn, q.Method, strconv.Itoa(status)).Observe(float64(dur / time.Millisecond))
ms := dur / time.Millisecond
vec.WithLabelValues(ptn, q.Method, strconv.Itoa(status), strconv.Itoa(int(ms))).Observe(float64(ms))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册