mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-27 21:57:42 +02:00
Add 5 new commands powered by Prometheus/VictoriaMetrics: - !system: Mac Mini status (CPU, RAM, Disk, Uptime, Load) - !services: Backend service health (UP/DOWN) - !traffic: HTTP traffic & latency per service - !db: PostgreSQL & Redis status - !growth: User growth statistics New modules: - PrometheusService: Query Prometheus/VictoriaMetrics API - InfrastructureService: Generate infrastructure reports Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
85 lines
1.8 KiB
Markdown
85 lines
1.8 KiB
Markdown
# Matrix Stats Bot - Claude Code Guidelines
|
|
|
|
## Overview
|
|
|
|
Matrix Stats Bot delivers analytics from Umami (self-hosted) via Matrix. GDPR-compliant replacement for telegram-stats-bot.
|
|
|
|
## Tech Stack
|
|
|
|
- **Framework**: NestJS 10
|
|
- **Matrix**: matrix-bot-sdk
|
|
- **Analytics**: Umami API + Prometheus/VictoriaMetrics
|
|
- **Scheduling**: @nestjs/schedule
|
|
|
|
## Commands
|
|
|
|
```bash
|
|
pnpm install
|
|
pnpm start:dev # Development with hot reload
|
|
pnpm build # Production build
|
|
pnpm type-check # TypeScript check
|
|
```
|
|
|
|
## Matrix Commands
|
|
|
|
### Analytics (Umami)
|
|
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `!stats` | Overview of all apps (30 days) |
|
|
| `!today` | Today's statistics |
|
|
| `!week` | This week's statistics |
|
|
| `!realtime` | Active visitors right now |
|
|
|
|
### Infrastructure (Prometheus)
|
|
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `!system` | Mac Mini status (CPU, RAM, Disk, Uptime) |
|
|
| `!services` | Backend service health (UP/DOWN) |
|
|
| `!traffic` | HTTP traffic & latency per service |
|
|
| `!db` | PostgreSQL & Redis status |
|
|
| `!growth` | User growth statistics |
|
|
|
|
### General
|
|
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `!status` | Account status |
|
|
| `!help` | Show available commands |
|
|
|
|
## Scheduled Reports
|
|
|
|
| Report | Schedule | Timezone |
|
|
|--------|----------|----------|
|
|
| Daily | 09:00 | Europe/Berlin |
|
|
| Weekly | Monday 09:00 | Europe/Berlin |
|
|
|
|
## Environment Variables
|
|
|
|
```env
|
|
PORT=3312
|
|
TZ=Europe/Berlin
|
|
|
|
# Matrix
|
|
MATRIX_HOMESERVER_URL=http://localhost:8008
|
|
MATRIX_ACCESS_TOKEN=syt_xxx
|
|
MATRIX_REPORT_ROOM_ID=!roomid:mana.how
|
|
|
|
# Umami
|
|
UMAMI_API_URL=http://umami:3000
|
|
UMAMI_USERNAME=admin
|
|
UMAMI_PASSWORD=xxx
|
|
|
|
# Prometheus / VictoriaMetrics
|
|
PROMETHEUS_URL=http://victoriametrics:8428
|
|
|
|
# Database (for user counts)
|
|
DATABASE_URL=postgresql://...
|
|
```
|
|
|
|
## Health Check
|
|
|
|
```bash
|
|
curl http://localhost:3312/health
|
|
```
|