diff options
Diffstat (limited to 'configd/src/apps/sentinel/metrics.cpp')
-rw-r--r-- | configd/src/apps/sentinel/metrics.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/configd/src/apps/sentinel/metrics.cpp b/configd/src/apps/sentinel/metrics.cpp index 42c61c06b50..bc9d87d0e73 100644 --- a/configd/src/apps/sentinel/metrics.cpp +++ b/configd/src/apps/sentinel/metrics.cpp @@ -4,18 +4,28 @@ #include <vespa/log/log.h> LOG_SETUP(".metrics"); +#include <vespa/vespalib/metrics/simple_metrics.h> + namespace config { namespace sentinel { +using vespalib::metrics::SimpleMetricsManager; +using vespalib::metrics::SimpleManagerConfig; + StartMetrics::StartMetrics() - : currentlyRunningServices(0), totalRestartsCounter(0), totalRestartsLastPeriod(1), - lastLoggedTime(0), - totalRestartsLastSnapshot(0), - snapshotStart(0), - snapshotEnd(0) + : metrics(SimpleMetricsManager::create(SimpleManagerConfig())), + producer(metrics), + currentlyRunningServices(0), + totalRestartsCounter(0), + totalRestartsLastPeriod(1), + startedTime(time(nullptr)), + lastLoggedTime(startedTime - 55), + sentinel_restarts(metrics->counter("sentinel.restarts")), + sentinel_totalRestarts(metrics->gauge("sentinel.totalRestarts")), + sentinel_running(metrics->gauge("sentinel.running")), + sentinel_uptime(metrics->gauge("sentinel.uptime")) { - snapshotEnd = time(nullptr); - lastLoggedTime = snapshotEnd - 55; + sentinel_restarts.add(); } void @@ -29,9 +39,6 @@ StartMetrics::output() void StartMetrics::reset(unsigned long curTime) { - totalRestartsLastSnapshot = totalRestartsLastPeriod; - snapshotStart = snapshotEnd; - snapshotEnd = curTime; totalRestartsLastPeriod = 0; lastLoggedTime = curTime; } @@ -40,6 +47,9 @@ void StartMetrics::maybeLog() { uint32_t curTime = time(nullptr); + sentinel_totalRestarts.sample(totalRestartsCounter); + sentinel_running.sample(currentlyRunningServices); + sentinel_uptime.sample(curTime - startedTime); if (curTime > lastLoggedTime + 59) { output(); reset(curTime); |