Automated monitoring solution for the Lleverage platform that runs health checks every 15 minutes and sends Slack notifications when components fail or the platform is unreachable.
- β Runs active monitoring checks every 15 minutes via Cloud Scheduler
- π Sends formatted Slack notifications on failures
- π Monitors both test components and AI providers
- π¨ Alerts on platform outages or component failures
- π Beautiful Slack message formatting with emojis and structured blocks
- Google Cloud Platform account with billing enabled
- Slack workspace with Incoming Webhooks enabled
- Node.js 14+ (for local testing)
- Go to https://api.slack.com/apps
- Create a new app or select an existing one
- Navigate to "Incoming Webhooks"
- Activate Incoming Webhooks
- Click "Add New Webhook to Workspace"
- Select the channel where you want notifications
- Copy the webhook URL
npm installSet the following environment variables:
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
export SMOKE_TEST_API_URL="https://lqnc85.lleverage.run/li8yb6pr" # Optional, defaults to this
export TEST_TEXT="Test" # Optional: text to send in the API request
export TEST_FILE_PATH="/path/to/file" # Optional: file to uploadMake the script executable and run it:
chmod +x deploy.sh
export SLACK_WEBHOOK_URL="your-slack-webhook-url"
export GOOGLE_CLOUD_PROJECT="your-gcp-project-id"
./deploy.sh# Set your project
gcloud config set project YOUR_PROJECT_ID
# Deploy the function
gcloud functions deploy activeMonitoring \
--gen2 \
--runtime=nodejs18 \
--region=us-central1 \
--source=. \
--entry-point=activeMonitoring \
--trigger-http \
--allow-unauthenticated \
--timeout=540s \
--memory=256MB \
--set-env-vars="SMOKE_TEST_API_URL=https://lqnc85.lleverage.run/li8yb6pr,SLACK_WEBHOOK_URL=your-slack-webhook-url"
# Create the scheduler job
gcloud scheduler jobs create http active-monitoring-scheduler \
--location=us-central1 \
--schedule="*/15 * * * *" \
--uri="$(gcloud functions describe activeMonitoring --gen2 --region=us-central1 --format='value(serviceConfig.uri)')" \
--http-method=POST \
--time-zone="UTC" \
--description="Runs Lleverage platform active monitoring every 15 minutes"You can test the function locally before deploying:
export SLACK_WEBHOOK_URL="your-slack-webhook-url"
node index.js- Cloud Scheduler triggers the function every 15 minutes
- Cloud Function makes a POST request to the monitoring API
- Response Analysis:
- If the request fails β Sends critical failure notification
- If any component returns
falseβ Sends component failure notification - If all tests pass β No notification (silent success)
- Slack Notifications are formatted with:
- Status indicators (π¨ for critical,
β οΈ for warnings) - Failed components list
- Passing components summary
- Timestamp and error details
- Status indicators (π¨ for critical,
π¨ Lleverage Platform Active Monitoring - CRITICAL FAILURE
Status: β Platform Unreachable
Error Details: [error message]
β οΈ Lleverage Platform Active Monitoring - Component Failure
Status: β οΈ Some components failed
Failed Components:
Tests: [component1], [component2]
Providers: [provider1]
Passing Tests: β
[list]
Passing Providers: β
[list]
gcloud functions logs read activeMonitoring --gen2 --region=us-central1 --limit=50curl -X POST "https://[YOUR-REGION]-[YOUR-PROJECT].cloudfunctions.net/activeMonitoring"gcloud scheduler jobs describe active-monitoring-scheduler --location=us-central1Edit the schedule in deploy.sh or update the scheduler job:
gcloud scheduler jobs update http active-monitoring-scheduler \
--location=us-central1 \
--schedule="*/30 * * * *" # Every 30 minutes insteadCommon cron schedules:
- Every 15 minutes:
*/15 * * * * - Every hour:
0 * * * * - Every day at 9 AM:
0 9 * * *
| Variable | Required | Default | Description |
|---|---|---|---|
SLACK_WEBHOOK_URL |
Yes | - | Slack incoming webhook URL |
SMOKE_TEST_API_URL |
No | https://lqnc85.lleverage.run/li8yb6pr |
API endpoint to test |
TEST_TEXT |
No | Test |
Text parameter for API request |
TEST_FILE_PATH |
No | - | Optional file path to upload |
-
Check Cloud Scheduler job status:
gcloud scheduler jobs describe active-monitoring-scheduler --location=us-central1 -
Check function logs for errors
-
Verify environment variables are set correctly
- Verify
SLACK_WEBHOOK_URLis correct - Test the webhook URL manually:
curl -X POST -H 'Content-type: application/json' \ --data '{"text":"Test message"}' \ YOUR_SLACK_WEBHOOK_URL
- Check if the API endpoint is accessible
- Verify network connectivity from Cloud Functions
- Check API endpoint authentication if required
This solution uses:
- Cloud Functions Gen 2: Pay per invocation (~$0.40 per million requests)
- Cloud Scheduler: Free for up to 3 jobs per month, then $0.10 per job per month
- Networking: Minimal egress costs
Estimated monthly cost: ~$0.50 - $2.00 for 15-minute intervals (2,880 invocations/month)
MIT