GraphQL: How to get the runtime of a serverless pod through the api stateless?

Goal is to get the runtime (or call it active time) since start. Constraint is to do it stateless, meaning that persisting timestamps in my environment is not an option. Using graphql https://graphql-spec.runpod.io/#definition-Pod: pod.runtime.uptimeInSeconds field seems to give a sum of all runtimes of the pod, not what is aimed for. Currently the timestamp in the pod.lastStatusChange string (which looks like this Resumed by user: Wed Feb 05 2024 10:54:54 GMT+0000 (Coordinated Universal Time)) is parsed to get an interval. Further these fields are checked for the running value: pod.desiredStatus: RUNNING pod.latestTelemetry.state: running (latestTelemetry.state can be running while the desired status is EXITED, and I check both for running to have some confidence) Like that I'm able to get the runtime which matches what's displayed in the ui. It seems a bit compicated and i'm not sure how much the lastStatusChange field can be relied on. Is there a better way to get the runtime of a serverless pod?
No description
1 Reply
pazanchick
pazanchick4mo ago
there's an undocumented field https://graphql-spec.runpod.io/#definition-Pod lastStartedAt which seems to give the desired datetime for that