prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.8k stars 738 forks source link

Slave lag query returning NaN #105

Open keithf4 opened 7 years ago

keithf4 commented 7 years ago

The following query keeps returning NaN

SELECT extract(epoch from now() - pg_last_xact_replay_timestamp())::int AS last_replay_time

I'm able to run this query as a non-superuser in the database and get results back, but I checked using a security definer function and it returns NaN as well

CREATE OR REPLACE FUNCTION monitor.replica_replay_time_lag() RETURNS TABLE (last_replay_time int) 
    LANGUAGE SQL SECURITY DEFINER
AS $$
    SELECT extract(epoch from now() - pg_last_xact_replay_timestamp())::int AS last_replay_time
    $$;
wrouesnel commented 7 years ago

Current master has a few logging enhancements for this problem. At the moment we don't handle timestampy values well (they're consistent enough that it should be possible to do so and PG10 adds a bunch we'd like to collect anyway).