Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Metrics

When the server is enabled, Prometheus metrics are served at GET /metrics in the standard text format (text/plain; version=0.0.4).

Exported metrics

MetricTypeLabelsDescription
pgsense_events_totalcounterdatabaseReplication events processed.
pgsense_findings_totalcounterdatabase, category, severitySensitive data findings produced.
pgsense_alerts_totalcounterchannel, statusAlerts dispatched (status is ok or error).
pgsense_pipeline_reconnects_totalcounterdatabasePipeline reconnection attempts.
pgsense_events_skipped_totalcounterdatabase, reasonEvents skipped by scan filters.
pgsense_dedup_totalcounterdatabase, outcomeDedup decisions (suppressed or passed).
pgsense_config_reloads_totalcounterstatusRule-file reload attempts (ok or error).
pgsense_script_errors_totalcounterrule_idRhai script execution errors.
pgsense_rules_loadedgaugeDetection rules currently loaded.
pgsense_pipeline_connectedgaugedatabasePipeline connection state (1 connected, 0 disconnected).
pgsense_queue_depthgaugedatabasePending batches in the event channel.
pgsense_scan_duration_secondshistogramdatabaseTime spent scanning a single event.
pgsense_batch_sizehistogramdatabaseEvents per pipeline batch.
pgsense_dispatch_duration_secondshistogramdatabaseTime spent dispatching alerts for one event.
pgsense_rule_scan_duration_secondshistogramrule_idPer-rule scan latency. Profiling only.
pgsense_phase_scan_duration_secondshistogramphasePer-phase scan latency (regex, builtin, script). Profiling only.
process_*mixedCPU, memory, open FDs, start time. Linux only.

Profiling

Per-rule and per-phase histograms are gated behind the profiling.enabled flag because they significantly increase metric cardinality:

[profiling]
enabled = true

Tip

Enable profiling temporarily when investigating performance issues (some rule is slowing the scanner down) and disable it in steady-state production. The combined cardinality of pgsense_rule_scan_duration_seconds{rule_id} for hundreds of rules across many time-series buckets adds up quickly.

Suggested alerts

ConditionSuggests
rate(pgsense_pipeline_reconnects_total[5m]) > 0Replication slot or network instability.
pgsense_pipeline_connected == 0 for > 1 minPipeline is down — scanner is producing zero findings for that database.
rate(pgsense_alerts_total{status="error"}[5m]) > 0Some alert channel is failing.
rate(pgsense_config_reloads_total{status="error"}[5m]) > 0A recent rules-file edit failed to compile and was rolled back.
rate(pgsense_script_errors_total[5m]) > 0A Rhai script is failing or timing out.
pgsense_queue_depth rising over timeScanner can’t keep up with replication throughput.

Cardinality budget

The high-cardinality labels are database (one per [[databases]] entry) and rule_id (only on the profiling histogram). Other labels are bounded — typical deployments emit a few hundred series total even with several databases configured.