Add a simple sealed gauge, updated when seal status changes (#9177)
* Add a simple unsealed gauge, updated when seal status changes
This commit is contained in:
parent
e608503139
commit
0b9a40a64e
|
@ -784,6 +784,8 @@ func NewCore(conf *CoreConfig) (*Core, error) {
|
|||
c.rawConfig.Store(conf.RawConfig)
|
||||
|
||||
atomic.StoreUint32(c.sealed, 1)
|
||||
c.metricSink.SetGaugeWithLabels([]string{"core", "unsealed"}, 0, nil)
|
||||
|
||||
c.allLoggers = append(c.allLoggers, c.logger)
|
||||
|
||||
c.router.logger = c.logger.Named("router")
|
||||
|
@ -1503,6 +1505,7 @@ func (c *Core) unsealInternal(ctx context.Context, masterKey []byte) (bool, erro
|
|||
|
||||
// Success!
|
||||
atomic.StoreUint32(c.sealed, 0)
|
||||
c.metricSink.SetGaugeWithLabels([]string{"core", "unsealed"}, 1, nil)
|
||||
|
||||
if c.logger.IsInfo() {
|
||||
c.logger.Info("vault is unsealed")
|
||||
|
@ -1716,6 +1719,7 @@ func (c *Core) sealInternalWithOptions(grabStateLock, keepHALock, shutdownRaft b
|
|||
if swapped := atomic.CompareAndSwapUint32(c.sealed, 0, 1); !swapped {
|
||||
return nil
|
||||
}
|
||||
c.metricSink.SetGaugeWithLabels([]string{"core", "unsealed"}, 0, nil)
|
||||
|
||||
c.logger.Info("marked as sealed")
|
||||
|
||||
|
@ -2096,6 +2100,13 @@ func (c *Core) emitMetrics(stopCh chan struct{}) {
|
|||
if c.expiration != nil {
|
||||
c.expiration.emitMetrics()
|
||||
}
|
||||
//Refresh the sealed gauge
|
||||
if c.Sealed() {
|
||||
c.metricSink.SetGaugeWithLabels([]string{"core", "unsealed"}, 0, nil)
|
||||
} else {
|
||||
c.metricSink.SetGaugeWithLabels([]string{"core", "unsealed"}, 1, nil)
|
||||
}
|
||||
|
||||
c.metricsMutex.Unlock()
|
||||
|
||||
case <-writeTimer:
|
||||
|
|
Loading…
Reference in New Issue