You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

7 years ago
package stats
import (
"github.com/prometheus/client_golang/prometheus"
)
//ApiID指标项: 请求数、http code分布、错误统计、耗时统计、QPS
//Label指标项继承ApiID请求数top n,错误数top n耗时top n, qps top n
//Service指标项: 继承Label
var (
Req = prometheus.NewSummaryVec(prometheus.SummaryOpts{
7 years ago
Name: "juz_req_stats",
7 years ago
Help: "Request stats",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
7 years ago
}, []string{"api_id", "service", "app"})
7 years ago
Limits = prometheus.NewCounterVec(prometheus.CounterOpts{
7 years ago
Name: "juz_req_limits",
7 years ago
Help: "Request blocked",
7 years ago
}, []string{"api_id", "service", "app"})
7 years ago
Errors = prometheus.NewCounterVec(prometheus.CounterOpts{
7 years ago
Name: "juz_req_errors",
7 years ago
Help: "Request error",
7 years ago
}, []string{"api_id", "service", "app"})
7 years ago
Codes = prometheus.NewCounterVec(
prometheus.CounterOpts{
7 years ago
Name: "juz_req_codes",
7 years ago
Help: "Reqeust http code",
},
7 years ago
[]string{"code", "api_id", "service", "app"},
7 years ago
)
)
func init() {
// Metrics have to be registered to be exposed:
prometheus.MustRegister(Req)
prometheus.MustRegister(Limits)
prometheus.MustRegister(Errors)
prometheus.MustRegister(Codes)
}