Nightwatch works automatically with zero configuration. It captures exceptions, queries, HTTP requests, jobs, and more — all out of the box. However, you can customize its behavior using environment variables and optional advanced features like sampling.
Variable | Description | Type | Default |
---|---|---|---|
NIGHTWATCH_TOKEN | Required. Your environment’s API token, used to authenticate the agent. You can find this in your environment settings in the Nightwatch dashboard. | string | |
NIGHTWATCH_ENABLED | Controls whether Nightwatch is active. | boolean | true |
NIGHTWATCH_DEPLOY | Optional identifier for the current deployment or release version. Useful for correlating traces and events to specific deploys. | string | |
NIGHTWATCH_SERVER | Sets the server name or instance identifier that Nightwatch uses when reporting events. Defaults to the system hostname. | string | gethostname() |
NIGHTWATCH_REQUEST_SAMPLE_RATE | Controls the percentage of HTTP requests to sample. Value must be between 0.0 (none) and 1.0 (all). | number | 1.0 |
NIGHTWATCH_COMMAND_SAMPLE_RATE | Controls the percentage of Artisan commands to sample. Value must be between 0.0 and 1.0 . | number | 1.0 |
NIGHTWATCH_EXCEPTION_SAMPLE_RATE | Controls the percentage of exceptions to sample. Value must be between 0.0 and 1.0 . To always capture exceptions, set to 1 . | number | 1.0 |
NIGHTWATCH_INGEST_URI | Sets the host and port that the agent should send events to. Used to route events to a local or remote collector. | string | 127.0.0.1:2407 |
NIGHTWATCH_INGEST_TIMEOUT | Timeout in seconds for the entire send operation. Applies to each batch of events. | number | 0.5 |
NIGHTWATCH_INGEST_CONNECTION_TIMEOUT | Timeout in seconds for establishing a connection with the ingest server. | number | 0.5 |
NIGHTWATCH_INGEST_EVENT_BUFFER | Maximum number of events to buffer before sending. The agent batches events to reduce overhead and improve throughput. | number | 500 |