github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/cdc/sink/metrics/cloudstorage/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  package cloudstorage
    14  
    15  import "github.com/prometheus/client_golang/prometheus"
    16  
    17  const (
    18  	namespace = "ticdc"
    19  	subsystem = "sink"
    20  )
    21  
    22  // Metrics for cloud storage sink
    23  var (
    24  	// CloudStorageWriteBytesGauge records the total number of bytes written to cloud storage.
    25  	CloudStorageWriteBytesGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
    26  		Namespace: namespace,
    27  		Subsystem: subsystem,
    28  		Name:      "cloud_storage_write_bytes_total",
    29  		Help:      "Total number of bytes written to cloud storage",
    30  	}, []string{"namespace", "changefeed"})
    31  
    32  	// CloudStorageFileCountGauge records the number of files generated by cloud storage sink.
    33  	CloudStorageFileCountGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
    34  		Namespace: namespace,
    35  		Subsystem: subsystem,
    36  		Name:      "cloud_storage_file_count",
    37  		Help:      "Total number of files managed by a cloud storage sink",
    38  	}, []string{"namespace", "changefeed"})
    39  
    40  	// CloudStorageWriteDurationHistogram records the latency distributions of writeLog.
    41  	CloudStorageWriteDurationHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
    42  		Namespace: namespace,
    43  		Subsystem: subsystem,
    44  		Name:      "cloud_storage_write_duration_seconds",
    45  		Help:      "The latency distributions of write storage by a cloud storage sink",
    46  		Buckets:   prometheus.ExponentialBuckets(0.001, 2.0, 13),
    47  	}, []string{"namespace", "changefeed"})
    48  
    49  	// CloudStorageFlushDurationHistogram records the latency distributions of flushLog.
    50  	CloudStorageFlushDurationHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
    51  		Namespace: namespace,
    52  		Subsystem: subsystem,
    53  		Name:      "cloud_storage_flush_duration_seconds",
    54  		Help:      "The latency distributions of flush storage by a cloud storage sink",
    55  		Buckets:   prometheus.ExponentialBuckets(0.001, 2.0, 13),
    56  	}, []string{"namespace", "changefeed"})
    57  
    58  	// CloudStorageWorkerBusyRatio records the busy ratio of CloudStorage bgUpdateLog worker.
    59  	CloudStorageWorkerBusyRatioCounter = prometheus.NewCounterVec(
    60  		prometheus.CounterOpts{
    61  			Namespace: namespace,
    62  			Subsystem: subsystem,
    63  			Name:      "cloud_storage_worker_busy_ratio",
    64  			Help:      "Busy ratio (X ms in 1s) for cloud storage sink dml worker.",
    65  		}, []string{"namespace", "changefeed", "id"})
    66  )
    67  
    68  // InitMetrics registers all metrics in this file.
    69  func InitMetrics(registry *prometheus.Registry) {
    70  	registry.MustRegister(CloudStorageWriteBytesGauge)
    71  	registry.MustRegister(CloudStorageFileCountGauge)
    72  	registry.MustRegister(CloudStorageWriteDurationHistogram)
    73  	registry.MustRegister(CloudStorageFlushDurationHistogram)
    74  	registry.MustRegister(CloudStorageWorkerBusyRatioCounter)
    75  }