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
[sinks.database]
enabled = true
type = "db"
url = "postgresql://postgres:passwd@localhost:5432/cdviz"
pool_connections_min = 1
pool_connections_max = 10Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
type | string | — | Must be "db" |
url | string | — | PostgreSQL connection URL |
enabled | boolean | true | Enable/disable this sink |
pool_connections_min | integer | 1 | Minimum idle connections |
pool_connections_max | integer | 10 | Maximum concurrent connections |
Database Requirements
The sink calls the store_cdevent stored procedure for every event:
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&...]# 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):
# Read connection URL from a mounted file (Kubernetes Secret, Docker volume, etc.)
[sinks.database]
enabled = true
type = "db"
url_file = "/run/secrets/db_url"# 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:
[sinks.database]
enabled = false
type = "db"
url = "postgresql://postgres:passwd@localhost:5432/cdviz"
pool_connections_min = 1
pool_connections_max = 10Enable via config (enabled = true) or environment variable:
CDVIZ_COLLECTOR__SINKS__DATABASE__ENABLED="true" cdviz-collector connect --config config.tomlPool Sizing
For production deployments:
pool_connections_min = 2keeps warm connections available during quiet periodspool_connections_maxshould not exceed your PostgreSQLmax_connectionsdivided by the number of collector instances- For most deployments, the defaults (
min=1, max=10) are sufficient
Related
- Database Setup (cdviz-db) — install the CDviz schema and TimescaleDB
- Debug Sink — log events to stdout before enabling the database sink
- ClickHouse Sink — alternative analytical database for high-throughput use cases
- DORA Metrics Dashboard — Grafana dashboard powered by stored CDEvents