Skip to content
no0p edited this page Oct 19, 2014 · 3 revisions

An alert is triggered when an "alert query" returns a null value in the first column of the first cell.

This convention means that adding an alert condition just involves writing an SQL statement against the pgantenna tables.

Example Alerts

Has my cluster sent a heartbeat in the last minute?

SELECT measured_at as is_alive
  FROM heartbeats
    WHERE measured_at > (clock_timestamp() - interval '1 minute')
  LIMIT 1

Do any of my filesystems have less than 20% available space?

WITH last_stats as (
  SELECT DISTINCT ON (filesystem_id) 
         filesystem_id, measured_at, blk_avail, blks_in_frags
    FROM stat_filesystems
      ORDER BY filesystem_id, measured_at DESC
)
SELECT filesystems.name
  FROM filesystems
    INNER JOIN last_stats ON last_stats.filesystem_id = filesystems.id
  WHERE ((blk_avail * blksize) / (blks_in_frags * fragsize)::numeric) < 0.2

Clone this wiki locally