Metrics Explorer
The Metrics Explorer allows you to create useful time-sequence plots for evaluating metrics that your deployed devices send to the Cloud. The Metrics Explorer provides both the ability to select which metrics are to be uses, but also to preprocess the data using Query Functions and Query Operators, as well as alter the time period and sampling of data displayed.
Queries
To create a time-sequence plot in the Metrics Explorer in maiLink SRM you have to create a query in a language known as PromQL. maiLink SRM leverages VictoriaMetrics, which in turn relies on the Prometheus database. PromQL is the query language of Prometheus.
Raw Time-Sequence Queries
■ For a Specific Device
To plot the raw values (straight from the database) for a specified metric and a specified device, use a query that refers to the true Device ID:
my_metric{device="my_device_id"}
# example: heartbeat{device="123317-01A"}
■ For the Current Device
To plot the raw values (straight from the database) for a specified metric on the current device, use a query that subsitutes $device.id for the true Device ID (the current Device ID will be appropriately substituted when the query is performed):
my_metric{device="$device.id"}
# example: heartbeat{device="$device.id"}
Using $device.id lets a plot be created at the Device Type level and, when visualized for a specific device, have the data from this device plotted.
Accumulated Time-Sequence Queries
Calculations such as sums can be performed during the query in order to accumulate values over a time period. This helps reduce the number of data points and simplifies the plotting of data.
sum_over_time(my_metric{device="my_device_id"}[my_time_period])
# example: sum_over_time(ProbeTemp_C{device="$device.id"}[1m])
For the example shown above, assume a heartbeat comes every 10 seconds. The example queiry will create a value of about 6 because it is summing over a 1 minute time period (one should expect about 6 heartbeats to arrive at a rate of one every 10 seconds). Note that there may be some sampling error in this data (because of clock offsets), so you would get between 5 and 7 heartbeats per minute in reality.
■ Specifying Time Periods
Time period are specified using concatenated numbers and units, goverened by the regex expression [0-9]+([ywdhms]|ms) for each subsection. The units in each section should be one of:
Unit | Description |
---|---|
ms | milliseconds |
s | seconds |
m | minutes |
h | hours |
d | days (with 24 hours) |
w | weeks (with 7 days) |
y | years (with 365 days) |
When periods are mixed, such as 1h30m, they should be constructed logically (largest units first).
Rolling Average of Accumulated Time-Sequence Queries
Rolling averages can be produced by averaging data over time. In the examples below tp represents a time period.
avg_over_time(sum_over_time(my_metric{device="my_device"}[tp1])[tp2])
# example: avg_over_time(sum_over_time(heartbeat{device="$device.id"}[1m])[2m30s])
In the above example the syntax of the function nesting means that the [1m] time period applies to the sum_over_time() function, and the [2m30s] time period applies to the avg_over_time() function. Also, simpler to the prior example, let’s assume the heartbeat comes every 10 seconds. As discussed above, the sum_over_time() value will be between 5 and 7. But if you do a rolling average using avg_over_time() you can expect the data to be smoothed to 6 heartbeats per minute, one every 10 seconds.
Additional Resources
Further information is available at: