Prometheus
PreviewProxy can expose a Prometheus-compatible metrics endpoint on a dedicated address, separate from the main proxy port.
Enabling the metrics endpoint
Set PP_PROMETHEUS_BIND to the address and port to listen on:
PP_PROMETHEUS_BIND=:9464
Or use the CLI flag:
previewproxy --prometheus-bind :9464
The endpoint is available at GET /metrics on the configured address. If PP_PROMETHEUS_BIND is not set, the metrics endpoint is disabled.
Metric namespace
By default, metrics have no prefix. Set PP_PROMETHEUS_NAMESPACE to add a prefix to all metric names:
PP_PROMETHEUS_NAMESPACE=previewproxy
With this set, requests_total becomes previewproxy_requests_total, and so on for all metrics.
Available metrics
Counters
| Metric | Labels | Description |
|---|---|---|
requests_total | - | Total HTTP requests processed |
status_codes_total | status | Response count by HTTP status code |
errors_total | type | Errors by type (e.g. timeout, upstream) |
cache_hits_total | layer | Cache hits by layer (memory, disk) |
cache_misses_total | layer | Cache misses by layer (memory, disk) |
Histograms
| Metric | Labels | Description |
|---|---|---|
request_duration_seconds | - | Full request latency in seconds |
request_span_duration_seconds | span | Request latency broken down by span |
buffer_size_bytes | - | Download buffer sizes in bytes |
Gauges
| Metric | Labels | Description |
|---|---|---|
workers | - | Configured max concurrent requests |
requests_in_progress | - | Requests currently being handled |
images_in_progress | - | Images currently being processed |
workers_utilization | - | Worker utilization percentage (requests_in_progress / workers * 100) |
buffer_default_size_bytes | - | Calibrated default buffer size in bytes |
buffer_max_size_bytes | - | Calibrated maximum buffer size in bytes |
cache_memory_size_bytes | - | Current memory cache size in bytes |
cache_disk_size_bytes | - | Current disk cache size in bytes |
cache_entries | layer | Current cache entry count by layer |
Example Prometheus scrape config
scrape_configs:
- job_name: previewproxy
static_configs:
- targets: ["localhost:9464"]