github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/cdc/metrics_owner.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 cdc 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 ) 48 49 const ( 50 // total tables that have been dispatched to a single processor 51 maintainTableTypeTotal string = "total" 52 // tables that are dispatched to a processor and have not been finished yet 53 maintainTableTypeWip string = "wip" 54 ) 55 56 // initOwnerMetrics registers all metrics used in owner 57 func initOwnerMetrics(registry *prometheus.Registry) { 58 registry.MustRegister(changefeedCheckpointTsGauge) 59 registry.MustRegister(changefeedCheckpointTsLagGauge) 60 registry.MustRegister(ownershipCounter) 61 registry.MustRegister(ownerMaintainTableNumGauge) 62 }