Skip to main content

Time-series

Time-series metadata, datapoint retrieval, and datapoint ingestion (single-request or high-throughput).

A series' externalId identifies it: unique per tenant, compared without case, and stored exactly as you send it. External ids & naming →

Create a series

Timeseries series = new Timeseries()
.setExternalId("engine_temperature")
.setName("Engine temperature");
series.setUnit("celsius");

client.timeseries().create(List.of(series));

Value types

Every series has a value type that decides how its datapoints are stored. Leave it unset and the series is floating-point (float32) — right for most sensor readings, so the create above accepts decimal values as-is. Set it explicitly when you need something else:

Value typeUse it for
float32 (default)Sensor readings — 32-bit precision is plenty.
floatDouble-precision floating point.
numeric / decimal32Exact decimals — money, lab values — stored without floating-point rounding. Pass the values as strings.
bigintWhole numbers (counts, integer statuses).
textNon-numeric string values.
mixedHeterogeneous values in one series.

A float written to a bigint series is rejected, so pick the type that matches the data. For a value that must reconcile exactly, use numeric:

Timeseries price = new Timeseries()
.setExternalId("book_value_usd")
.setName("Book value (USD)");
price.setUnit("usd");
price.setValueType("numeric"); // exact decimals, no float rounding

client.timeseries().create(List.of(price));

Filter series

POST /timeseries/filter finds series by structured criteria. Everything you supply is combined with AND — a series must match every criterion to be included.

CriterionMatching
dataSetIdThe data set and every data set beneath it in the data set hierarchy — a series attached to a child (or grandchild, …) data set matches too.
unitCase-insensitive; % works as a wildcard ("cel%").
unitExternalIdExact match on the unit-catalogue external id (e.g. temperature_deg_c).
metadataKey / metadataValueTogether: that key must carry that value. Alone: any entry with that key (or any entry with that value).

Results come newest first, capped by limit (default 1000, max 10000). Series in data sets you lack read access to are silently omitted — the result is what your token may see, not an error. For free-text lookups use POST /timeseries/search instead.

import ai.intellistream.datahub.models.datafilters.TimeseriesFilter;

TimeseriesFilter criteria = new TimeseriesFilter();
criteria.setDataSetId(12L); // this data set and every data set beneath it
criteria.setUnit("celsius");

DataWrapper<Timeseries> series = client.timeseries().filter(criteria);

Pass a TimeseriesRetreiver instead of the bare criteria to set an explicit limit.

The hierarchy expansion is what makes "master" data sets useful: filter on the top-level data set of a site or project and you get the series of the whole family beneath it, without knowing (or maintaining a list of) the sub-data sets.

Delete a series

Deletes the series and its datapoints. Remove any referencing subscriptions (and edges) first, or the backend responds 409.

import ai.intellistream.datahub.models.IdCollection;

client.timeseries().delete(List.of(IdCollection.createFromExternalId("engine_temperature")));

Write datapoints

A datapoint is a (timestamp, value) pair grouped under a series' external id.

Timestamps are epoch milliseconds as strings:

DatapointsCollection collection = new DatapointsCollection();
collection.setExternalId("engine_temperature");
collection.setDatapoints(List.of(
new DatapointString(String.valueOf(System.currentTimeMillis()), "92.4")));

client.timeseries().insertDatapoints(List.of(collection));

High-throughput ingestion

For large or unbounded volumes the SDK chunks and sends in bulk. See the ingestion guide for the full story.

Survive outages with durable buffering

Enable durable buffering on the client and datapoint ingestion that can't reach the API spools to disk and flushes on the next call, bounded by a time and/or size window. Retries are idempotent (datapoints dedup on (series, timestamp)).

ingest chunks, parallelises and retries, returning an IngestResult tuned with IngestOptions:

IngestResult result = client.timeseries().ingest(data,
IngestOptions.builder()
.batchSize(10_000) // datapoints per request
.parallelism(16) // concurrent in-flight requests
.maxRetries(3)
.build());

System.out.printf("ingested %,d, failed %,d%n", result.succeeded(), result.failed());

Retrieve datapoints

Identify a series (external id or id) and a time window.

import java.time.ZonedDateTime;

RetrieveFilter series = new RetrieveFilter();
series.setExternalId("engine_temperature");
series.setStart(ZonedDateTime.now().minusHours(1));
series.setEnd(ZonedDateTime.now());
series.setLimit(1000);

DataRetriever<RetrieveFilter> request = new DataRetriever<>();
request.setItems(List.of(series));

DataWrapper<DatapointsCollection> points = client.timeseries().retrieve(request);
points.getItems().forEach(c ->
System.out.println(c.getExternalId() + ": " + c.getDatapoints().size() + " points"));

IngestOptions

The Java ingest tuning knobs (Python's insert_from_lists and Rust's insert_datapoints batch internally):

OptionDefaultMeaning
batchSize10_000Maximum items per request.
parallelism8Concurrent in-flight requests.
maxRetries3Retries for transient failures (HTTP 429/5xx, network).
failFastfalseIf true, abort on the first failed batch instead of collecting errors.

IngestOptions.defaults() returns the defaults; ingest(data) (no options) uses them.

IngestResult

long succeeded() // items ingested
long failed() // items that could not be ingested
long buffered() // items spooled to the durable buffer (0 unless buffering is on)
boolean isComplete() // true when nothing failed and nothing was buffered
List<BatchError> errors() // one entry per failed batch

BatchError is a record (int datapointCount, int statusCode, String message)statusCode is 0 when the failure was a network error rather than an HTTP status.

if (!result.isComplete()) {
result.errors().forEach(e ->
System.err.println(e.statusCode() + " on " + e.datapointCount() + " items: " + e.message()));
}