PHPackages                             abirhossain/laravel-query-watchdog - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. abirhossain/laravel-query-watchdog

ActiveLibrary[Database &amp; ORM](/categories/database)

abirhossain/laravel-query-watchdog
==================================

Production-safe Laravel query performance monitor with fingerprinting, aggregation, alerts, and dashboard insights.

v0.2.0(1mo ago)00MITPHPPHP ^8.1

Since Apr 5Pushed 1mo agoCompare

[ Source](https://github.com/Abir784/laravel-query-watchdog)[ Packagist](https://packagist.org/packages/abirhossain/laravel-query-watchdog)[ RSS](/packages/abirhossain-laravel-query-watchdog/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

Laravel Query Watchdog
======================

[](#laravel-query-watchdog)

Laravel Query Watchdog is a Laravel 10-13 compatible package for monitoring slow database queries in production-like environments.

Features
--------

[](#features)

- Slow query capture
- SQL fingerprinting
- Aggregated percentile metrics
- Alert engine with cooldown and notification channels
- Regression detection by app version (p95 comparison)
- N+1 burst heuristic detection by request fingerprint repetition
- Dashboard with auth gate support
- One-command package installer

Installation
------------

[](#installation)

```
composer require abirhossain/laravel-query-watchdog
```

```
php artisan query-watchdog:install --migrate
```

Quick Start
-----------

[](#quick-start)

1. Enable query monitoring and alerts in `.env`.
2. Configure dashboard access with allowed emails or a custom authorizer.
3. Generate traffic and open `/query-watchdog`.

Example `.env`:

```
QUERY_WATCHDOG_ENABLED=true
QUERY_WATCHDOG_SLOW_QUERY_MS=200
QUERY_WATCHDOG_SAMPLE_RATE=0.02

QUERY_WATCHDOG_ALERTS_ENABLED=true
QUERY_WATCHDOG_ALERT_CHANNELS=log,slack
QUERY_WATCHDOG_ALERT_COOLDOWN_MINUTES=30
QUERY_WATCHDOG_REGRESSION_MULTIPLIER=2.0
QUERY_WATCHDOG_MIN_REGRESSION_MS=150
QUERY_WATCHDOG_ANALYSIS_WINDOW_MINUTES=60
QUERY_WATCHDOG_MIN_SAMPLES=20

QUERY_WATCHDOG_N_PLUS_ONE_ENABLED=true
QUERY_WATCHDOG_N_PLUS_ONE_MIN_REPETITIONS=12

QUERY_WATCHDOG_DASHBOARD_ALLOWED_EMAILS=dev1@company.com,dev2@company.com
QUERY_WATCHDOG_ALERT_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXX/YYY/ZZZ
```

Notification Channel Abstraction
--------------------------------

[](#notification-channel-abstraction)

Channels are configured using `QUERY_WATCHDOG_ALERT_CHANNELS`.

- `log`
- `mail` (requires `QUERY_WATCHDOG_ALERT_MAIL_TO`)
- `slack` (requires `QUERY_WATCHDOG_ALERT_SLACK_WEBHOOK_URL`)

You can add custom channels by extending the dispatcher map in your app via container rebinding.

Dashboard Authorization Gate
----------------------------

[](#dashboard-authorization-gate)

By default, dashboard routes are protected by:

- `web`
- `auth`
- `can:viewQueryWatchdog`

The package defines the `viewQueryWatchdog` gate and grants access when either:

1. app environment is local and `QUERY_WATCHDOG_DASHBOARD_ALLOW_LOCAL=true`
2. authenticated user email is listed in `QUERY_WATCHDOG_DASHBOARD_ALLOWED_EMAILS`
3. custom authorizer class (invokable) returns `true`

Production Tuning Defaults
--------------------------

[](#production-tuning-defaults)

Recommended starting values:

- `QUERY_WATCHDOG_SLOW_QUERY_MS=250`
- `QUERY_WATCHDOG_SAMPLE_RATE=0.01`
- `QUERY_WATCHDOG_ALERT_COOLDOWN_MINUTES=30`
- `QUERY_WATCHDOG_REGRESSION_MULTIPLIER=2.0`
- `QUERY_WATCHDOG_MIN_SAMPLES=25`
- `QUERY_WATCHDOG_N_PLUS_ONE_MIN_REPETITIONS=15`
- `QUERY_WATCHDOG_RAW_RETENTION_DAYS=14`
- `QUERY_WATCHDOG_AGG_RETENTION_DAYS=90`

Maintenance
-----------

[](#maintenance)

Prune old records:

```
php artisan query-watchdog:prune
```

Dashboard Column Reference
--------------------------

[](#dashboard-column-reference)

### Recent Fingerprints

[](#recent-fingerprints)

ColumnMeaningHashShort prefix of the fingerprint hash that identifies a normalized query shape. Click to open detail view.Last SeenRelative time since this fingerprint was last captured.Latest DurationDuration in milliseconds of the most recent event for this fingerprint.Route / CommandLaravel route name or console command name associated with the latest event. `n/a` means context was not available.### Top Fingerprints

[](#top-fingerprints)

ColumnMeaningFingerprintFingerprint hash preview and a truncated canonical SQL shape for grouped queries.OperationSQL operation type detected from normalized SQL (`select`, `insert`, `update`, `delete`, or `other`).CountTotal sampled/captured event count for this fingerprint in the selected window.Max p95 (ms)Highest p95 latency bucket recorded in the selected window. Useful for tail-latency monitoring.Max duration (ms)Single highest event duration recorded for this fingerprint in the selected window.### Fingerprint Detail: Recent Aggregates

[](#fingerprint-detail-recent-aggregates)

ColumnMeaningBucketMinute-level aggregation timestamp for the metric row.CountNumber of events captured in that bucket.SlowNumber of events in that bucket with duration greater than or equal to `QUERY_WATCHDOG_SLOW_QUERY_MS`.p50Median latency (50th percentile) for events in the bucket.p9595th percentile latency for events in the bucket.p9999th percentile latency for events in the bucket.AvgArithmetic mean latency for events in the bucket.MaxHighest single-event latency in the bucket.### Fingerprint Detail: Recent Events

[](#fingerprint-detail-recent-events)

ColumnMeaningTimeTimestamp when the query event was captured.DurationSingle event duration in milliseconds.ConnectionDatabase connection name used by the query.Route / CommandRoute or command context tied to this event.SQLTruncated raw SQL captured for that event.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/109214535?v=4)[Shukhi Coder](/maintainers/AbirCodes)[@AbirCodes](https://github.com/AbirCodes)

---

Top Contributors

[![AbirCodes](https://avatars.githubusercontent.com/u/109214535?v=4)](https://github.com/AbirCodes "AbirCodes (3 commits)")

---

Tags

laravelmonitoringdatabaseperformancequery

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/abirhossain-laravel-query-watchdog/health.svg)

```
[![Health](https://phpackages.com/badges/abirhossain-laravel-query-watchdog/health.svg)](https://phpackages.com/packages/abirhossain-laravel-query-watchdog)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[tpetry/laravel-query-expressions

Database-independent Query Expressions as a replacement to DB::raw calls

359436.5k2](/packages/tpetry-laravel-query-expressions)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[sarfraznawaz2005/indexer

Laravel package to monitor SELECT queries and offer best possible INDEX fields.

562.7k](/packages/sarfraznawaz2005-indexer)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
