add label (#314)

Signed-off-by: yisaer <disxiaofei@163.com>
This commit is contained in:
Song Gao 2021-09-26 18:06:28 +08:00 committed by GitHub
parent f65172694b
commit 3cc2459779
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -358,7 +358,8 @@ func (c *RPCClient) updateTiKVSendReqHistogram(req *tikvrpc.Request, start time.
if !ok {
reqType := req.Type.String()
storeID := strconv.FormatUint(req.Context.GetPeer().GetStoreId(), 10)
v = metrics.TiKVSendReqHistogram.WithLabelValues(reqType, storeID)
staleRead := strconv.FormatBool(req.StaleRead)
v = metrics.TiKVSendReqHistogram.WithLabelValues(reqType, storeID, staleRead)
sendReqHistCache.Store(key, v)
}

View File

@ -44,7 +44,7 @@ var (
TiKVTxnCmdHistogram *prometheus.HistogramVec
TiKVBackoffHistogram *prometheus.HistogramVec
TiKVSendReqHistogram *prometheus.HistogramVec
TiKVCoprocessorHistogram prometheus.Histogram
TiKVCoprocessorHistogram *prometheus.HistogramVec
TiKVLockResolverCounter *prometheus.CounterVec
TiKVRegionErrorCounter *prometheus.CounterVec
TiKVTxnWriteKVCountHistogram prometheus.Histogram
@ -108,6 +108,7 @@ const (
LblAddress = "address"
LblFromStore = "from_store"
LblToStore = "to_store"
LblStaleRead = "stale_read"
)
func initMetrics(namespace, subsystem string) {
@ -136,16 +137,16 @@ func initMetrics(namespace, subsystem string) {
Name: "request_seconds",
Help: "Bucketed histogram of sending request duration.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 29), // 0.5ms ~ 1.5days
}, []string{LblType, LblStore})
}, []string{LblType, LblStore, LblStaleRead})
TiKVCoprocessorHistogram = prometheus.NewHistogram(
TiKVCoprocessorHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "cop_duration_seconds",
Help: "Run duration of a single coprocessor task, includes backoff time.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 29), // 0.5ms ~ 1.5days
})
}, []string{LblStore, LblStaleRead})
TiKVLockResolverCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{