I want to see the current pod age. Since there is no metric like that, but only the pod creation time (got that from kube_pod_created{namespace="$namespace"} * 1000
), I though that maybe I could subtract that from the current time of the host machine. Is that possible? If so, how can I do that?
yep, there is a way. See the time()
function in PromQL.
Also check out this panel in one of our public dashboards and then try something like:
time() - node_boot_time_seconds{job="node", instance=~"$node:.*"}
or I guess in your case something like:
time() - kube_pod_created{namespace="$namespace"} * 1000)
Can you please explain why this does not provide the difference between now and the last time the metric was published?
(time() - max(timestamp(statsd_gauges_braas_config{config_name="test-db-config"})))/3600
I guess the metric is still being reported - the timestamp takes the timestamp of the point the series returns, so if the series is present now, it’s returning now.
No the last time the metric was pushed was 2 day ago, so ideally it should return the difference in hours but it’s returning some weird number.
so for example: max(timestamp(statsd_gauges_braas_config{config_name="test-db-config"}))
is giving 1737104452
and time()
is giving 1737292800
but time() - max(timestamp(statsd_gauges_braas_config{config_name="test-db-config"}))
is giving 548 which is wrong imo.
Can you provide some more info? Screens of base statsd_gauges_braas_config{config_name="test-db-config"}
as a range query, screens of max(timestamp(statsd_gauges_braas_config{config_name="test-db-config"}))
and time()
as instant queries?