Export benchmark metrics to PostgreSQL with TimescaleDB for advanced analysis
Chainbench can export detailed benchmark metrics to PostgreSQL with the TimescaleDB extension, enabling advanced time-series analysis, long-term storage, and custom visualization of your load testing results.
All PostgreSQL connection parameters (host, port, username, password) are required when using the --timescale flag. The benchmark will exit with an error if any are missing.
Chainbench validates the configuration on startup:
if timescale and any(pg_arg is None for pg_arg in (pg_host, pg_port, pg_username, pg_password)): click.echo( "PG connection parameters are required " "when --timescale flag is used: pg_host, pg_port, pg_username, pg_password" ) sys.exit(1)
Missing parameters will cause immediate exit before the test begins.
CREATE TABLE IF NOT EXISTS user_count ( time TIMESTAMPTZ NOT NULL, test_run_id TEXT, user_count INTEGER);SELECT create_hypertable('user_count', 'time', if_not_exists => TRUE);
SELECT method, AVG(response_time) as avg_response_ms, PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY response_time) as p95_response_ms, COUNT(*) as total_requestsFROM request_metricsWHERE test_run_id = 'your-run-id'GROUP BY methodORDER BY avg_response_ms DESC;
SELECT time_bucket('1 minute', time) as bucket, method, AVG(response_time) as avg_response_ms, COUNT(*) as requests_per_minuteFROM request_metricsWHERE test_run_id = 'your-run-id'GROUP BY bucket, methodORDER BY bucket;
SELECT method, exception, COUNT(*) as error_countFROM request_metricsWHERE test_run_id = 'your-run-id' AND success = falseGROUP BY method, exceptionORDER BY error_count DESC;
Compare performance across different configurations:
SELECT test_run_id, AVG(response_time) as avg_response_ms, COUNT(*) as total_requests, SUM(CASE WHEN success THEN 1 ELSE 0 END)::FLOAT / COUNT(*) * 100 as success_rateFROM request_metricsWHERE time > NOW() - INTERVAL '7 days'GROUP BY test_run_idORDER BY avg_response_ms;
SELECT time_bucket('30 seconds', time) AS time, method as metric, AVG(response_time) as valueFROM request_metricsWHERE $__timeFilter(time) AND test_run_id = '$test_run_id'GROUP BY time_bucket('30 seconds', time), methodORDER BY time;