Laravel
Add monitoring to your Laravel app. Health endpoint, Laravel Scheduler heartbeats, and status badge.
Health endpoint
routes/api.php
Route::get('/health', function () {
return response()->json(['status' => 'ok']);
});This exposes GET /api/health — Laravel prefixes API routes with /api by default.
Heartbeat push (optional)
Use an Artisan command with Laravel Scheduler to push heartbeats every 5 minutes.
app/Console/Commands/SendHeartbeat.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Redis;
class SendHeartbeat extends Command
{
protected $signature = 'heartbeat:send';
protected $description = 'Send health heartbeat to BlueMonitor';
public function handle()
{
$checks = [];
// Database check
$dbStart = microtime(true);
try {
DB::select('SELECT 1');
$checks['database'] = [
'status' => 'ok',
'latency' => round((microtime(true) - $dbStart) * 1000),
];
} catch (\Exception $e) {
$checks['database'] = [
'status' => 'error',
'latency' => round((microtime(true) - $dbStart) * 1000),
'message' => $e->getMessage(),
];
}
// Redis check
$redisStart = microtime(true);
try {
Redis::ping();
$checks['redis'] = [
'status' => 'ok',
'latency' => round((microtime(true) - $redisStart) * 1000),
];
} catch (\Exception $e) {
$checks['redis'] = [
'status' => 'error',
'latency' => round((microtime(true) - $redisStart) * 1000),
];
}
$hasError = collect($checks)->contains('status', 'error');
Http::withToken(config('services.bluemonitor.key'))
->post('https://www.bluemonitor.org/api/v1/heartbeat', [
'domain' => 'yourapp.com',
'status' => $hasError ? 'error' : 'ok',
'timestamp' => now()->toISOString(),
'checks' => $checks,
]);
$this->info('Heartbeat sent.');
}
}routes/console.php (Laravel 11+)
Schedule::command('heartbeat:send')->everyFiveMinutes();config/services.php
'bluemonitor' => [
'key' => env('BLUEMONITOR_API_KEY'),
],.env
BLUEMONITOR_API_KEY=bm_your_api_keyStatus badge
Blade template
<a href="https://www.bluemonitor.org/status/your-domain-com">
<img
src="https://www.bluemonitor.org/api/badge/your-domain-com"
alt="Status on BlueMonitor"
height="36"
/>
</a>Markdown (README.md)
[](https://www.bluemonitor.org/status/your-domain-com)Bot tracking
PROTrack which search engines, AI crawlers, and social bots visit your app. Add bot detection middleware to report visits to BlueMonitor. Requires a Pro plan.
app/Http/Middleware/TrackBots.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class TrackBots
{
private const BOT_PATTERNS = [
['/Googlebot/i', 'googlebot', 'search_engine'],
['/bingbot/i', 'bingbot', 'search_engine'],
['/GPTBot/i', 'gptbot', 'ai_crawler'],
['/ClaudeBot/i', 'claudebot', 'ai_crawler'],
['/PerplexityBot/i', 'perplexitybot', 'ai_crawler'],
['/Twitterbot/i', 'twitterbot', 'social'],
['/facebookexternalhit/i', 'facebookbot', 'social'],
['/AhrefsBot/i', 'ahrefsbot', 'seo'],
];
public function handle(Request $request, Closure $next)
{
$ua = $request->userAgent() ?? '';
$bot = $this->identifyBot($ua);
if ($bot) {
try {
Http::withToken(config('services.bluemonitor.key'))
->timeout(5)
->post('https://www.bluemonitor.org/api/v1/bot-visits', [
'domain' => 'yourapp.com',
'visits' => [[
'bot_name' => $bot['name'],
'bot_category' => $bot['category'],
'path' => $request->path(),
'user_agent' => $ua,
]],
]);
} catch (\Exception $e) {}
}
return $next($request);
}
private function identifyBot(string $ua): ?array
{
foreach (self::BOT_PATTERNS as [$pattern, $name, $cat]) {
if (preg_match($pattern, $ua)) {
return ['name' => $name, 'category' => $cat];
}
}
return null;
}
}
// Register in bootstrap/app.php (Laravel 11+):
// ->withMiddleware(function (Middleware $middleware) {
// $middleware->web(append: [TrackBots::class]);
// })View results in your dashboard under Bot Tracking.
Using an AI coding tool?
Paste this URL in Claude, Cursor, or Copilot and it will set up monitoring for your Laravel app automatically.
https://www.bluemonitor.org/llm-laravel.txtNext steps
- API Reference — explore all endpoints
- Badge Generator — customize your badge