forked from k3s-io/k3s
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
- Loading branch information
Showing
5 changed files
with
113 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package etcd | ||
|
||
import ( | ||
"github.com/k3s-io/k3s/pkg/version" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"k8s.io/component-base/metrics" | ||
) | ||
|
||
var ( | ||
snapshotSaveCount = prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: version.Program + "_etcd_snapshot_save_duration_seconds", | ||
Help: "Total time taken to complete the etcd snapshot process", | ||
Buckets: metrics.ExponentialBuckets(0.008, 2, 15), | ||
}, []string{"status"}) | ||
|
||
snapshotSaveLocalCount = prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: version.Program + "_etcd_snapshot_save_local_duration_seconds", | ||
Help: "Total time taken to save a local snapshot file", | ||
Buckets: metrics.ExponentialBuckets(0.008, 2, 15), | ||
}, []string{"status"}) | ||
|
||
snapshotSaveS3Count = prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: version.Program + "_etcd_snapshot_save_s3_duration_seconds", | ||
Help: "Total time taken to upload a snapshot file to S3", | ||
Buckets: metrics.ExponentialBuckets(0.008, 2, 15), | ||
}, []string{"status"}) | ||
|
||
snapshotReconcileCount = prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: version.Program + "_etcd_snapshot_reconcile_duration_seconds", | ||
Help: "Total time taken to sync the list of etcd snapshots", | ||
Buckets: metrics.ExponentialBuckets(0.008, 2, 15), | ||
}, []string{"status"}) | ||
|
||
snapshotReconcileLocalCount = prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: version.Program + "_etcd_snapshot_reconcile_local_duration_seconds", | ||
Help: "Total time taken to list local snapshot files", | ||
Buckets: metrics.ExponentialBuckets(0.008, 2, 15), | ||
}, []string{"status"}) | ||
|
||
snapshotReconcileS3Count = prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: version.Program + "_etcd_snapshot_reconcile_s3_duration_seconds", | ||
Help: "Total time taken to list S3 snapshot files", | ||
Buckets: metrics.ExponentialBuckets(0.008, 2, 15), | ||
}, []string{"status"}) | ||
) | ||
|
||
// MustRegister registers etcd snapshot metrics | ||
func MustRegister(registerer prometheus.Registerer) { | ||
registerer.MustRegister( | ||
snapshotSaveCount, | ||
snapshotSaveLocalCount, | ||
snapshotSaveS3Count, | ||
snapshotReconcileCount, | ||
snapshotReconcileLocalCount, | ||
snapshotReconcileS3Count, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package metrics | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
func ObserveWithStatus(vec *prometheus.HistogramVec, start time.Time, err error, labels ...string) { | ||
status := "success" | ||
if err != nil { | ||
status = "error" | ||
} | ||
labels = append(labels, status) | ||
vec.WithLabelValues(labels...).Observe(time.Since(start).Seconds()) | ||
} |