From 22ebc8032913787b7e1dc41be0ae255a5150e062 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 6 Mar 2018 15:43:36 +0100 Subject: [PATCH] cmd/stdiscosrv: Expose process metrics Like this: $ curl -s http://localhost:9098/metrics | egrep '^syncthing_discovery_process' syncthing_discovery_process_cpu_seconds_total 12.92 syncthing_discovery_process_max_fds 10240 syncthing_discovery_process_open_fds 51 syncthing_discovery_process_resident_memory_bytes 1.3674496e+08 syncthing_discovery_process_start_time_seconds 1.52034731837e+09 syncthing_discovery_process_virtual_memory_bytes 1.40324864e+08 --- cmd/stdiscosrv/stats.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/stdiscosrv/stats.go b/cmd/stdiscosrv/stats.go index 609b420d..6367f47c 100644 --- a/cmd/stdiscosrv/stats.go +++ b/cmd/stdiscosrv/stats.go @@ -7,6 +7,8 @@ package main import ( + "os" + "github.com/prometheus/client_golang/prometheus" ) @@ -105,4 +107,6 @@ func init() { replicationSendsTotal, replicationRecvsTotal, databaseKeys, databaseStatisticsSeconds, databaseOperations, databaseOperationSeconds) + + prometheus.MustRegister(prometheus.NewProcessCollector(os.Getpid(), "syncthing_discovery")) }