Skip to content

Commit 37ec6e5

Browse files
akhil-gautamclaude
andcommitted
docs: add real-world Postgres plugin example to README
Shows a complete plugins.toml with PG connections, active queries, database sizes, top tables, and Redis — copy-paste ready. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6c25aaa commit 37ec6e5

1 file changed

Lines changed: 49 additions & 1 deletion

File tree

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,55 @@ end
463463
| ML inference tokens/sec | External | Poll ollama API, compute delta |
464464
| Custom alerting | Lua | Conditional logic on system data |
465465

466-
See `examples/` directory for ready-to-use plugin samples.
466+
### Real-World Example: Postgres Monitoring
467+
468+
Create `~/.config/bloat/plugins.toml` to monitor your database alongside system metrics:
469+
470+
```toml
471+
# Connection states (active, idle, etc.)
472+
[[panel]]
473+
name = "PG Connections"
474+
command = "psql -c \"SELECT state, count(*) FROM pg_stat_activity GROUP BY state ORDER BY count DESC;\" -t 2>/dev/null || echo 'PG not running'"
475+
interval = 5
476+
position = "right"
477+
color = "blue"
478+
479+
# Currently running queries
480+
[[panel]]
481+
name = "PG Active Queries"
482+
command = "psql -c \"SELECT pid, now()-query_start as duration, left(query,50) FROM pg_stat_activity WHERE state='active' AND query NOT LIKE '%pg_stat%' ORDER BY duration DESC LIMIT 5;\" -t 2>/dev/null || echo 'None'"
483+
interval = 5
484+
position = "right"
485+
color = "blue"
486+
487+
# Database sizes
488+
[[panel]]
489+
name = "PG Databases"
490+
command = "psql -c \"SELECT datname, pg_size_pretty(pg_database_size(datname)) as size FROM pg_database WHERE datistemplate=false ORDER BY pg_database_size(datname) DESC LIMIT 8;\" -t 2>/dev/null || echo 'PG not running'"
491+
interval = 30
492+
position = "left"
493+
color = "blue"
494+
495+
# Largest tables in your app database
496+
[[panel]]
497+
name = "PG Top Tables"
498+
command = "psql -d myapp_development -c \"SELECT schemaname||'.'||relname, pg_size_pretty(pg_total_relation_size(relid)) FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC LIMIT 5;\" -t 2>/dev/null || echo 'No tables'"
499+
interval = 30
500+
position = "left"
501+
color = "cyan"
502+
503+
# Redis alongside Postgres
504+
[[panel]]
505+
name = "Redis"
506+
command = "redis-cli info memory 2>/dev/null | grep -E 'used_memory_human|connected_clients' || echo 'Redis not running'"
507+
interval = 5
508+
position = "right"
509+
color = "red"
510+
```
511+
512+
Replace `myapp_development` with your database name. Add `-U username -h hostname` to `psql` if needed.
513+
514+
See `examples/` directory for more ready-to-use plugin samples.
467515

468516
## Tech Stack
469517

0 commit comments

Comments
 (0)