Persist time series viewer metrics (#1752)

* WIP persisting time series viewer metrics. Closes #1478

* Remove unused var, move around initial collection
This commit is contained in:
Gabe Kangas
2022-03-06 19:43:57 -08:00
committed by GitHub
parent 1f05783d9a
commit 1ed1cc01eb
6 changed files with 69 additions and 21 deletions

View File

@@ -13,15 +13,11 @@ import (
// How often we poll for updates.
const metricsPollingInterval = 1 * time.Minute
var _getStatus func() models.Status
// CollectedMetrics stores different collected + timestamped values.
type CollectedMetrics struct {
CPUUtilizations []timestampedValue `json:"cpu"`
RAMUtilizations []timestampedValue `json:"memory"`
DiskUtilizations []timestampedValue `json:"disk"`
Viewers []timestampedValue `json:"-"`
}
// Metrics is the shared Metrics instance.
@@ -29,8 +25,6 @@ var Metrics *CollectedMetrics
// Start will begin the metrics collection and alerting.
func Start(getStatus func() models.Status) {
_getStatus = getStatus
host := data.GetServerURL()
if host == "" {
host = "unknown"
@@ -72,7 +66,6 @@ func Start(getStatus func() models.Status) {
Metrics = new(CollectedMetrics)
go startViewerCollectionMetrics()
handlePolling()
for range time.Tick(metricsPollingInterval) {
handlePolling()