Watchtower Laravel agent 1.1.1 — open-source APM instrumentation for Laravel that sends telemetry only to your Watchtower instance.
This project is derived from laravel/nightwatch v1.30.0 (MIT). It does not connect to Laravel’s hosted Nightwatch service. Composer authors are Watchtower; Nightwatch attribution lives in LICENSE.md and NOTICE.md.
| Package version | 1.1.1 (version.txt) |
| Git branch | 1.x |
| Wire protocol | watchtower / protocol_version 2 |
| PHP | 8.2–8.5 |
| Laravel | 10–13 |
Documentation
- Architecture — SDK, sidecar, platform
- Protocol — frames, HELLO/WELCOME, session, sequence, batch limits
- Fork and 1.0.0 scope — what we kept, what we own, what is deferred
- Development — test, lint, CI, phar, Docker
- Changelog
- Hooks Laravel (HTTP, queue, schedule, mail, cache, queries, exceptions, …).
- Sensors turn those events into records (existing
t+ field shapes). - The package opens TCP to a local sidecar (
WATCHTOWER_INGEST_URI, default127.0.0.1:2407) and speaks the Watchtower session protocol (not Nightwatchv1:tokenHash:payload). - The sidecar authenticates to
{WATCHTOWER_BASE_URL}/api/agent-authand forwards batches to the ingest URL in that response.
App --Watchtower frames--> sidecar --HTTPS--> Watchtower platform
composer require watchtowerapm/agentPublish config if you want a file in the app:
php artisan vendor:publish --tag=watchtower-configWATCHTOWER_ENABLED=true
WATCHTOWER_TOKEN=
WATCHTOWER_INGEST_URI=127.0.0.1:2407| Variable | Required | Purpose |
|---|---|---|
WATCHTOWER_TOKEN |
Yes for sidecar + HELLO hash | Platform bearer token |
WATCHTOWER_BASE_URL |
No | Platform origin. Defaults to https://api.watchtowers.cloud; set it only for a self-hosted or staging platform |
WATCHTOWER_INGEST_URI |
No | Where the app sends frames / sidecar listens |
WATCHTOWER_REMOTE_SETTINGS |
No | Default true: apply sampling and filters set in the Watchtower panel (agent writes bootstrap/cache/watchtower-settings.php) |
WATCHTOWER_ENABLED |
No | Default true |
WATCHTOWER_DEPLOY |
For watchtower:deploy |
Deploy identifier |
Sampling, filtering, and redaction: config/watchtower.php and configure-watchtower.
Optional logs:
LOG_CHANNEL=watchtower
# or
LOG_STACK=watchtower,single
LOG_CHANNEL=stackThe Laravel process is not the sidecar. Run one sidecar per host (or container) that should accept local frames:
php artisan watchtower:agentIf agent/build/agent.phar exists, that binary is used; otherwise agent/src/agent.php. After protocol changes, use a rebuilt phar (CI commits it on 1.x).
Docker image from this repo:
docker build -f agent/Dockerfile -t watchtower-agent .
docker run --rm \
-e WATCHTOWER_TOKEN \
-p 127.0.0.1:2407:2407 \
watchtower-agentHealth: php artisan watchtower:status or php agent/watchtower-status (needs WATCHTOWER_TOKEN).
Deploy notification (HTTPS to the platform, not the local protocol):
php artisan watchtower:deployFraming: {byte_length}\\n{json}.
HELLO (protocol=watchtower, protocol_version=2, nonce, mac)
→ WELCOME (session_id, max_batch=500, nonce, mac)
→ telemetry_batch | ping (session_id, sequence=1, mac)
→ ACK
Every message is signed with HMAC-SHA256, using a key derived from the full WATCHTOWER_TOKEN (the token never crosses the socket); batch records are covered by an xxh128 digest inside the signature, to keep the cost per request low. Each side sends a fresh nonce, so a recorded exchange can't be replayed, and the app sends nothing until the sidecar has proved it holds the same token. The sidecar also rejects mismatched session, sequence ≠ 1, batch_version ≠ 2, and batches larger than 500. Keep the listen address on localhost or a private network anyway. Details: docs/protocol.md.
| Path | Role |
|---|---|
src/ |
Laravel package |
agent/ |
Sidecar, Docker, phar build |
tests/ |
Package tests |
agent/tests/ |
Sidecar tests |
docs/ |
Protocol and contributor docs |
You do not need a real Watchtower in GitHub (or locally) to run the suite.
PHPUnit uses fixture WATCHTOWER_TOKEN / https://watchtower.test. Tests that would call a live /api/agent-auth skip when the URL is that fixture.
composer install
composer test
cd agent && composer install && composer testLint: vendor/bin/pint --test and vendor/bin/phpstan at the repo root and under agent/.
GitHub Actions (.github/workflows/pull_request.yml): Pint, PHPStan, phar build, package matrix (PHP × Laravel × prefer-lowest), agent tests, Docker health check. Secrets are optional; they default to the same fixtures.
Full contributor workflow: docs/development.md.
- 1.0.0 is the first Watchtower package release (this is not Nightwatch 2.x and not “protocol 2”).
- Bump
version.txtandcomposer.jsontogether. protocol_version/batch_versionchange only when the wire contract changes (see protocol docs).
The code is MIT-licensed (see below). Using it with the Watchtower service is also governed by the Watchtower Terms of Service, which you accept when you create a Watchtower account. Under those terms, notwithstanding the MIT license, you agree to:
- use the agent only with the Watchtower service;
- send the monitoring data it collects only to Watchtower;
- install it only on systems you own or operate, or are authorized to monitor.
The terms also forbid using the service to build a competing product, benchmarking it other than for internal evaluation, and reverse engineering its non-open-source parts.
MIT. Portions derived from Laravel Nightwatch:
Copyright (c) Taylor Otwell
See LICENSE.md and NOTICE.md.