chore: add bun.lock, docker-compose telemetry network, and METRICS.md documentation

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-07 18:14:35 +07:00
co-authored by Claude Opus 4.8
parent 5a47b0c658
commit 0da578c546
2 changed files with 113 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
# ZeaVis Edu — Metrics Endpoints
This document lists every Prometheus metrics endpoint exposed by the ZeaVis Edu
application stack and the payload each service provides.
---
## Overview
| Service | Host (prod) | Metrics Endpoint | Port (local) |
|-----------------------|-----------------------------------|----------------------------|--------------|
| Web (Vite dev) | `zeavisedu.asepharyana.my.id` | `GET /metrics` | 5173 |
| API (Elysia) | `api-zeavisedu.asepharyana.my.id` | `GET /metrics` | 3000 |
| ML Service (Axum) | `ml-zeavisedu.asepharyana.my.id` | `GET /metrics` | 8000 |
| Prometheus Collector | — | `GET /metrics` (self) | 9090 |
> In production all metrics are scraped by the Prometheus collector running in the
> Telemetry stack. See [`telemetry/prometheus/targets/`](./telemetry/prometheus/targets/)
> for the autodiscovery configuration.
---
## 1. Web App — `GET /metrics`
| Endpoint | Description |
|-------------------|--------------------------------------------------|
| `/metrics` | Vite devserver middleware + clientside snapshot |
### Metrics
| Metric Name | Type | Labels | Description |
|-------------------------------------|---------|-------------------------------|------------------------------------------|
| `zeavis_web_page_views_total` | counter | — | Total page views this session |
| `zeavis_web_vital_bucket` | gauge | `name`, `rating` | Lastseen Web Vitals (CLS, FCP, INP…) |
**Development:** served inline by the Vite plugin `vite-plugin-metrics.ts`.
**Production:** the static frontend serves no `/metrics` endpoint — consider
forwarding the Vite dev server, or use the Telemetry collector to scrape
clientside beacons.
---
## 2. API (Elysia/Bun) — `GET /metrics`
| Endpoint | Description |
|-------------------|--------------------------------------------------|
| `/metrics` | Prometheus text format via `prom-client` |
### Metrics
| Metric Name | Type | Labels | Description |
|--------------------------------------------|-----------|--------------------------------|------------------------------------------|
| `zeavis_api_http_requests_total` | counter | `method`, `path`, `status` | Total HTTP requests |
| `zeavis_api_http_request_duration_seconds` | histogram | `method`, `path` | Request latency buckets |
| `zeavis_api_http_requests_active` | gauge | — | Concurrentlyhandled requests |
| `zeavis_api_classifications_total` | counter | `result` | AI image classifications |
| `zeavis_api_diagnoses_total` | counter | `disease` | Created diagnoses |
| `zeavis_api_auth_operations_total` | counter | `operation`, `success` | Login / register attempts |
| Default Node.js metrics | various | — | CPU, memory, eventloop lag, GC … |
**Source:** `apps/api/src/lib/telemetry.ts`, instrumented in `routes/`.
---
## 3. ML Service (Rust/Axum) — `GET /metrics`
| Endpoint | Description |
|-------------------|--------------------------------------------------|
| `/metrics` | Prometheus text format via `prometheus` crate |
### Metrics
| Metric Name | Type | Labels | Description |
|--------------------------------------------|-----------|--------------------------------|------------------------------------------|
| `zeavis_ml_http_requests_total` | counter | — | Total HTTP requests |
| `zeavis_ml_http_request_duration_seconds` | histogram | — | Request latency buckets |
| `zeavis_ml_http_requests_active` | gauge | — | Concurrentlyhandled requests |
| `zeavis_ml_predictions_total` | counter | — | Successful ONNX predictions |
| `zeavis_ml_model_load_status` | gauge | — | 1 = loaded, 0 = not loaded |
| Process metrics (libc/procfs) | various | — | RSS, CPU, fd count … |
**Source:** `apps/ml-service/src/telemetry.rs`, instrumented in `routes.rs`.
---
## Prometheus AutoDiscovery (Telemetry Stack)
The Telemetry submodule includes a Prometheus instance that uses
`file_sd_configs` to discover targets. Place a target file under
`telemetry/prometheus/targets/` with content such as:
```json
[
{
"targets": ["zeavis-api:3000"],
"labels": { "service": "zeavis-api", "component": "backend" }
},
{
"targets": ["zeavis-ml:8000"],
"labels": { "service": "zeavis-ml", "component": "inference" }
}
]
```
The Prometheus config (in `telemetry/prometheus/prometheus.yml`) will
automatically pick up new files within its 15second scrape interval —
no restart required.