Time series database reference

Time series database.

class lognplot.tsdb.db.TsDb

A time series database.

add_sample(name: str, sample)

Add a single sample to the given series.

add_samples(name: str, samples)

Add samples to the given series.


Remove all signals from the database.


Notify listeners of a change.

Rate limit the events to prevent GUI flooding. To do this, keep a token counter, if there is an event, check the tokens, if there is a token, propagate the event. Otherwise, store the event for later processing.

If more events arrive, aggregate the events into a resulting event.

query(name: str, timespan: lognplot.time.timespan.TimeSpan, count: int)

Query the database on the given signal.


Get a sorted list of signal names.

B-tree data structure.

Idea is to create summary levels on top of chunks of data.

class lognplot.tsdb.btree.BtreeInternalNode(max_children)

Intermediate level node in the B-tree.

Has child nodes of either internal node, or leave type.


Append a single sample to a descendant of this node.


Append a leave node.

select_range(selection_span: lognplot.time.timespan.TimeSpan)

Select a range of nodes falling between begin and end

class lognplot.tsdb.btree.BtreeLeaveNode(max_samples)

A leave node in the B-tree.

This node type actually contains raw observations.


Retrieve all samples in this node.

select_range(selection_span: lognplot.time.timespan.TimeSpan)

Select a range of samples falling between begin and end

class lognplot.tsdb.btree.BtreeNode

Base class for either internal, or leave nodes of the B-tree.

This class and it’s subclasses are for internal usage in the B-tree. Do not use outside this file.

lognplot.tsdb.btree.enhance(nodes, selection_span)

Enhance resolution by descending into child nodes in the selected time span.

class lognplot.tsdb.metrics.EventMetrics(count, first, last)

Simplest metric, simply counting the events.

class lognplot.tsdb.metrics.LogMetrics(count, first, last)
class lognplot.tsdb.metrics.Metrics

Compaction metrics.

This is a base class for data summary.

static from_metrics(metrics)

Merge several metrics into a single metric.

classmethod from_values(values)

Convert a single sample into metrics.

class lognplot.tsdb.metrics.ValueMetrics(count, minimum, maximum, first, last, mean, m2)

Compaction range matrics.

Idea is this is some sort of summary about data. For example, we have the count of samples about which these metrics are a summary. Also, we have minimum and maximum values.

Note that addition is not commutative, the chunks are ordered in sequence.

classmethod from_value(value)

Convert a single sample into metrics.


Mean value of this data chunk


Calculate standard deviation.


Calculate the variance of this aggregation