Getting Started
This guide will help you set up Sentinel Guard and start monitoring your application in just a few minutes.
Step 1: Create Your UptimeBeacon Account
- Visit UptimeBeacon.cloud  and sign up for an account
- Create a new project in your dashboard
- Navigate to the “API Keys” section
- Generate and copy your API credentials:
- API Key
- API Base URL
- Monitor API Key (from your monitor configuration)
Step 2: Install Sentinel Guard
Install the library using your preferred package manager:
npm install @uptimebeacon/sentinel-guard
Step 3: Set Up Environment Variables
Create a .env
file in your project root and add your credentials:
SENTINEL_API_KEY=your-api-key-here
SENTINEL_API_URL=https://api.uptimebeacon.cloud
SENTINEL_MONITOR_API_KEY=your-monitor-api-key-here
Never commit these credentials to version control. Add .env
to your .gitignore
file.
Step 4: Initialize Sentinel Guard
Create a new file or add to your existing application:
import { SentinelGuard } from "@uptimebeacon/sentinel-guard";
const sentinel = new SentinelGuard({
apiKey: process.env.SENTINEL_API_KEY!,
baseUrl: process.env.SENTINEL_API_URL!,
monitorApiKey: process.env.SENTINEL_MONITOR_API_KEY!,
timeout: 10000, // Optional: request timeout in milliseconds
});
Step 5: Start Monitoring
Begin automatic heartbeat monitoring:
// Start monitoring with a 30-second interval
sentinel.startMonitoring({
interval: 30000,
maxConsecutiveErrors: 5,
});
console.log("Monitoring started successfully");
Step 6: Add Graceful Shutdown
Ensure proper cleanup when your application shuts down:
process.on("SIGINT", () => {
console.log("Shutting down monitoring...");
sentinel.stopMonitoring();
process.exit(0);
});
process.on("SIGTERM", () => {
console.log("Shutting down monitoring...");
sentinel.stopMonitoring();
process.exit(0);
});
Complete Example
Here’s a complete minimal example:
import { SentinelGuard } from "@uptimebeacon/sentinel-guard";
const sentinel = new SentinelGuard({
apiKey: process.env.SENTINEL_API_KEY!,
baseUrl: process.env.SENTINEL_API_URL!,
monitorApiKey: process.env.SENTINEL_MONITOR_API_KEY!,
});
// Start monitoring
sentinel.startMonitoring({
interval: 30000,
maxConsecutiveErrors: 5,
});
console.log("Application monitoring started");
// Graceful shutdown
process.on("SIGINT", () => {
sentinel.stopMonitoring();
process.exit(0);
});
Verification
After starting your application:
- Check your console for the “Application monitoring started” message
- Log in to your UptimeBeacon.cloud dashboard
- Navigate to your project’s monitoring section
- You should see heartbeat data appearing within 30 seconds
Troubleshooting
If you encounter issues:
- Authentication Error: Verify your API credentials are correct
- Network Error: Check your internet connection and API URL
- No Data in Dashboard: Ensure your monitor API key is configured correctly
Common Patterns
Express.js Integration
import express from "express";
import { SentinelGuard } from "@uptimebeacon/sentinel-guard";
const app = express();
const sentinel = new SentinelGuard({
apiKey: process.env.SENTINEL_API_KEY!,
baseUrl: process.env.SENTINEL_API_URL!,
monitorApiKey: process.env.SENTINEL_MONITOR_API_KEY!,
});
app.listen(3000, () => {
console.log("Server running on port 3000");
sentinel.startMonitoring({
interval: 60000,
maxConsecutiveErrors: 3,
});
});
Background Service
import { SentinelGuard } from "@uptimebeacon/sentinel-guard";
class BackgroundService {
private sentinel: SentinelGuard;
constructor() {
this.sentinel = new SentinelGuard({
apiKey: process.env.SENTINEL_API_KEY!,
baseUrl: process.env.SENTINEL_API_URL!,
monitorApiKey: process.env.SENTINEL_MONITOR_API_KEY!,
});
}
async start() {
this.sentinel.startMonitoring({
interval: 45000,
maxConsecutiveErrors: 5,
});
console.log("Background service monitoring started");
}
async stop() {
this.sentinel.stopMonitoring();
console.log("Background service monitoring stopped");
}
}
You’re now ready to monitor your application with Sentinel Guard. The library will automatically send heartbeats to UptimeBeacon.cloud, allowing you to track your application’s health and performance in real-time.