...

Source file src/edge-infra.dev/pkg/edge/datasync/controllers/couchctl/metrics.go

Documentation: edge-infra.dev/pkg/edge/datasync/controllers/couchctl

     1  package couchctl
     2  
     3  import (
     4  	"github.com/prometheus/client_golang/prometheus"
     5  	"github.com/prometheus/client_golang/prometheus/promauto"
     6  
     7  	"edge-infra.dev/pkg/k8s/runtime/controller/metrics"
     8  )
     9  
    10  var (
    11  	DatabaseReplicationStatus = promauto.NewCounterVec(prometheus.CounterOpts{
    12  		Name: metrics.Name("couchctl", "database_replication_status"),
    13  		Help: "information about database replication status",
    14  	}, []string{"server_name", "db_name", "status", "message"})
    15  	DatabaseDocumentCount = promauto.NewGaugeVec(prometheus.GaugeOpts{
    16  		Name: metrics.Name("couchctl", "database_doc_count"),
    17  		Help: "number of documents in a couchdb database",
    18  	}, []string{"server_name", "db_name"})
    19  	DatabaseDiffDocumentCount = promauto.NewGaugeVec(prometheus.GaugeOpts{
    20  		Name: metrics.Name("couchctl", "database_diff_count"),
    21  		Help: "difference in documents from the cloud couchdb database",
    22  	}, []string{"server_name", "db_name"})
    23  )
    24  
    25  func DatabaseDocumentCountSet(servername, dbname string, count float64) {
    26  	var l = prometheus.Labels{
    27  		"server_name": servername,
    28  		"db_name":     dbname,
    29  	}
    30  	DatabaseDocumentCount.With(l).Set(count)
    31  }
    32  
    33  func DatabaseDocumentDiffInc(servername, dbname string, count float64) {
    34  	var l = prometheus.Labels{
    35  		"server_name": servername,
    36  		"db_name":     dbname,
    37  	}
    38  	DatabaseDiffDocumentCount.With(l).Set(count)
    39  }
    40  
    41  func ReplicationStatusInc(servername, dbname, status, message string) {
    42  	var l = prometheus.Labels{
    43  		"server_name": servername,
    44  		"db_name":     dbname,
    45  		"status":      status,
    46  		"message":     message,
    47  	}
    48  	DatabaseReplicationStatus.With(l).Inc()
    49  }
    50  

View as plain text