github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/cdc/owner/metrics.go (about) 1 // Copyright 2020 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 owner 15 16 import "github.com/prometheus/client_golang/prometheus" 17 18 var ( 19 changefeedCheckpointTsGauge = prometheus.NewGaugeVec( 20 prometheus.GaugeOpts{ 21 Namespace: "ticdc", 22 Subsystem: "owner", 23 Name: "checkpoint_ts", 24 Help: "checkpoint ts of changefeeds", 25 }, []string{"changefeed"}) 26 changefeedCheckpointTsLagGauge = prometheus.NewGaugeVec( 27 prometheus.GaugeOpts{ 28 Namespace: "ticdc", 29 Subsystem: "owner", 30 Name: "checkpoint_ts_lag", 31 Help: "checkpoint ts lag of changefeeds", 32 }, []string{"changefeed"}) 33 ownershipCounter = prometheus.NewCounter( 34 prometheus.CounterOpts{ 35 Namespace: "ticdc", 36 Subsystem: "owner", 37 Name: "ownership_counter", 38 Help: "The counter of ownership increases every 5 seconds on a owner capture", 39 }) 40 ownerMaintainTableNumGauge = prometheus.NewGaugeVec( 41 prometheus.GaugeOpts{ 42 Namespace: "ticdc", 43 Subsystem: "owner", 44 Name: "maintain_table_num", 45 Help: "number of replicated tables maintained in owner", 46 }, []string{"changefeed", "capture", "type"}) 47 changefeedStatusGauge = prometheus.NewGaugeVec( 48 prometheus.GaugeOpts{ 49 Namespace: "ticdc", 50 Subsystem: "owner", 51 Name: "status", 52 Help: "The status of changefeeds", 53 }, []string{"changefeed"}) 54 ) 55 56 const ( 57 // total tables that have been dispatched to a single processor 58 maintainTableTypeTotal string = "total" 59 // tables that are dispatched to a processor and have not been finished yet 60 maintainTableTypeWip string = "wip" 61 ) 62 63 // InitMetrics registers all metrics used in owner 64 func InitMetrics(registry *prometheus.Registry) { 65 registry.MustRegister(changefeedCheckpointTsGauge) 66 registry.MustRegister(changefeedCheckpointTsLagGauge) 67 registry.MustRegister(ownershipCounter) 68 registry.MustRegister(ownerMaintainTableNumGauge) 69 registry.MustRegister(changefeedStatusGauge) 70 }