Any way to get a process uptime as a counter?

Hi,

Is there was to get a process uptime as a counter, aside from creating a custom metric collector?

The only thing I found in Telegraf was procstat’s created_at field. It’s the epoch timestamp of when the process was started, and it can be used with Grafana’s data unit “From now”, but I’d much prefer a counter with the total number of seconds of uptime so far, as you can get for a host’s uptime.

Any hint appreciated!

Note: I’m using InfluxDB 1.8, not 2.x

Hi,

The system plugin can provide an “uptime” in seconds. Check out the README for an example.

That’s for system/host uptime, not the uptime of a particular process.

ah my bad not sure how I got that mixed up!

It may be possible to use the starlark processor to do that math to get the amount of time since the created_at field and add it as a field to the final metric. Here is an example of some time manipulation with the starlark processor.

Does that help?

1 Like

What is this sourcery?! :slight_smile:
Love this starlak processor, wasn’t aware of it. And didn’t even cross my mind to use a processor :man_facepalming: I guess the execd could also be used, but why do that when there’s a built-in interpreter in Telegraf? Wow.

Many thanks!

haha that is how I felt when I heard about it. Super powerful!