From f0591d85cd9caa922acf15b96e5c229d0b7dba20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 20 Jul 2025 02:14:17 +0200 Subject: [PATCH] process: fix `windows_process_start_time_seconds_timestamp` return relative time on Windows Server 2019 (#2137) --- internal/collector/process/process_worker.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/collector/process/process_worker.go b/internal/collector/process/process_worker.go index d1e30043..03640d80 100644 --- a/internal/collector/process/process_worker.go +++ b/internal/collector/process/process_worker.go @@ -144,7 +144,12 @@ func (c *Collector) collectWorker() { name, pidString, parentPID, strconv.Itoa(int(processGroupID)), processOwner, cmdLine, ) - startTime := float64(time.Now().UnixMicro())/1e6 - data.ElapsedTime + startTime := data.ElapsedTime + if c.config.CounterVersion == 2 { + // For V2, the ElapsedTime is in seconds, so we need to convert it to a timestamp. + // The start time is the current time minus the elapsed time. + startTime = float64(time.Now().UnixMicro())/1e6 - data.ElapsedTime + } ch <- prometheus.MustNewConstMetric( c.startTime,