You can easily connect all your App compute and Worker clusters by automatically integrating Nightwatch with your app environment.
Configure Nightwatch on Cloud
1
Install Nightwatch package
Install the Laravel Nightwatch package in your application locally using Composer:
Run
composer require laravel/nightwatch
on your local machine to update your composer.json and composer.lock files before deploying.2
Add your Nightwatch token
Add your Nightwatch environment’s
NIGHTWATCH_TOKEN
to your .env
file:You will find this value in your Nightwatch dashboard when you create an application.
3
Configure the agent as a background process
To ensure the Nightwatch agent is always running and sending data, configure it as a background process in your Cloud environment:


- Go to your App cluster in the Cloud dashboard.

Select the App cluster
- Click New background process.

Select “New Background Process”
- Choose Custom worker.

Add a custom worker that runs the `nightwatch:agent` command
- Enter the following command:
- Save your changes and redeploy your application.
If you’re using a dedicated worker cluster, repeat these steps for the worker cluster so it also runs the agent.
4
Monitor the agent
To check the health of the running agent, use the following command:The
nightwatch:status
command will exit with a non-zero status code if there is an error. This command will ensure the agent is able to accept connections and send data to Nightwatch.Use Cloud and Nightwatch logs
To send your logs to both Laravel Cloud Logs and Nightwatch, use Laravel’s log stacks feature. Update your.env
file as shown below to enable logging to both services: