comparison 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
comparison
equal deleted inserted replaced
5110:98da039474b1 5111:7547c7dfd017
843 countStudies, countSeries, countInstances); 843 countStudies, countSeries, countInstances);
844 844
845 unsigned int jobsPending, jobsRunning, jobsSuccess, jobsFailed; 845 unsigned int jobsPending, jobsRunning, jobsSuccess, jobsFailed;
846 context.GetJobsEngine().GetRegistry().GetStatistics(jobsPending, jobsRunning, jobsSuccess, jobsFailed); 846 context.GetJobsEngine().GetRegistry().GetStatistics(jobsPending, jobsRunning, jobsSuccess, jobsFailed);
847 847
848 int64_t serverUpTime = context.GetServerUpTime();
849 Json::Value lastChange;
850 context.GetIndex().GetLastChange(lastChange);
851
848 MetricsRegistry& registry = context.GetMetricsRegistry(); 852 MetricsRegistry& registry = context.GetMetricsRegistry();
849 registry.SetValue("orthanc_disk_size_mb", static_cast<float>(diskSize) / MEGA_BYTES); 853 registry.SetValue("orthanc_disk_size_mb", static_cast<float>(diskSize) / MEGA_BYTES);
850 registry.SetValue("orthanc_uncompressed_size_mb", static_cast<float>(diskSize) / MEGA_BYTES); 854 registry.SetValue("orthanc_uncompressed_size_mb", static_cast<float>(diskSize) / MEGA_BYTES);
851 registry.SetValue("orthanc_count_patients", static_cast<unsigned int>(countPatients)); 855 registry.SetValue("orthanc_count_patients", static_cast<unsigned int>(countPatients));
852 registry.SetValue("orthanc_count_studies", static_cast<unsigned int>(countStudies)); 856 registry.SetValue("orthanc_count_studies", static_cast<unsigned int>(countStudies));
855 registry.SetValue("orthanc_jobs_pending", jobsPending); 859 registry.SetValue("orthanc_jobs_pending", jobsPending);
856 registry.SetValue("orthanc_jobs_running", jobsRunning); 860 registry.SetValue("orthanc_jobs_running", jobsRunning);
857 registry.SetValue("orthanc_jobs_completed", jobsSuccess + jobsFailed); 861 registry.SetValue("orthanc_jobs_completed", jobsSuccess + jobsFailed);
858 registry.SetValue("orthanc_jobs_success", jobsSuccess); 862 registry.SetValue("orthanc_jobs_success", jobsSuccess);
859 registry.SetValue("orthanc_jobs_failed", jobsFailed); 863 registry.SetValue("orthanc_jobs_failed", jobsFailed);
860 864 registry.SetValue("orthanc_up_time_s", serverUpTime);
865 registry.SetValue("orthanc_last_change", lastChange["Last"].asInt64());
866
861 std::string s; 867 std::string s;
862 registry.ExportPrometheusText(s); 868 registry.ExportPrometheusText(s);
863 869
864 call.GetOutput().AnswerBuffer(s, MimeType_PrometheusText); 870 call.GetOutput().AnswerBuffer(s, MimeType_PrometheusText);
865 } 871 }