TimescaleDB
TimescaleDB is an open-source database extenion designed to make SQL scalable for time-series data. It is engineered up from PostgreSQL and packaged as a PostgreSQL extension, providing automatic partitioning across time and space (partitioning key), as well as full SQL support.
Using Reporting Sinks extension for TimescaleDB, you can store NBomber metrics into TimescaleDB and analyze your performance results with NBomber.MetricsUI (in development) or Grafana.
This package is experimental and might be subject to breaking API changes in the future. While we intend to keep experimental packages as stable as possible, we may need to introduce breaking changes.
To start working with NBomber.Sinks.Timescale package you should install it:
dotnet add package NBomber.Sinks.Timescale
Also, the source code is available on Github.
Integrating with TimescaleDB
The simple way to run TimescaleDB is via Docker. By this link, you can find a docker-compose.yaml to run it.
Configuring TimescaleDB Sink via JSON Config
To configure TimescaleDB Sink we will use JSON Infrastracture Config file
{
"TimescaleDbSink": {
"ConnectionString": "Host=localhost;Port=5432;Database=metricsdb;Username=timescaledb;Password=timescaledb;Pooling=true;Maximum Pool Size=300;"
}
}
Now you should load this "infra-config.json" file.
var timescaleDbSink = new TimescaleDbSink();
var scenario = Scenario.Create("scenario", async context => { ... });
NBomberRunner
.RegisterScenarios(scenario)
.WithReportingInterval(TimeSpan.FromSeconds(5))
.WithReportingSinks(timescaleDbSink)
.LoadInfraConfig("infra-config.json");
You can find the complete example by this link.
During the load test run, NBomber's metrics will appear in TimescaleDB, and you can query them.
Connecting to TimescaleDB via code
You might have a situation that requires you to connect to TimescaleDB via code.
var timescaleDbSink = new TimescaleDbSink("Host=localhost;Port=5432;Database=metricsdb;Username=timescaledb;Password=timescaledb;Pooling=true;Maximum Pool Size=300;");
Saving custom metrics to TimescaleDB
This feature is in development...