github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/cdc/redo/common/metric.go (about) 1 // Copyright 2021 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package common 15 16 import ( 17 "github.com/prometheus/client_golang/prometheus" 18 ) 19 20 const ( 21 namespace = "ticdc" 22 subsystem = "redo" 23 ) 24 25 var ( 26 // RedoWriteBytesGauge records the total number of bytes written to redo log. 27 RedoWriteBytesGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{ 28 Namespace: namespace, 29 Subsystem: subsystem, 30 Name: "write_bytes_total", 31 Help: "Total number of bytes redo log written", 32 }, []string{"namespace", "changefeed"}) 33 34 // RedoFsyncDurationHistogram records the latency distributions of fsync called by redo writer. 35 RedoFsyncDurationHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{ 36 Namespace: namespace, 37 Subsystem: subsystem, 38 Name: "fsync_duration_seconds", 39 Help: "The latency distributions of fsync called by redo writer", 40 Buckets: prometheus.ExponentialBuckets(0.001, 2.0, 13), 41 }, []string{"namespace", "changefeed"}) 42 43 // RedoFlushAllDurationHistogram records the latency distributions of flushAll 44 // called by redo writer. 45 RedoFlushAllDurationHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{ 46 Namespace: namespace, 47 Subsystem: subsystem, 48 Name: "flushall_duration_seconds", 49 Help: "The latency distributions of flushall called by redo writer", 50 Buckets: prometheus.ExponentialBuckets(0.001, 2.0, 13), 51 }, []string{"namespace", "changefeed"}) 52 53 // RedoTotalRowsCountGauge records the total number of rows written to redo log. 54 RedoTotalRowsCountGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{ 55 Namespace: namespace, 56 Subsystem: subsystem, 57 Name: "total_rows_count", 58 Help: "The total count of rows that are processed by redo writer", 59 }, []string{"namespace", "changefeed"}) 60 61 // RedoWriteLogDurationHistogram records the latency distributions of writeLog. 62 RedoWriteLogDurationHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{ 63 Namespace: namespace, 64 Subsystem: subsystem, 65 Name: "write_log_duration_seconds", 66 Help: "The latency distributions of writeLog called by redoManager", 67 Buckets: prometheus.ExponentialBuckets(0.001, 2.0, 13), 68 }, []string{"namespace", "changefeed"}) 69 70 // RedoFlushLogDurationHistogram records the latency distributions of flushLog. 71 RedoFlushLogDurationHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{ 72 Namespace: namespace, 73 Subsystem: subsystem, 74 Name: "flush_log_duration_seconds", 75 Help: "The latency distributions of flushLog called by redoManager", 76 Buckets: prometheus.ExponentialBuckets(0.001, 2.0, 13), 77 }, []string{"namespace", "changefeed"}) 78 79 // RedoWorkerBusyRatio records the busy ratio of redo bgUpdateLog worker. 80 RedoWorkerBusyRatio = prometheus.NewCounterVec( 81 prometheus.CounterOpts{ 82 Namespace: namespace, 83 Subsystem: subsystem, 84 Name: "worker_busy_ratio", 85 Help: "Busy ratio (X ms in 1s) for redo bgUpdateLog worker.", 86 }, []string{"namespace", "changefeed"}) 87 ) 88 89 // InitMetrics registers all metrics in this file 90 func InitMetrics(registry *prometheus.Registry) { 91 registry.MustRegister(RedoFsyncDurationHistogram) 92 registry.MustRegister(RedoTotalRowsCountGauge) 93 registry.MustRegister(RedoWriteBytesGauge) 94 registry.MustRegister(RedoFlushAllDurationHistogram) 95 registry.MustRegister(RedoWriteLogDurationHistogram) 96 registry.MustRegister(RedoFlushLogDurationHistogram) 97 registry.MustRegister(RedoWorkerBusyRatio) 98 }