Dear Marcelo, thank you for the answer.
But the query is not so good still. If processes have multiple threads with
different pids, sum grows much faster than time.
I tried to imagine something like
sum by (process) (timestamp(windows_process_start_time{}) -
windows_process_start_time{process="chrome"})/3600 /
count(windows_process_start_time{}) by (process)
[image: изображение.png]
but this does not work if the process is fully closed and restarted after
sometime.
I also tried to imagine something like
sum_over_time(windows_process_start_time{}[24h]^0), but this does not work
due to the hard mix of range and instant vectors.
Also I tried to add %24 to try to drop values from multi-days processes.
sum by (process) (timestamp(windows_process_start_time{}) -
windows_process_start_time{})/3600/24%24
Not no good, but this problem may be dropped by label filtering. Game
process is usually stopped even if the computer suspends.
пн, 11 янв. 2021 г. в 16:13, 'Marcelo Magallón' via Prometheus Users <
[email protected]>:
> 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 a topic in the
> Google Groups "Prometheus Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/prometheus-users/zTToHabForU/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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
> <https://groups.google.com/d/msgid/prometheus-users/CABiJYgZxqtodRQox9Nh5OfnoGQCmhtxCGPrPLVQO5L9iRfo-Tg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
Regards,
Alexander Golikov
--
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/CACvZ-jHoDB4w%3Dehh44EWnnck5gk%2BUZ2BNgW3VyfKH6rfABBnrA%40mail.gmail.com.