Skip to content

Prometheus metrics

With --enable-metrics, Hardcharger™ collects runtime metrics and serves them in the Prometheus text format at GET /metrics on --metrics-port (9091), a separate plaintext port.

Terminal window
$ curl -s localhost:9091/metrics | grep -E '^hardcharger_(build_info|up_seconds|sessions\{)' | head -3
hardcharger_build_info{…} 1
hardcharger_up_seconds …
hardcharger_sessions{state="…"} …

Keep the port on a private network: --metrics-bind-address (default 0.0.0.0) picks the interface, and --metrics-port 0 turns the HTTP endpoint off while keeping the SQL view.

The same numbers are in hardcharger_metrics(), for administrators and dashboards that speak SQL:

Terminal window
$ HARDCHARGER_PASSWORD='change-me' hardcharger --host localhost --tls=false --username hardcharger --csv --command \
"SELECT name, labels['state'] AS state FROM hardcharger_metrics() WHERE name = 'hardcharger_queue_depth' ORDER BY state"
name,state
hardcharger_queue_depth,active
hardcharger_queue_depth,queued
scrape_configs:
- job_name: hardcharger
scrape_interval: 15s
static_configs:
- targets: ["hardcharger-0.hardcharger:9091", "hardcharger-1.hardcharger:9091"]

In Kubernetes with the Prometheus Operator, a PodMonitor on the metrics port does the same (Docker and Kubernetes).

Alert when Metric
The server restarted uncleanly hardcharger_last_exit_unclean == 1, or increase(hardcharger_unclean_exits_total[1h]) > 0
Health checks fail hardcharger_health_check_status == 0
Statements are being turned away rate(hardcharger_queue_rejected_total[5m]) > 0
Statements wait long for a slot histogram_quantile(0.95, rate(hardcharger_queue_wait_seconds_bucket[5m]))
Errors climb rate(hardcharger_statements_total{status="error"}[5m])
Memory nears DuckDB’s limit hardcharger_duckdb_memory_usage_bytes / hardcharger_duckdb_memory_limit_bytes > 0.9
Sessions near the cap sum(hardcharger_sessions) / hardcharger_session_limit > 0.9 (when max_sessions is set)
Metrics themselves stopped hardcharger_metrics_collection_success == 0, or the scrape is missing (up == 0)

Generated from a running server’s /metrics:

MetricTypeLabelsMeaning
hardcharger_build_infogaugeduckdb_version, server, versionServer build: version, DuckDB version.
hardcharger_concurrency_limitgaugemax_concurrent_statements (0: no queue).
hardcharger_draininggauge1 while the server shuts down.
hardcharger_duckdb_memory_limit_bytesgaugeDuckDB memory_limit in bytes.
hardcharger_duckdb_memory_usage_bytesgaugeMemory DuckDB's buffer manager holds.
hardcharger_duckdb_spill_bytesgaugeSize of DuckDB's temporary (spill) files now.
hardcharger_duckdb_spill_filesgaugeDuckDB's temporary (spill) files now.
hardcharger_duckdb_temp_storage_bytesgaugeTemporary storage DuckDB holds for evicted buffers, from duckdb_memory().
hardcharger_duckdb_threadsgaugeDuckDB threads setting.
hardcharger_health_check_duration_secondsgaugeHow long the last health check took.
hardcharger_health_check_statusgauge1 when the health check passes.
hardcharger_host_cpusgaugeLogical CPUs of the host.
hardcharger_host_memory_bytesgaugePhysical memory of the host.
hardcharger_last_exit_uncleangauge1 if the last run on this database did not stop cleanly (NaN: unknown).
hardcharger_metrics_collection_duration_secondsgaugeHow long the last collection took.
hardcharger_metrics_collection_successgauge1 when the last collection succeeded.
hardcharger_metrics_last_collection_success_secondsgaugeUnix time of the last successful collection.
hardcharger_queue_admin_bypass_totalcounterStatements that skipped the queue.
hardcharger_queue_depthgaugestateStatements holding or waiting for a queue slot.
hardcharger_queue_rejected_totalcounterStatements the queue refused or timed out.
hardcharger_queue_wait_secondshistogramTime statements waited in the queue.
hardcharger_session_limitgaugemax_sessions (0: unlimited).
hardcharger_sessionsgaugestateOpen client sessions, by state.
hardcharger_sessions_opened_totalcounterClient sessions opened.
hardcharger_sessions_reaped_totalcounterClient sessions ended for being idle or killed.
hardcharger_statement_duration_secondshistogramkindClient statement run time, by kind.
hardcharger_statements_activegaugeStatements running now.
hardcharger_statements_totalcounterstatusClient statements finished, by status.
hardcharger_unclean_exits_totalcounterRuns on this database that did not stop cleanly.
hardcharger_up_secondsgaugeSeconds since the server started.
process_open_fdsgaugeOpen file descriptors of the server process.
process_resident_memory_bytesgaugeResident memory of the server process.
process_start_time_secondsgaugeUnix time the server process started.
process_threadsgaugeOperating-system threads of the server process.