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
- Every 5 Minutes
- Set Configuration Parameters
- Query Blocking Sessions
- Group by Blocking Session
- Post to Ollama API
- Validate Ollama Response
- Log Proposed Sessions
- Approve or Reject via Telegram
- If Approved
- Terminate Session
- Notify Outcome on Telegram
- Log Rejected Sessions
- Post Situation Embedding
- Search Criteria in Vector DB
15 steps in total.
Similar automations
Monitoring, Ops & IncidentsDiagnose failed n8n workflows with Ollama and post triage to Discord16 stepsCRM & Sales PipelineScore customer churn risk from PostgreSQL data and alert Slack with Gemini17 stepsData Sync & ETLExport a PostgreSQL Table to a CSV File4 stepsData Sync & ETLExport a PostgreSQL Table to a CSV File6 steps