On Wed, Jan 6, 2021 at 2:33 PM Alexander Golikov <[email protected]>
wrote:
So I want to get time while metric
> windows_process_start_time{process="game_process_name"} is present during
> current day.
> Is it possible?
>
Since the value of the metric is the start time for that process, something
like:
timestamp(windows_process_start_time{...}) - windows_process_start_time{...}
will give you the uptime for that process (assuming the metric goes stale
fast enough after the process stops).
If you have multiple processes, because they have started and stopped,
you'll get multiple values, so:
sum by (process) (timestamp(windows_process_start_time{...}) -
windows_process_start_time{...})
gives you the accumulated run time for all the processes with the same name.
Just keep in mind that if the process doesn't stop, say for example the
computer suspends, this expression will report a higher uptime and your
kids will rightfully object :-)
--
Marcelo Magallón
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/CABiJYgZxqtodRQox9Nh5OfnoGQCmhtxCGPrPLVQO5L9iRfo-Tg%40mail.gmail.com.