metric: add KMS-related metrics (#15258)

This commit adds a minimal set of KMS-related metrics:
```
 # HELP minio_cluster_kms_online Reports whether the KMS is online (1) or offline (0)
 # TYPE minio_cluster_kms_online gauge
 minio_cluster_kms_online{server="127.0.0.1:9000"} 1
 # HELP minio_cluster_kms_request_error Number of KMS requests that failed with a well-defined error
 # TYPE minio_cluster_kms_request_error counter
 minio_cluster_kms_request_error{server="127.0.0.1:9000"} 16790
 # HELP minio_cluster_kms_request_success Number of KMS requests that succeeded
 # TYPE minio_cluster_kms_request_success counter
 minio_cluster_kms_request_success{server="127.0.0.1:9000"} 348031
```

Currently, we report whether the KMS is available and how many requests
succeeded/failed. However, KES exposes much more metrics that can be
exposed if necessary. See: https://pkg.go.dev/github.com/minio/kes#Metric

Signed-off-by: Andreas Auernhammer <hi@aead.dev>
This commit is contained in:
Andreas Auernhammer
2022-07-11 18:17:28 +02:00
committed by GitHub
parent b49fc33cb3
commit f800cee4fa
6 changed files with 130 additions and 6 deletions

View File

@@ -115,6 +115,10 @@ func (c *kesClient) Stat() (Status, error) {
}, nil
}
func (c *kesClient) Metrics(ctx context.Context) (kes.Metric, error) {
return c.client.Metrics(ctx)
}
// CreateKey tries to create a new key at the KMS with the
// given key ID.
//

View File

@@ -23,6 +23,7 @@ import (
"encoding/json"
jsoniter "github.com/json-iterator/go"
"github.com/minio/kes"
)
// KMS is the generic interface that abstracts over
@@ -31,6 +32,9 @@ type KMS interface {
// Stat returns the current KMS status.
Stat() (Status, error)
// Metrics returns a KMS metric snapshot.
Metrics(ctx context.Context) (kes.Metric, error)
// CreateKey creates a new key at the KMS with the given key ID.
CreateKey(keyID string) error

View File

@@ -33,6 +33,7 @@ import (
"golang.org/x/crypto/chacha20"
"golang.org/x/crypto/chacha20poly1305"
"github.com/minio/kes"
"github.com/minio/minio/internal/hash/sha256"
)
@@ -89,6 +90,10 @@ func (kms secretKey) Stat() (Status, error) {
}, nil
}
func (secretKey) Metrics(ctx context.Context) (kes.Metric, error) {
return kes.Metric{}, errors.New("kms: metrics are not supported")
}
func (secretKey) CreateKey(string) error {
return errors.New("kms: creating keys is not supported")
}