Skip to content

Configuration

jitterbug.models.config

Configuration models using Pydantic for validation and serialization.

RTT_COLUMN_SYNONYMS = ('values', 'rtt_value', 'rtt', 'latency') module-attribute

RTT column names searched, in this order, when InputConfig.rtt_column is None.

SOURCE_KINDS = ('clickhouse', 'influxdb2', 'influxdb3', 'duckdb') module-attribute

Database back ends a SourceConfig can name.

SECRET_ENV_DEFAULTS = {'clickhouse': 'CLICKHOUSE_PASSWORD', 'influxdb2': 'INFLUXDB_V2_TOKEN', 'influxdb3': 'INFLUX_TOKEN'} module-attribute

Environment variable each back end reads its password or token from by default: the names clickhouse-client, influxdb-client and influxdb3-python use.

SECRET_KEYS = frozenset({'password', 'passwd', 'pwd', 'token', 'access_token', 'api_key', 'apikey', 'api_token', 'secret', 'auth', 'authorization', 'credentials'}) module-attribute

Setting names that would hold a secret; they are rejected in a source profile or URI.

ChangePointDetectionConfig

Bases: BaseModel

Configuration for change point detection algorithms.

Attributes:

Name Type Description
algorithm Literal['bcp', 'ruptures']

Algorithm to use for change point detection.

threshold float

Threshold for change point detection sensitivity.

min_time_elapsed int

Minimum time in seconds between change points.

max_change_points Optional[int]

Maximum number of change points to detect.

JitterAnalysisConfig

Bases: BaseModel

Configuration for jitter analysis methods.

Attributes:

Name Type Description
method Literal['jitter_dispersion', 'ks_test']

Method to use for jitter analysis.

threshold float

Threshold for significance testing.

moving_average_order int

Order of moving average filter (must be even).

moving_iqr_order int

Order of moving IQR filter.

significance_level float

Statistical significance level for tests.

LatencyJumpConfig

Bases: BaseModel

Configuration for latency jump detection.

Attributes:

Name Type Description
threshold float

Threshold for latency jump detection.

DataProcessingConfig

Bases: BaseModel

Configuration for data processing.

Attributes:

Name Type Description
minimum_interval_minutes int

Interval in minutes for computing minimum RTT values.

min_samples_per_interval int

Deprecated, no effect: no minimum number of samples per interval has ever been enforced. Accepted until 3.0, where it is removed.

outlier_detection bool

Deprecated, no effect: no outlier filtering has ever been applied. Accepted until 3.0, where it is removed.

outlier_threshold float

Deprecated, no effect: no outlier filtering has ever been applied. Accepted until 3.0, where it is removed.

Notes

Setting a deprecated option emits one :class:DeprecationWarning and one log warning per option. Dumps (configuration files written by to_file, the metadata.config of result files) leave the deprecated options out unless they were set explicitly.

ClusteringConfig

Bases: BaseModel

Configuration for the non-sequential (clustering) analysis mode.

Each minimum-RTT interval becomes one point with two features, its minimum RTT and the interquartile range of the jitter samples inside it. The points are clustered without regard to time; the cluster with the lowest median minimum RTT is the baseline, and every other cluster is congested when its median minimum RTT exceeds the baseline by more than the latency threshold and the jitter samples of the two clusters differ: a Kolmogorov-Smirnov test is significant at jitter_analysis.significance_level and its statistic is at least min_ks_statistic.

Attributes:

Name Type Description
algorithm Literal['gmm', 'kmeans', 'kmeans_silhouette']

gmm: Gaussian mixture with the number of components chosen by BIC among 1..max_clusters (one component means no congestion signal). kmeans: k-means with n_clusters clusters. kmeans_silhouette: k-means with the number of clusters in 2..max_clusters that maximizes the silhouette score.

n_clusters int

Number of clusters for kmeans.

max_clusters int

Largest number of clusters tried by gmm and kmeans_silhouette.

min_period_intervals int

Temporal smoothing, in intervals: gaps of at most this many non-congested intervals inside congestion are filled, then congested runs of at most this many intervals are dropped. 0 keeps the raw per-interval labels.

random_state int

Seed for the clustering algorithms, so results are reproducible.

latency_threshold float | None

Minimum excess of a cluster's median minimum RTT over the baseline's (ms). None uses latency_jump.threshold, the threshold of the sequential mode.

min_ks_statistic float

Smallest Kolmogorov-Smirnov statistic (the largest gap between the two empirical jitter distributions, 0-1) that counts as a jitter change. Clusters pool thousands of samples, so the p-value alone is significant for negligible differences; this bounds the effect size. 0 relies on the p-value only.

StreamingConfig

Bases: BaseModel

Settings of the online (streaming) mode, jitterbug.streaming.OnlineJitterbug.

The online mode reuses the sequential decision rule: minimum-RTT bins of data_processing.minimum_interval_minutes, the latency jump threshold of latency_jump.threshold, the significance level of jitter_analysis.significance_level and the device of change_point_detection.bcp_device. The fields below are specific to the Bayesian online change point detector and to the two-stage verdicts.

Attributes:

Name Type Description
backend Literal['bocpd', 'window']

bocpd (default): incremental Bayesian online change point detection, one bin at a time. window: rerun the offline sequential pipeline on a trailing window of window_hours every rerun_every_bins closed bins and emit a verdict once it has been identical in stable_runs consecutive reruns. The baseline the incremental detector is compared with; heavier per bin, no new algorithm.

window_hours float

Length of the trailing window of the window back end, in hours.

rerun_every_bins int

Closed bins between two reruns of the window back end.

stable_runs int

Consecutive reruns in which a change point or a verdict must be identical before the window back end emits it.

hazard_lambda float

Expected run length in bins (constant hazard 1 / hazard_lambda).

decision Literal['map', 'lag', 'window']

Change point rule. map (default) fires when the most probable run length drops; lag thresholds the posterior that a segment started exactly lag bins ago; window thresholds the posterior that it started within the last lag bins and places the change at the most probable run length.

lag int

Decision delay in bins for the lag and window rules.

threshold float

Posterior threshold for the lag and window rules.

max_run_length int or None

Run lengths kept by the detector (bounds memory and time per bin); None keeps the exact posterior.

min_time_elapsed int

Minimum seconds between change points. The MAP rule refines a boundary a few bins after first reporting it; one hour absorbs those refinements.

revise_change_points bool

bocpd back end with the map rule only. When the MAP rule moves the last change point by less than min_time_elapsed (it only moves later), emit a revision event instead of dropping the refinement: the open period starts at the revised epoch, its provisional verdict is judged again, and its final verdict and StateChangeTracker use it. The previous period's final verdict, already emitted, keeps its end_epoch. Off by default: on the paper dataset it puts 13 instead of 8 of the 30 reference boundaries in the right bin but one revision moves a boundary away from the reference (19 instead of 20 within 30 min), and revisions arrive hours after the first report (see docs/ONLINE_MODE.md).

prior_alpha, prior_beta, prior_kappa float

Normal-Gamma prior of the Student-t predictive (see online_likelihoods.StudentT).

prior_mu float or None

Prior mean; None uses the first minimum RTT seen.

min_ks_statistic float

Smallest Kolmogorov-Smirnov statistic that counts as a jitter change (effect-size guard, 0-1); 0 relies on the p-value only.

min_period_samples int

Jitter samples the open period must hold before a provisional verdict. About three 15-minute bins on the paper dataset; 30 gives noisy p-values. With jitter_analysis.method: jitter_dispersion the verdict also waits for enough causal dispersion values (JitterAnalyzer.causal_dispersion_delay plus moving_average_order bins).

state_change_bins int

Closed minimum-RTT bins of a new period the early state-change rule looks at (jitterbug.streaming.StateChangeTracker): a change is suspected when every one of them is above (or, from congested, none is above) the previous period's mean by more than latency_jump.threshold. More bins, fewer retractions, later signal.

InputConfig

Bases: BaseModel

How raw input rows map to RTT samples: column names, units and row policies.

Every file reader and DataLoader.load_from_dataframe hand their rows to one normalizer (jitterbug.io.normalize) that applies these settings. The defaults are the historical contract: an epoch column in Unix seconds, an RTT column in milliseconds named values, rtt_value, rtt or latency, duplicate timestamps kept, out-of-range RTTs dropped and unsorted rows sorted. Jitterbug never imputes or resamples.

Attributes:

Name Type Description
time_column str

Column holding the sample time.

rtt_column str | None

Column holding the RTT. None takes the first of values, rtt_value, rtt, latency that is present.

source_column, destination_column str

Optional columns kept as per-sample metadata; absent columns give None.

time_unit Literal['s', 'ms', 'us', 'ns', 'iso', 'auto']

Unit of numeric times (Unix epoch in seconds, milliseconds, microseconds or nanoseconds), or iso for datetime strings (naive ones are UTC). auto reads datetime strings as iso and numbers by the magnitude of their median: below 1e11 seconds, below 1e14 milliseconds, below 1e17 microseconds, otherwise nanoseconds. The inferred unit is logged and recorded in the dataset metadata.

rtt_unit Literal['ms', 'us', 's', 'ns']

Unit of the RTT column; values are converted to milliseconds.

delimiter str | None

Field separator of CSV-like files. None detects it from the header line (comma, tab or semicolon); TSV files always default to tab.

duplicates Literal['keep', 'first', 'min', 'error']

Rows sharing a timestamp: keep them all, keep the first in file order, keep the one with the lowest RTT, or raise.

out_of_range Literal['drop', 'error']

RTTs that are not positive or exceed MAX_RTT_MS: drop them (counted in the metadata) or raise. Missing values are always dropped.

unsorted Literal['sort', 'error']

Rows not in time order: sort them (stable) or raise.

group_by list[str]

Columns whose values identify a series; each distinct combination is loaded and analyzed on its own, with the row policies applied per series. source and destination name the mapped source_column and destination_column; any other name is a raw input column (a probe id, a device). Empty (the default) reads the input as one series.

series dict[str, str]

Keep only the rows whose column equals the value ({"destination": "8.8.8.8"}), compared as text (numbers in a file or in Python become text: 1234 means "1234"); names resolve like group_by. Applied before grouping and before the row policies. A filter that matches no row is an error naming the values that exist.

SourceConfig

Bases: BaseModel

A database query to read RTT samples from, instead of a file.

The query result goes through the same column mapping, units, row policies, series filters and group_by as a file (InputConfig). Credentials are never part of this model: passwords and tokens are read from environment variables when the query runs, and a setting that looks like a secret is rejected.

Attributes:

Name Type Description
kind Literal['clickhouse', 'influxdb2', 'influxdb3', 'duckdb']

Back end: ClickHouse (SQL, clickhouse extra), InfluxDB 2 (Flux, influx extra), InfluxDB 3 (SQL or InfluxQL, influxdb3 extra) or DuckDB (SQL over files, attached databases and object storage, duckdb extra).

host str | None

Server host name or address (ClickHouse, InfluxDB); localhost when None.

port int | None

Server port; None uses the client's default for ClickHouse, 8086 for InfluxDB 2 and 8181 for InfluxDB 3 (443 with secure).

secure bool

Connect over HTTPS (ClickHouse, InfluxDB).

database str | None

ClickHouse database, or InfluxDB 3 database (required there).

user str | None

ClickHouse user; None reads CLICKHOUSE_USER, then uses the client's default (default).

org str | None

InfluxDB 2 organization.

language Literal['sql', 'influxql']

Query language for InfluxDB 3.

path str | None

DuckDB database file; None is an in-memory database.

read_only bool

Open the DuckDB database file read-only (the default); never applies to an in-memory database.

password_env str | None

Environment variable holding the ClickHouse password; None means CLICKHOUSE_PASSWORD. An unset variable means no password.

token_env str | None

Environment variable holding the InfluxDB token; None means INFLUXDB_V2_TOKEN (InfluxDB 2) or INFLUX_TOKEN (InfluxDB 3).

query str | None

Query text. A --query or --query-file on the command line replaces it.

query_file Path | None

File holding the query text, read when the query runs; exclusive with query.

secret_env()

The environment variable this source reads its password or token from.

Returns:

Type Description
str | None

password_env/token_env or the back end's default; None for DuckDB.

JitterbugConfig

Bases: BaseSettings

Main configuration class for Jitterbug.

Attributes:

Name Type Description
analysis_mode Literal['sequential', 'clustering']

sequential (default) is the PAM 2022 method: change points split the series and each period is compared with the previous one. clustering groups minimum-RTT intervals by (latency, jitter) regardless of when they occur and compares each cluster with the baseline one; see ClusteringConfig.

change_point_detection ChangePointDetectionConfig

Configuration for change point detection.

jitter_analysis JitterAnalysisConfig

Configuration for jitter analysis.

latency_jump LatencyJumpConfig

Configuration for latency jump detection.

data_processing DataProcessingConfig

Configuration for data processing.

clustering ClusteringConfig

Configuration for the clustering mode.

streaming StreamingConfig

Configuration for the online (streaming) mode.

input InputConfig

Column mapping, units and row policies for loading RTT data.

sources dict[str, SourceConfig]

Named database sources (profiles), selected with --source NAME. Left out of dumps while empty, so configurations without sources serialize as before.

output_format Literal['json', 'csv', 'parquet']

Output format for results.

verbose bool

Whether to enable verbose logging.

from_file(config_path) classmethod

Load configuration from file.

Parameters:

Name Type Description Default
config_path Path

Path to configuration file (YAML or JSON).

required

Returns:

Type Description
JitterbugConfig

Loaded configuration.

to_file(config_path)

Save configuration to file.

Parameters:

Name Type Description Default
config_path Path

Path to save configuration file.

required

secret_rejection(key, kind)

The error for a secret found under key: where the secret should come from instead.

Parameters:

Name Type Description Default
key str

The offending setting or URI part (password, token, userinfo...).

required
kind str | None

The back end, to name its environment variable; None lists them all.

required

Returns:

Type Description
str

Message that never contains the secret itself.