An open API service indexing awesome lists of open source software.

https://github.com/simulieren/adonisjs-server-stats

Laravel Telescope-inspired dev toolbar and real-time server monitor for AdonisJS v6
https://github.com/simulieren/adonisjs-server-stats

adonisjs adonisjs-package debug dev-toolbar devtools metrics server-monitoring typescript

Last synced: 12 days ago
JSON representation

Laravel Telescope-inspired dev toolbar and real-time server monitor for AdonisJS v6

Awesome Lists containing this project

README

          

# adonisjs-server-stats

[![npm version](https://img.shields.io/npm/v/adonisjs-server-stats.svg)](https://www.npmjs.com/package/adonisjs-server-stats)
[![npm downloads](https://img.shields.io/npm/dm/adonisjs-server-stats.svg)](https://www.npmjs.com/package/adonisjs-server-stats)
[![license](https://img.shields.io/npm/l/adonisjs-server-stats.svg)](https://github.com/simulieren/adonisjs-server-stats/blob/main/LICENSE)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.9+-blue.svg)](https://www.typescriptlang.org/)
[![AdonisJS](https://img.shields.io/badge/AdonisJS-v6-5A45FF.svg)](https://adonisjs.com/)
[![AdonisJS](https://img.shields.io/badge/AdonisJS-v7-5A45FF.svg)](https://adonisjs.com/)

A Laravel Telescope-inspired dev toolbar and real-time server monitor for **AdonisJS v6 & v7**.

Drop a single Edge tag into your layout and get a live stats bar showing CPU, memory, requests/sec, database pool, Redis, queues, and logs -- plus a full debug toolbar with SQL query inspection, event tracing, route listing, live log tailing, and custom panels.

Zero frontend dependencies. Zero build step. Just `@serverStats()` and go.

**New (alpha):** Native [React & Vue components](#react--vue-inertiajs--alpha) for Inertia.js apps — same features, framework-native.

![adonisjs-server-stats demo](https://raw.githubusercontent.com/simulieren/adonisjs-server-stats/main/screenshots/demo.gif)

## Screenshots

**Debug toolbar** -- expandable panels for deep inspection:

| Queries | Events |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ![Queries panel showing SQL queries with duration and model info](https://raw.githubusercontent.com/simulieren/adonisjs-server-stats/main/screenshots/debug-queries.png) | ![Events panel showing application events with payload data](https://raw.githubusercontent.com/simulieren/adonisjs-server-stats/main/screenshots/debug-events.png) |

| Routes | Logs |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![Routes panel showing all registered routes with handlers](https://raw.githubusercontent.com/simulieren/adonisjs-server-stats/main/screenshots/debug-routes.png) | ![Logs panel with level filtering and request ID correlation](https://raw.githubusercontent.com/simulieren/adonisjs-server-stats/main/screenshots/debug-logs.png) |

| Emails (custom pane) |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![Emails panel showing sent emails with delivery status](https://raw.githubusercontent.com/simulieren/adonisjs-server-stats/main/screenshots/debug-emails.png) |

## Features

- **Live stats bar** -- CPU, memory, event loop lag, HTTP throughput, DB pool, Redis, queues, logs
- **Debug toolbar** -- SQL queries, events, emails, routes, logs with search and filtering
- **Request tracing** -- per-request waterfall timeline showing DB queries, events, and custom spans
- **Custom panes** -- add your own tabs (webhooks, emails, cache, anything) with a simple config
- **Full-page dashboard** -- dedicated page at `/__stats` with overview cards, charts, request history, query analysis, EXPLAIN plans, cache/queue/config inspection, and saved filters
- **Pluggable collectors** -- use built-in collectors or write your own
- **Visibility control** -- show only to admins, specific roles, or in dev mode
- **SSE broadcasting** -- real-time updates via AdonisJS Transmit
- **Prometheus export** -- expose all metrics as Prometheus gauges
- **Self-contained** -- inline HTML/CSS/JS Edge tag, no external assets
- **React & Vue support (alpha)** -- native Inertia.js components with the same features as Edge
- **Graceful degradation** -- missing optional dependencies are handled automatically
- **Theme support** -- dark and light themes across dashboard, debug panel, and stats bar with system preference detection and manual toggle

## Installation

```bash
npm install adonisjs-server-stats
```

## Quick Start

### 1. Register providers

```ts
// adonisrc.ts
providers: [
() => import('adonisjs-server-stats/provider'),
]
```

### 2. Register middleware

```ts
// start/kernel.ts
server.use([() => import('adonisjs-server-stats/middleware')])
```

### 3. Create config

```ts
// config/server_stats.ts
import { defineConfig } from 'adonisjs-server-stats'

export default defineConfig({})
```

That's it -- zero config required. Collectors are auto-detected from your installed packages (Lucid, Redis, BullMQ, etc.) and enabled automatically. All other options have sensible defaults.

**Common setup** -- add access control and enable the toolbar/dashboard:

```ts
// config/server_stats.ts
import { defineConfig } from 'adonisjs-server-stats'

export default defineConfig({
authorize: (ctx) => ctx.auth?.user?.role === 'admin',
toolbar: true,
dashboard: true,
})
```

> **Tip: Enable query capture** -- Lucid only emits `db:query` events when `debug: true` is set on the connection. Without it, the Queries panel will be empty.
>
> ```ts
> // config/database.ts
> connections: {
> postgres: {
> client: 'pg',
> debug: app.inDev, // ← enables query capture in development
> connection: { ... },
> },
> }
> ```

**Full control** -- override auto-detection with explicit collectors:

```ts
// config/server_stats.ts
import env from '#start/env'
import { defineConfig } from 'adonisjs-server-stats'
import {
processCollector,
systemCollector,
httpCollector,
dbPoolCollector,
redisCollector,
queueCollector,
logCollector,
appCollector,
} from 'adonisjs-server-stats/collectors'

export default defineConfig({
pollInterval: 3000,
collectors: [
processCollector(),
systemCollector(),
httpCollector({ maxRecords: 10_000 }),
dbPoolCollector({ connectionName: 'postgres' }),
redisCollector(),
queueCollector({
queueName: 'default',
connection: {
host: env.get('QUEUE_REDIS_HOST'),
port: env.get('QUEUE_REDIS_PORT'),
password: env.get('QUEUE_REDIS_PASSWORD'),
},
}),
logCollector(),
appCollector(),
],
})
```

### 4. Render the stats bar

That's it for setup -- **all API routes are auto-registered by the package**. No controllers or route definitions needed. On startup you'll see:

```
[server-stats] auto-registered routes: /admin/api/server-stats, /admin/api/debug/*, /__stats/*
```

All routes are gated by the `authorize` callback if configured (see [Visibility Control](#visibility-control-authorize)).

**Edge** (add before `