Skip to content

Database Sink

Stores CDEvents in PostgreSQL. The primary sink for CDviz dashboards and analytics — events stored here power DORA metrics, deployment timelines, and artifact tracking in Grafana.

Configuration

toml
[sinks.database]
enabled = true
type = "db"
url = "postgresql://postgres:passwd@localhost:5432/cdviz"
pool_connections_min = 1
pool_connections_max = 10

Parameters

ParameterTypeDefaultDescription
typestringMust be "db"
urlstringPostgreSQL connection URL
enabledbooleantrueEnable/disable this sink
pool_connections_mininteger1Minimum idle connections
pool_connections_maxinteger10Maximum concurrent connections

Database Requirements

The sink calls the store_cdevent stored procedure for every event:

sql
CALL store_cdevent($1);

The CDviz schema provides this procedure. See Database Setup for installation instructions.

PostgreSQL 12+ is required; TimescaleDB is strongly recommended for time-series queries and automatic data retention.

Connection URL

postgresql://[user[:password]@][host][:port][/dbname][?param=value&...]
toml
# Basic
url = "postgresql://cdviz_user:password@localhost:5432/cdviz"

# SSL required (recommended for production)
url = "postgresql://user:pass@host:5432/cdviz?sslmode=require"

# SSL with client certificates
url = "postgresql://user:pass@host:5432/cdviz?sslmode=require&sslcert=client.pem&sslkey=client.key&sslrootcert=ca.pem"

Keep credentials out of config files using the _file suffix (read from a mounted file) or by setting via environment variable (the key need not exist in TOML):

toml
# Read connection URL from a mounted file (Kubernetes Secret, Docker volume, etc.)
[sinks.database]
enabled = true
type = "db"
url_file = "/run/secrets/db_url"
bash
# Or set via environment variable (no TOML entry needed):
export CDVIZ_COLLECTOR__SINKS__DATABASE__URL="postgresql://user:pass@prod-db:5432/cdviz"

Default Configuration

The database sink is included but disabled by default:

toml
[sinks.database]
enabled = false
type = "db"
url = "postgresql://postgres:passwd@localhost:5432/cdviz"
pool_connections_min = 1
pool_connections_max = 10

Enable via config (enabled = true) or environment variable:

bash
CDVIZ_COLLECTOR__SINKS__DATABASE__ENABLED="true" cdviz-collector connect --config config.toml

Pool Sizing

For production deployments:

  • pool_connections_min = 2 keeps warm connections available during quiet periods
  • pool_connections_max should not exceed your PostgreSQL max_connections divided by the number of collector instances
  • For most deployments, the defaults (min=1, max=10) are sufficient