Automated real-time monitoring of financial services using Downdetector data
Setup β’ Usage β’ Testing β’ Contributing
This bot was created to proactively monitor service instability reported on Downdetector Brasil and automatically notify Slack channels about potential issues affecting Brazilian financial services.
βοΈ Real-time alerts when services experience problems
βοΈ Automated monitoring
βοΈ Centralized notifications in Slack
βοΈ Early warning system for technical teams
- Automated Monitoring: Checks 8 major financial services every 10 minutes
- Slack Notifications: Sends formatted alerts to designated channels
- Status Tracking: Monitors
success,warning, anddangerstates - Smart Detection: Tracks incidents from start to resolution
- Batch Alerts: Sends collective warnings when 3+ services are affected within a 5-minute window
- Time-Window Filtering: Prevents false positives from isolated warnings at different times
- Docker Ready: Containerized deployment with Railway support
- Tested: Unit tests with Vitest
Click to expand monitored services
| Service |
|---|
| PIX |
| ItaΓΊ |
| Bradesco |
| Santander |
| Nubank |
| Banco do Brasil |
| Mercado Pago |
| PicPay |
Click to expand/collapse architecture diagram
graph TB
Start([Cron Job<br/>Every 5min]) --> Server[Server.ts<br/>Entry Point]
Server --> Job[Monitoring Job]
Job --> Orchestrator[Notification Orchestrator<br/>CheckAll Function]
Orchestrator --> Scraper[Downdetector Service<br/>Playwright Scraper]
Scraper --> Browser{Cloud Browser}
Browser --> DD1[downdetector.com.br/pix]
Browser --> DD2[downdetector.com.br/itau]
Browser --> DD3[downdetector.com.br/...]
DD1 --> Data{Extract Status}
DD2 --> Data
DD3 --> Data
Data --> Scraper
Scraper --> Orchestrator
Orchestrator --> Process{Process Results}
Process --> Warning[Warning Collector<br/>3+ services in 5min<br/>Time-windowed detection]
Process --> Incident[Incident Monitors<br/>8 individual monitors]
Warning --> Slack1[Slack Channel<br/>β οΈ Batch Alert]
Incident --> Slack2[Slack Channel<br/>β οΈ Critical Alert]
Incident --> Slack3[Slack Channel<br/>π Resolution]
Slack1 --> End([Team Notified])
Slack2 --> End
Slack3 --> End
style Start fill:#e1f5fe
style Orchestrator fill:#fff9c4
style Browser fill:#fff3e0
style Process fill:#e1bee7
style Slack1 fill:#4A154B,color:#fff
style Slack2 fill:#4A154B,color:#fff
style Slack3 fill:#4A154B,color:#fff
style End fill:#e8f5e9
graph LR
subgraph "Application Layer"
Server[server.ts<br/> Entry Point]
App[app.ts<br/> Slack Config]
Job[jobs/monitoring.ts<br/> */5 * * * *]
end
subgraph "Orchestration Layer"
Orchestrator[slack/notificationOrchestrator.ts]
end
subgraph "Business Logic"
Incident[slack/incidentMonitor.ts<br/>Per-Service Handler<br/>8 instances]
Warning[slack/warningMonitor.ts<br/>Batch Warning Detector<br/>Time-window: 5min]
end
subgraph "Data Layer"
Scraper[services/downdetectorService.ts<br/>Playwright Automation<br/>checkAllServices]
Types[types/downdetector.ts]
end
subgraph "External Services"
Downdetector[(downdetector.br)]
Slack[( Slack API)]
BrowserCash[(Cloud Browser)]
end
Server --> Job
Server --> App
Job --> Orchestrator
Orchestrator --> Scraper
Orchestrator --> Incident
Orchestrator --> Warning
Scraper --> BrowserCash
BrowserCash --> Downdetector
Incident --> Slack
Warning --> Slack
Scraper -.-> Types
style Server fill:#4CAF50,color:#fff
style Orchestrator fill:#FFD700,color:#000
style Scraper fill:#2196F3,color:#fff
style Downdetector fill:#FF9800,color:#fff
style Slack fill:#4A154B,color:#fff
style BrowserCash fill:#9C27B0,color:#fff
Each service has its own incident monitor that tracks status changes:
- β οΈ Critical Alert: Sent when service enters
dangerstate - π Resolution Alert: Sent when service returns to
success
The system uses a 5-minute sliding time window to detect widespread issues:
Trigger Conditions:
- 3 or more services in
warningstate - All warnings occurred within the last 5 minutes
- Prevents false positives from isolated incidents
Example:
23:30 - PIX enters warning
23:32 - Santander enters warning
23:34 - Nubank enters warning
βοΈ ALERT SENT (3 services affected simultaneously)
23:30 - PIX enters warning
23:40 - Santander enters warning (PIX warning expired)
23:45 - Nubank enters warning
βοΈ NO ALERT (warnings not simultaneous)
Why This Matters:
- Reduces noise from sporadic issues
- Highlights actual system-wide instability
- Teams only get alerted for meaningful incidents
- Node.js 20+
- Slack App with Bot Token (Create one here)
Click to expand setup instructions
- Clone the repository
git clone https://github.com/eduardotashiro/downdetector-slack.git
cd downdetector-slack- Install dependencies
npm install- Configure environment variables
Create a .env file:
# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
SLACK_SIGNING_SECRET=your-signing-secret-here
CHANNEL_ID=your-slack-channel-id
# BrowserCash
APIKEY=your-browsercash-api-key
# Server
PORT=3000- Build the project
npm run build- Start the bot
npm startClick to expand instructions
This project includes a Slack App Manifest to simplify app creation.- Go to https://api.slack.com/apps
- Click Create New App
- Choose From an app manifest
- Select your workspace
- Paste the content of
/slack/manifest.json - Install the app to your workspace
- Copy the Bot Token and Signing Secret to your
.env
Click to expand Docker instructions
docker build -t downdetector-slack .
docker run -p 3000:3000 --env-file .env downdetector-slack- Push your code to GitHub
- Connect repository to Railway
- Add environment variables in Railway dashboard:
SLACK_BOT_TOKENSLACK_SIGNING_SECRETCHANNEL_IDAPIKEY
- Railway auto-deploys on push to
main
Click to expand usage examples
npm run devRuns with hot-reload using tsx watch
npm run build
npm startFrequency: Every 10 minutes, 24/7
// src/jobs/monitoring.ts
cron.schedule("*/10 * * * *", run, {
timezone: "America/Sao_Paulo"
});Click to expand testing guide
This project uses Vitest for fast and modern testing.
npm test # Run tests once
npm run test:watch # Watch mode src/slack/__tests__/
βββ fixtures.ts # Mock data for tests
βββ incidentMonitor.spec.ts # Incident monitor tests
βββ warningMonitor.spec.ts # Warning collector tests
Click to expand contribution guide
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature- Commit your changes (use Conventional Commits)
git commit -m 'feat: add amazing feature'- Push to the branch
git push origin feature/amazing-feature- Open a Pull Request
feat: New featurefix: Bug fixdocs: Documentation changestest: Add or update testsperf: Performance improvementsrefactor: Code refactoringchore: Maintenance tasks
npm test # Run tests
npm run build # Verify build worksThis project is licensed under the MIT License - see the LICENSE file for details.



