Skip to main content

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

MetricLabelsDescription
requests_total-Total HTTP requests processed
status_codes_totalstatusResponse count by HTTP status code
errors_totaltypeErrors by type (e.g. timeout, upstream)
cache_hits_totallayerCache hits by layer (memory, disk)
cache_misses_totallayerCache misses by layer (memory, disk)

Histograms

MetricLabelsDescription
request_duration_seconds-Full request latency in seconds
request_span_duration_secondsspanRequest latency broken down by span
buffer_size_bytes-Download buffer sizes in bytes

Gauges

MetricLabelsDescription
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_entrieslayerCurrent cache entry count by layer

Example Prometheus scrape config

scrape_configs:
- job_name: previewproxy
static_configs:
- targets: ["localhost:9464"]