Skip to main content
Nightwatch observes your Laravel application as it runs, capturing events and data that occur during execution. The package follows a predefined flow that determines what data is collected and how it’s processed, ensuring a consistent and predictable experience.
  1. Observation: The agent monitors your Laravel application, observing requests, commands, scheduled tasks, and all the events they trigger, e.g. queries, jobs, exceptions, etc.
  2. Sampling: For entry points (requests, commands, and scheduled tasks), sampling determines whether the entire trace should be collected based on configured sample rates. If a request is sampled, all related events within that request lifecycle are captured.
  3. Filtering: Once a trace has been selected for collection, filters can be applied with scalpel-like precision to exclude specific events based on criteria. Filters allow you to make granular decisions about individual events, determining whether they should be collected or excluded.
  4. Redaction: After data has passed through sampling and filtering gates, redaction methods allow you to manipulate the data being collected. This enables you to obfuscate sensitive information, modify user details, or add contextual information to records.

Sampling

Sampling controls the rate at which entry points are collected. Entry points are the initial events that trigger a trace. These are requests, commands, and scheduled tasks. When an entry point is sampled in, the entire trace (including all related events like queries, jobs, and exceptions) is captured. If an entry point is sampled out, all related events are not captured. By default, Nightwatch has a sample rate of 100% for all entry points, resulting in unrestricted data collection and complete visibility out of the box. We recommend everyone to apply some level of Sampling to reduce the volume of data collected. For new applications, we recommend starting with the global sample rate of 0.1 or lower on requests to build an understanding of your application’s profile and adjusting the rate based on your observations.
NIGHTWATCH_EXCEPTION_SAMPLE_RATE=1.0
NIGHTWATCH_COMMAND_SAMPLE_RATE=1.0
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1 # Recommended
In addition to global sample rates, there are a number of advanced sampling methods, including route-based sampling, package route sampling and dynamic sampling. Please see the following guides for more detail for each specific event type:
Event TypeDescription
RequestsConfigure sampling rates for Requests with advanced sampling methods
CommandsConfigure sampling for Artisan commands executed in your application
ExceptionsConfigure sampling for exceptions observed in your application

Filtering

Filtering allows you to exclude specific events from collection with precision. Once a trace has been selected for collection through sampling, filters can be applied to individual events based on criteria, allowing you to make granular decisions about what should be collected or excluded. Please see the following guides for how to apply filtering to the following event types:
Event TypeDescription
QueriesFilter database queries based on SQL patterns or other criteria
CacheExclude cache events by key patterns or specific cache operations
MailFilter mail events based on subject, recipient, or other attributes
NotificationsExclude notification events by channel, type, or other criteria
Outgoing RequestsFilter outgoing HTTP requests based on URL patterns or other attributes
JobsExclude specific jobs from collection based on job class or other criteria

Redaction

Redaction allows you to manipulate collected data before it’s sent to Nightwatch. After data has passed through sampling and filtering, redaction methods enable you to obfuscate sensitive information, modify user details, or add contextual information to records. Please see the following guides for how to apply redaction to the following event types:
Event TypeDescription
RequestsRedact URLs, IP addresses, headers, and payload data from requests
QueriesModify SQL statements to remove or obfuscate sensitive data
CacheRedact cache key names that may contain sensitive information
CommandsModify command arguments to remove sensitive data
MailRedact mail subjects or other mail-related data
Outgoing RequestsModify outgoing request URLs or other request data
ExceptionsRedact sensitive information from exception messages