Type: reference · Imported reference (adopted from the clarity backend developer docs)
Query endpoints accept an optional pipeline that transforms each tag's series before it is returned. pipeline is a JSON object mapping each tag (or resolved generatedDataTagId) to an ordered array of steps, applied in sequence.
Each step is an object with an "op" key selecting the operator, an optional "bucket" (bucket width in milliseconds, default 60000 for bucketed ops), and any operator-specific parameters as sibling keys. Buckets are anchored at the query start.
{
"temperature": [
{ "op": "mean", "bucket": 60000 },
{ "op": "scale", "factor": 1.8 },
{ "op": "filter", "filter_op": "gt", "threshold": 100.0 }
],
"pressure": [ { "op": "gaps", "bucket": 60000 } ],
"vibration": [ { "op": "percentile", "percentile": 0.95, "bucket": 300000 } ]
}
"op" |
Parameters | Meaning |
|---|---|---|
mean / avg |
(bucket) | Bucket average. |
sum |
(bucket) | Bucket sum. |
min |
(bucket) | Bucket minimum. |
max |
(bucket) | Bucket maximum. |
count |
(bucket) | Number of readings per bucket. |
first |
(bucket) | First reading per bucket. |
last |
(bucket) | Last reading per bucket. |
dev |
(bucket) | Standard deviation per bucket. |
gaps |
bucket (+ query start/end) |
Emit every grid slot, with null/NaN at gaps. |
histogram |
percentile: f64 (+bucket) |
Percentile per bucket. |
percentile |
percentile: f64 (+bucket) |
Percentile per bucket. |
leastsquares (alias least_squares) |
— | Linear regression fit. |
diff |
— | Consecutive difference. |
div |
divisor: f64 |
Divide each value. |
rate |
unit: string |
Per-second change. |
sampler |
unit: string |
Placeholder (behaves like rate). |
scale |
factor: f64 |
Multiply each value. |
trim |
trim: "first"\|"last"\|"both" |
Drop endpoint(s). |
saveas |
metric_name, tags, ttl?, add_saved_from? |
Placeholder (no-op). |
filter |
filter_op: "lte"\|"lt"\|"gte"\|"gt"\|"equal", threshold: f64 |
Keep matching points. |
score |
order: "ascending"\|"descending", thresholds: [{ "value": f64, "boundary": "superior"\|"inferior" }] |
Map value → score index. |
Enum values also accept their uppercase forms (FIRST, GT, ASCENDING, SUPERIOR, …).
(timestamp, value|null).gaps operator produces explicit null/NaN entries; every other operator emits present values only.fast_query (JSON) these become [[ts, value|null], …]. In the binary handlers, the NaN-emit path is enabled only when a gaps step is present.mean, sum, min, max, count, first, last) is evaluated inside the storage scan for speed.Hourly average, converted and thresholded:
{ "temperature": [
{ "op": "mean", "bucket": 3600000 },
{ "op": "scale", "factor": 1.8 },
{ "op": "filter", "filter_op": "gt", "threshold": 100.0 }
] }
Explicit gap markers (for charting):
{ "pressure": [ { "op": "gaps", "bucket": 60000 } ] }
Scored status:
{ "status_code": [
{ "op": "score", "order": "ascending",
"thresholds": [
{ "value": 10.0, "boundary": "inferior" },
{ "value": 50.0, "boundary": "superior" }
] }
] }
pipeline is usedAdopted from clarity backend developer docs (
docs/developer/api/aggregation.md), imported reference.
Primary handler:clarity:backend/src-tauri/src/api/aggregator.rs.
Last updated: 2026-07-17 from commit 6800acc