Nola Query Language (NolaQL)
NolaQL is an expression language for querying data from the Nola dashboard.
It enables you to take data from metrics, compare metrics to each other and run calculations and analysis on them.
It is used as part of writing conditions for Notifications.
Syntax
The language supports some basic and familiar syntax:
1 + 1
max($a) >= min($b)
false || true
Metrics
Querying metrics from Nola involves referencing the metric by its name, and optionally specifying a time range, time bucket and subslice:
$metric_name{time_range,time_bucket}[subslice]
Field | Description | Examples |
---|---|---|
$metric_name | The name of the metric to query. It always begins with a $ and is based upon the metric's name in the Nola dashboard, with invalid characters replaced by _ . | $occupancy , $band_room_staff_count |
time_range | Counting back from the current time, how long of a time range to fetch data for. It is composed of a number and a unit. The default value is 10m . (Required) | 5m , 1h30m , 1d |
time_bucket | The size of each time bucket for the metric. Each value in the metric data will represent this time interval. The default value is OneMinute . (Required) | OneMinute , TenMinute , Hour , Day |
subslice | Select a subslice of the metric data. This is useful for picking out certain times within the selected time range. (Optional) | [-1] (last value), [0:5] (first 5 values) |
Available Functions
Function | Description | Example |
---|---|---|
max($metric) -> number | Returns the maximum value of the metric as a number. | max($metric{5m,OneMinute}) |
min($metric) -> number | Returns the minimum value of the metric as a number. | min($metric{5m,OneMinute}) |
mean($metric) -> number | Returns the mean (average) value of the metric as a number. | mean($metric{5m,OneMinute}) |
median($metric) -> number | Returns the median value of the metric as a number. | median($metric{5m,OneMinute}) |
mode($metric) -> number | Returns the mode value of the metric as a number. | mode($metric{5m,OneMinute}) |
first($metric) -> number | Returns the first value of the metric as a number. This is the same as using a [0] subslice. | first($metric{5m,OneMinute}) |
last($metric) -> number | Returns the last value of the metric as a number. This is the same as using a [-1] subslice. | last($metric{5m,OneMinute}) |
rate($metric) -> $metric | Returns a metric (of 1 less length) that represents the rate of change (per second) of the input metric. | rate($metric{5m,OneMinute}) |
increase($metric) -> $metric | Returns a metric (of 1 less length) that represents the increase (from the previous value) of the input metric. | increase($metric{5m,OneMinute}) |
holt_winters($metric, projection_duration, season_length, alpha, beta, gamma) -> $metric | Performs a Holt-Winters forecast on the input metric.
This is the recommended forecasting method. | holt_winters($metric{20m,OneMinute}, 5m, 10) This would project $metric 5 minutes into the future, using a season length of 10 minutes (10 * OneMinute ) and default smoothing parameters. |
linear_predict($metric, projection_duration) -> $metric | Performs a forecast using linear regression on the input metric.
| linear_predict($metric{10m,OneMinute}, 5m) |
ema_predict($metric, alpha, projection_duration) -> $metric | Performs a forecast using Exponential Moving Average on the input metric.
| ema_predict($metric{10m,OneMinute}, 0.4, 5m) |
even_distribution( [$metric, ...], ["Metric Label", ...], projection_interval, min_metric_value, diff_threshold) -> boolean | Compares a list of metrics and performs pair-wise checks to see if they are evenly distributed. Metric
| even_distribution([$metric_a{10m, OneMinute}, $metric_b{10m, OneMinute}], ["Metric A", "Metric B"], 5m, 30, 25) This would check that every pair of metrics ( Metrics under |
pt_arrival("Stop ID") -> boolean | Returns true for 60 seconds from the moment when public transport arrives at a specified stop ID. | pt_arrival("20016") |
network_check("no_reply_in_seconds") -> boolean | Returns true if at least one of the connected CCTV devices does not provide video stream. Nola checks camera status every 20 seconds, parameter no_reply_in_seconds specifies the minimum time when camera is not responding | network_check("60") |