Skip to content

Commit

Permalink
Merge pull request #13371 from geetasg/main
Browse files Browse the repository at this point in the history
storage/backend: Add a gauge to indicate if defrag is active
  • Loading branch information
gyuho committed Oct 5, 2021
2 parents 1d73f3c + 205720c commit b571ec5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG-3.6.md
Expand Up @@ -28,3 +28,10 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.6.0).
- Package `mvcc/buckets` was moved to `storage/schema`
- Package `wal` was moved to `storage/wal`
- Package `datadir` was moved to `storage/datadir`


### Metrics, Monitoring

See [List of metrics](https://etcd.io/docs/latest/metrics/) for all metrics per release.

- Add [`etcd_disk_defrag_inflight`](https://github.com/etcd-io/etcd/pull/13371).
2 changes: 2 additions & 0 deletions server/storage/backend/backend.go
Expand Up @@ -432,6 +432,8 @@ func (b *backend) Defrag() error {

func (b *backend) defrag() error {
now := time.Now()
isDefragActive.Set(1)
defer isDefragActive.Set(0)

// TODO: make this non-blocking?
// lock batchTx to ensure nobody is using previous tx, and then
Expand Down
8 changes: 8 additions & 0 deletions server/storage/backend/metrics.go
Expand Up @@ -83,6 +83,13 @@ var (
// highest bucket start of 0.01 sec * 2^16 == 655.36 sec
Buckets: prometheus.ExponentialBuckets(.01, 2, 17),
})

isDefragActive = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "etcd",
Subsystem: "disk",
Name: "defrag_inflight",
Help: "Whether or not defrag is active on the member. 1 means active, 0 means not.",
})
)

func init() {
Expand All @@ -92,4 +99,5 @@ func init() {
prometheus.MustRegister(writeSec)
prometheus.MustRegister(defragSec)
prometheus.MustRegister(snapshotTransferSec)
prometheus.MustRegister(isDefragActive)
}

0 comments on commit b571ec5

Please sign in to comment.