Browse Source

etcdserver: add "etcd_server_quota_backend_bytes"

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
72c51d3e12
2 changed files with 13 additions and 3 deletions
  1. 7 0
      etcdserver/metrics.go
  2. 6 3
      etcdserver/quota.go

+ 7 - 0
etcdserver/metrics.go

@@ -77,6 +77,12 @@ var (
 		Name:      "slow_read_indexes_total",
 		Name:      "slow_read_indexes_total",
 		Help:      "The total number of pending read indexes not in sync with leader's or timed out read index requests.",
 		Help:      "The total number of pending read indexes not in sync with leader's or timed out read index requests.",
 	})
 	})
+	quotaBackendBytes = prometheus.NewGauge(prometheus.GaugeOpts{
+		Namespace: "etcd",
+		Subsystem: "server",
+		Name:      "quota_backend_bytes",
+		Help:      "Current backend storage quota size in bytes.",
+	})
 	currentVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
 	currentVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
 		Namespace: "etcd",
 		Namespace: "etcd",
 		Subsystem: "server",
 		Subsystem: "server",
@@ -96,6 +102,7 @@ func init() {
 	prometheus.MustRegister(proposalsFailed)
 	prometheus.MustRegister(proposalsFailed)
 	prometheus.MustRegister(leaseExpired)
 	prometheus.MustRegister(leaseExpired)
 	prometheus.MustRegister(slowReadIndex)
 	prometheus.MustRegister(slowReadIndex)
+	prometheus.MustRegister(quotaBackendBytes)
 	prometheus.MustRegister(currentVersion)
 	prometheus.MustRegister(currentVersion)
 
 
 	currentVersion.With(prometheus.Labels{
 	currentVersion.With(prometheus.Labels{

+ 6 - 3
etcdserver/quota.go

@@ -14,9 +14,7 @@
 
 
 package etcdserver
 package etcdserver
 
 
-import (
-	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
-)
+import pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
 
 
 const (
 const (
 	// DefaultQuotaBytes is the number of bytes the backend Size may
 	// DefaultQuotaBytes is the number of bytes the backend Size may
@@ -58,15 +56,20 @@ const (
 )
 )
 
 
 func NewBackendQuota(s *EtcdServer) Quota {
 func NewBackendQuota(s *EtcdServer) Quota {
+	quotaBackendBytes.Set(float64(s.Cfg.QuotaBackendBytes))
+
 	if s.Cfg.QuotaBackendBytes < 0 {
 	if s.Cfg.QuotaBackendBytes < 0 {
 		// disable quotas if negative
 		// disable quotas if negative
 		plog.Warningf("disabling backend quota")
 		plog.Warningf("disabling backend quota")
 		return &passthroughQuota{}
 		return &passthroughQuota{}
 	}
 	}
+
 	if s.Cfg.QuotaBackendBytes == 0 {
 	if s.Cfg.QuotaBackendBytes == 0 {
 		// use default size if no quota size given
 		// use default size if no quota size given
+		quotaBackendBytes.Set(float64(DefaultQuotaBytes))
 		return &backendQuota{s, DefaultQuotaBytes}
 		return &backendQuota{s, DefaultQuotaBytes}
 	}
 	}
+
 	if s.Cfg.QuotaBackendBytes > MaxQuotaBytes {
 	if s.Cfg.QuotaBackendBytes > MaxQuotaBytes {
 		plog.Warningf("backend quota %v exceeds maximum recommended quota %v", s.Cfg.QuotaBackendBytes, MaxQuotaBytes)
 		plog.Warningf("backend quota %v exceeds maximum recommended quota %v", s.Cfg.QuotaBackendBytes, MaxQuotaBytes)
 	}
 	}