Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/guides/monitoring.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Monitoring

A scaffolded chapkit service exposes `/metrics` (Prometheus format) by default — `chapkit init` calls `.with_monitoring()` on the builder. This guide shows how to scrape that endpoint with Prometheus and surface it in Grafana, either as a local dev stack or an overlay alongside an existing chapkit service.
Every chapkit service exposes `/metrics` (Prometheus format) by default; monitoring is on unless the builder calls `.with_monitoring(enabled=False)`. This guide shows how to scrape that endpoint with Prometheus and surface it in Grafana, either as a local dev stack or an overlay alongside an existing chapkit service.

## What you get out of the box

Expand Down Expand Up @@ -88,12 +88,12 @@ If your model is registered with chap-core, you generally don't need to run a lo

## Disabling `/metrics`

If you actively don't want a metrics endpoint exposed (e.g. internal-only deployment with strict surface restrictions), remove the `.with_monitoring()` call from your generated `main.py`:
If you actively don't want a metrics endpoint exposed (e.g. internal-only deployment with strict surface restrictions), turn monitoring off in your generated `main.py`. Since servicekit 3, monitoring is on by default, so removing the `.with_monitoring()` call is not enough:

```python
app = (
MLServiceBuilder(...)
# .with_monitoring() <- remove this line
.with_monitoring(enabled=False)
.with_registration()
.build()
)
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/web-console.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ served straight from the installed package with no Node.js runtime required.
| **Predict** | Submit `$predict` jobs from a trained model, with the same `$validate` gating and sample-data generator. |
| **Endpoints** | Every HTTP operation exposed by the service, parsed from `/openapi.json`, grouped by tag and filterable. Links out to Swagger. |
| **System** | Runtime information (host, platform, Python, timezone) and the static apps mounted by the service. |
| **Monitoring** | Live, in-memory view of the service's Prometheus `/metrics` (request rate, latency, active requests, GC, ML job counters, and Linux process CPU/memory/FDs), with sparklines, a poll-interval control, and a raw-metric explorer. Shown only when the service enables `.with_monitoring()` (detected from the OpenAPI spec); nothing is stored server-side. |
| **Monitoring** | Live, in-memory view of the service's Prometheus `/metrics` (request rate, latency, active requests, GC, ML job counters, and Linux process CPU/memory/FDs), with sparklines, a poll-interval control, and a raw-metric explorer. Shown unless the service turns monitoring off with `.with_monitoring(enabled=False)` (detected from the OpenAPI spec); nothing is stored server-side. |

## Seeding a session

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ app = (
- `GET /api/v1/artifacts` - Browse trained models and predictions
- `GET /api/v1/jobs` - Monitor training/prediction jobs
- `GET /health` - Health checks
- `GET /metrics` - Prometheus metrics (with `.with_monitoring()`)
- `GET /metrics` - Prometheus metrics (on by default; `.with_monitoring(enabled=False)` turns it off)

Run with: `fastapi dev your_file.py` → Service ready at `http://localhost:9090`

Expand Down
14 changes: 7 additions & 7 deletions frontend/src/pages/MonitoringPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,21 @@ function buildTiles(snapshots: MetricsSnapshot[]): Tile[] {
const avgLatency = (): number | null => {
if (!latest || !prev) return null
const dc =
(latest.values.get('http_server_duration_milliseconds_count') ?? 0) -
(prev.values.get('http_server_duration_milliseconds_count') ?? 0)
(latest.values.get('http_server_request_duration_seconds_count') ?? 0) -
(prev.values.get('http_server_request_duration_seconds_count') ?? 0)
const ds =
(latest.values.get('http_server_duration_milliseconds_sum') ?? 0) -
(prev.values.get('http_server_duration_milliseconds_sum') ?? 0)
return dc > 0 ? ds / dc : null
(latest.values.get('http_server_request_duration_seconds_sum') ?? 0) -
(prev.values.get('http_server_request_duration_seconds_sum') ?? 0)
return dc > 0 ? (ds / dc) * 1000 : null
}

return [
{
key: 'requests',
label: 'Requests / sec',
value: rateNow('http_server_duration_milliseconds_count'),
value: rateNow('http_server_request_duration_seconds_count'),
format: (v) => formatNumber(v, 2),
series: rateSeries('http_server_duration_milliseconds_count'),
series: rateSeries('http_server_request_duration_seconds_count'),
},
{
key: 'latency',
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"geojson-pydantic>=2.1.1",
"typer>=0.24.2",
"jinja2>=3.1.6",
"servicekit>=2.0.3,<3",
"servicekit>=3.0.0,<4",
"httpx>=0.28.1",
]

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/chapkit/api/apps/console/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chapkit Console</title>
<script type="module" crossorigin src="./assets/index-C4rUuFhx.js"></script>
<script type="module" crossorigin src="./assets/index-BXTIRDCJ.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-HY9NoZeE.css">
</head>
<body>
Expand Down
Loading
Loading