Skip to main content

Work with units of measure

Units are shared reference data — celsius, bar, m/s, usd. Tagging a time-series with a unit makes its values self-describing: a chart can label its axis, and a consumer knows that 248.6 is bar, not psi. Browse the catalogue, then reference a unit by its external id when you create a series.

Browse the catalogue

client.units().list().getItems().forEach(u ->
System.out.println(u.getExternalId() + " " + u.getName() + " (" + u.getSymbol() + ") — " + u.getQuantity()));

Tag a series with a unit

The everyday use: pass a unit's external id when you create a time-series. The value type stays numeric; the unit just describes what the numbers mean.

var series = Timeseries.of("wellhead_pressure_bar").name("Wellhead pressure");
series.setUnit("bar");
client.timeseries().create(series);

Look up a specific unit

Resolve a unit you already know — by external id, or by numeric id.

byIds takes UnitModels with their id set:

UnitModel lookup = new UnitModel();
lookup.setId(7L);
UnitModel unit = client.units().byIds(List.of(lookup)).getItems().iterator().next();
Unit external ids are snake_case

The seeded unit catalogue uses snake_case throughout — m_s for metres per second, deg_c for degrees Celsius — so reference them that way and browse the catalogue to find the exact id. That is a property of the catalogue, not a rule about external ids in general: the ones you create are stored exactly as you send them.

See the Units reference for the full method list.