Notifications
pgtail can send desktop notifications for important log events while it tails.
Platform support
Section titled “Platform support”| Platform | Method |
|---|---|
| macOS | osascript (built in) |
| Linux | notify-send (libnotify; install the libnotify-bin package if it is missing) |
| Windows | Windows toast notifications |
On Windows, pgtail creates a pgtail shortcut in the Start menu, since Windows shows toasts only for applications
registered there.
Turning notifications on
Section titled “Turning notifications on”notify on adds a rule and turns notifications on. Rules add up: each notify on keeps the earlier ones.
By log level
Section titled “By log level”notify on FATAL PANIC # Specific levelsnotify on error+ # ERROR and aboveLevels accept the same forms as level.
By pattern
Section titled “By pattern”notify on /deadlock/ # Case-sensitivenotify on /connection refused/i # Ignoring caseBy error rate
Section titled “By error rate”notify on errors > 10/min # When more than 10 errors arrive in a minuteBy query duration
Section titled “By query duration”notify on slow > 500ms # When a query takes longer than 500 msnotify on slow > 2s # Seconds work tooViewing the settings
Section titled “Viewing the settings”pgtail> notifyNotifications: enabled Levels: FATAL, PANIC Patterns: /deadlock/i Error rate: > 10/min Quiet hours: 22:00-08:00Platform: macOS (osascript)What notifies, and how often
Section titled “What notifies, and how often”- Only entries logged after tailing starts. Entries a time filter reads back, as
tail 0 --since 1ddoes, count in the statistics but never notify. - At most one notification every 5 seconds. Alerts that match in between are not dropped: when the 5 seconds are up,
one notification counts them (
pgtail: 4 more alerts,3 ERROR · 1 FATAL) and shows the most severe. - An alert whose message was already shown in the last minute, apart from its numbers (
queue depth is 814andqueue depth is 233), counts as a repeat instead of showing again; the next time it shows, it says how many times it repeated. - Error rate alerts at most once a minute
- Nothing during quiet hours
Quiet hours
Section titled “Quiet hours”Silence notifications during set hours:
notify quiet 22:00-08:00 # Nothing from 10 PM to 8 AMnotify quiet off # No quiet hoursA range that crosses midnight works as expected. notify shows (active) while quiet hours are in effect.
Testing
Section titled “Testing”notify test # An info notificationnotify test error # Also: warning, criticalOn Windows the severity sets how long the toast stays in the notification center: 2 minutes for info, 10 for warning, 30 for error, and until dismissed for critical.
Turning notifications off
Section titled “Turning notifications off”notify off # Stop notifying, keeping the rulesnotify clear # Remove every ruleConfiguration
Section titled “Configuration”notify commands save their settings to the configuration file:
[notifications]enabled = truelevels = ["FATAL", "PANIC"]patterns = ["/deadlock/i"]error_rate = 10slow_query_ms = 500quiet_hours = "22:00-08:00"The same commands work in tail mode.