summaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/metrics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'configd/src/apps/sentinel/metrics.cpp')
-rw-r--r--configd/src/apps/sentinel/metrics.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/configd/src/apps/sentinel/metrics.cpp b/configd/src/apps/sentinel/metrics.cpp
index 204e8476e51..fe912c1ebb2 100644
--- a/configd/src/apps/sentinel/metrics.cpp
+++ b/configd/src/apps/sentinel/metrics.cpp
@@ -25,6 +25,7 @@ StartMetrics::StartMetrics()
{
// account for the sentinel itself restarting
sentinel_restarts.add();
+ lastRestartTime = vespalib::steady_clock::now();
}
StartMetrics::~StartMetrics() = default;
@@ -32,10 +33,22 @@ StartMetrics::~StartMetrics() = default;
void
StartMetrics::maybeLog()
{
+ using namespace std::chrono_literals;
vespalib::steady_time curTime = vespalib::steady_clock::now();
+ if (curTime - lastRestartTime > 2h) {
+ totalRestartsCounter = 0;
+ lastRestartTime = vespalib::steady_clock::now();
+ }
sentinel_totalRestarts.sample(totalRestartsCounter);
sentinel_running.sample(currentlyRunningServices);
sentinel_uptime.sample(vespalib::to_s(curTime - startedTime));
}
+void
+StartMetrics::incRestartsCounter()
+{
+ ++totalRestartsCounter;
+ lastRestartTime = vespalib::steady_clock::now();
+}
+
}