coolify/.cursor/skills/configure-nightwatch/reference.md
Andras Bacsai 8aea029782 chore(skills): add Nightwatch and MCP agent skills
Add Nightwatch configuration guidance and MCP development skill docs across agent integrations, and refresh existing Laravel skill references.
2026-06-11 11:58:42 +02:00

3.9 KiB

Nightwatch Configuration Reference

Configuration Summary by Event Type

Event Type Sampling Filtering Redaction
Requests NIGHTWATCH_REQUEST_SAMPLE_RATE, Route middleware Not applicable Headers, payload, URL, IP
Commands NIGHTWATCH_COMMAND_SAMPLE_RATE, Event listener Not applicable Command arguments
Queries Parent context rejectQueries(), NIGHTWATCH_IGNORE_QUERIES SQL statement
Cache Parent context rejectCacheKeys(), rejectCacheEvents(), NIGHTWATCH_IGNORE_CACHE_EVENTS Cache key
Jobs Parent context, Queue::before rejectQueuedJobs() Not applicable
Mail Parent context rejectMail(), NIGHTWATCH_IGNORE_MAIL Subject
Notifications Parent context rejectNotifications(), NIGHTWATCH_IGNORE_NOTIFICATIONS Not applicable
Outgoing Requests Parent context rejectOutgoingRequests(), NIGHTWATCH_IGNORE_OUTGOING_REQUESTS URL
Exceptions NIGHTWATCH_EXCEPTION_SAMPLE_RATE Not applicable Exception message

Production Recommendations

High-Traffic Applications


# Conservative sampling

NIGHTWATCH_REQUEST_SAMPLE_RATE=0.01          # 1% of requests

NIGHTWATCH_COMMAND_SAMPLE_RATE=0.1           # 10% of commands

NIGHTWATCH_EXCEPTION_SAMPLE_RATE=1.0         # Always capture exceptions

# Filter noisy events

NIGHTWATCH_IGNORE_CACHE_EVENTS=true
NIGHTWATCH_IGNORE_QUERIES=true               # Or filter specific queries programmatically

Privacy-Conscious Applications


# Disable sensitive data collection

NIGHTWATCH_CAPTURE_REQUEST_PAYLOAD=false
NIGHTWATCH_REDACT_HEADERS=Authorization,Cookie,Proxy-Authorization,X-XSRF-TOKEN

# Or use redaction in AppServiceProvider


# Sample rates

NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1
NIGHTWATCH_COMMAND_SAMPLE_RATE=1.0
NIGHTWATCH_EXCEPTION_SAMPLE_RATE=1.0

# Filter obvious noise programmatically

# Redact PII as needed


Verification Checklist

After configuration:

  • Sampling rates appropriate for traffic volume
  • Noisy events filtered (cache, certain queries)
  • Sensitive data redacted (PII, tokens, credentials)
  • Exceptions always captured for debugging
  • Test in development with NIGHTWATCH_REQUEST_SAMPLE_RATE=1.0
  • Monitor event quota usage in Nightwatch dashboard

Common Patterns

Filter Health Checks + Reduce Sampling

Route::get('/health', fn() => ['status' => 'ok'])
    ->middleware(Sample::never());

Exclude Internal/Vendor Queries

Nightwatch::rejectQueries(fn($q) =>
    str_contains($q->sql, 'telescope') ||
    str_contains($q->sql, 'pulse')
);

Protect User Data in Cache Keys

Nightwatch::redactCacheEvents(fn($e) =>
    $e->key = preg_replace('/user:\d+/', 'user:***', $e->key)
);