Skip to content
NEWMarketplace and your team: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / Monitoring, Ops & Incidents

Monitoring, Ops & Incidents

Triage PostgreSQL blocking sessions with Ollama and Telegram approval

Runs every 5 minutes to find PostgreSQL blocking sessions, asks a local Ollama model for a TERMINATE or WAIT triage, and terminates the blocker only after Telegram approval.

What it does

## Triage PostgreSQL blocking sessions with Ollama and Telegram approval ### How it works Every 5 minutes the workflow looks for blocking sessions in PostgreSQL and groups them into one proposal per blocker. It retrieves the applicable severity criterion from a pgvector knowledge base, asks a local Ollama model for a triage (TERMINATE or WAIT) and writes the proposal to an append-only audit log. A Telegram message then asks a human to approve or reject: on approval the blocking session is terminated and the outcome is notified, otherwise the rejection is logged. The AI proposes, a human signs off, the database records. The guardrails live in the database, not in the workflow. ### Setup steps - Run the one-time database setup described in the Prerequisites note. - Create two Postgres credentials on the monitored database: user ai_monitor (all Postgres nodes except one) and user ai_action (only Terminate Session). - Create a Telegram credential with your bot token and assign it to the two Telegram nodes. - In Set Configuration Parameters fill in chatId, approver, ollamaUrl and, if needed, model and embeddingModel. - Pull the two Ollama models (llama3.2:3b, nomic-embed-text) and make sure n8n can reach Ollama. - n8n must be reachable from the approver's device, because the Approve / Reject buttons open the n8n webhook URL. ### Customization Change the schedule, the 30-minute window that avoids repeated proposals, the severity criteria in the knowledge base, the prompt or the Ollama model.

The steps

  1. Every 5 Minutes
  2. Set Configuration Parameters
  3. Query Blocking Sessions
  4. Group by Blocking Session
  5. Post to Ollama API
  6. Validate Ollama Response
  7. Log Proposed Sessions
  8. Approve or Reject via Telegram
  9. If Approved
  10. Terminate Session
  11. Notify Outcome on Telegram
  12. Log Rejected Sessions
  13. Post Situation Embedding
  14. Search Criteria in Vector DB

15 steps in total.

Similar automations