anchor.diff:      - queries:
           usage: "GAUGE"
           description: "Current number of slow queries"
  +
  +pg_long_running_transactions:
  +  query: |
  +    SELECT COUNT(*) as transactions,
  +    coalesce(MAX(EXTRACT(EPOCH FROM (clock_timestamp() - xact_start))), 0) AS age_in_seconds
  +    FROM pg_stat_activity
  +    WHERE state is distinct from 'idle' AND (now() - xact_start) > '1 minutes'::interval AND query not like 'autovacuum:%'
  +  metrics:
  +    - transactions:
  +        usage: "GAUGE"
  +        description: "Current number of long running transactions"
  +    - age_in_seconds:
  +        usage: "GAUGE"
  +        description: "The current maximum transaction age in seconds"
  +
  +pg_stuck_idle_in_transaction:
  +  query: |
  +    SELECT COUNT(*) AS queries
  +    FROM pg_stat_activity
  +    WHERE state = 'idle in transaction' AND (now() - query_start) > '10 minutes'::interval
  +  metrics:
  +    - queries:
  +        usage: "GAUGE"
  +        description: "Current number of queries that are stuck being idle in transactions"
  +
  +# All xid and lsn metrics here are reported mod 2^52 to ensure they
  +# fit within a float for Prometheus :( Really annoying that counters
  +# aren't stored in a 64-bit integer. Note that for queries that report
  +# floats this only works because postgres_exporter does know to set
  +# extra_float_digits (which it sets to 2). So they don't print in
  +# exponential notation and precision is maintained up to 2^53-1.
   
   pg_vacuum:
     query: |
  
positive.code:         usage: "GAUGE"
          description: "Elapsed time vacuuming (in seconds)"
  
  
negative.code:         usage: "LABEL"
          description: "The table on which a query is blocked"
  
  pg_oldest_blocked:
    query: |
      SELECT coalesce(extract('epoch' from max(clock_timestamp() - state_change)), 0) age_seconds
        FROM pg_stat_activity
       WHERE wait_event_type = 'Lock'
         AND state='active'
    metrics:
      - age_seconds:
          usage: "GAUGE"
          description: "Largest number of seconds any transaction is currently waiting on a lock"
  
  pg_slow:
    query: |
      SELECT COUNT(*) AS queries
  