diff OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp @ 5111:7547c7dfd017

/tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
author Alain Mazy <am@osimis.io>
date Tue, 22 Nov 2022 18:01:23 +0100
parents c2ebc47f4f18
children a6fa660ec26e
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Tue Nov 22 16:30:50 2022 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Tue Nov 22 18:01:23 2022 +0100
@@ -845,6 +845,10 @@
     unsigned int jobsPending, jobsRunning, jobsSuccess, jobsFailed;
     context.GetJobsEngine().GetRegistry().GetStatistics(jobsPending, jobsRunning, jobsSuccess, jobsFailed);
 
+    int64_t serverUpTime = context.GetServerUpTime();
+    Json::Value lastChange;
+    context.GetIndex().GetLastChange(lastChange);
+
     MetricsRegistry& registry = context.GetMetricsRegistry();
     registry.SetValue("orthanc_disk_size_mb", static_cast<float>(diskSize) / MEGA_BYTES);
     registry.SetValue("orthanc_uncompressed_size_mb", static_cast<float>(diskSize) / MEGA_BYTES);
@@ -857,7 +861,9 @@
     registry.SetValue("orthanc_jobs_completed", jobsSuccess + jobsFailed);
     registry.SetValue("orthanc_jobs_success", jobsSuccess);
     registry.SetValue("orthanc_jobs_failed", jobsFailed);
-    
+    registry.SetValue("orthanc_up_time_s", serverUpTime);
+    registry.SetValue("orthanc_last_change", lastChange["Last"].asInt64());
+
     std::string s;
     registry.ExportPrometheusText(s);