MetricValue
The MetricValue represents the actual value of a Metric at a certain point in time.
It is defined as a readonly record struct.
See also: Updating Metric Values
note
When a metric's value is updated, it must conform to the type restrictions imposed by the MetricValueType of the metric's MetricType.
For metric types with a defined base unit, the value must be provided in that base unit to ensure accurate unit conversions.
Properties
| Property | Type | Restrictions | Description |
|---|---|---|---|
Id | string | Required Length: 1 - 256Pattern: ^[\w\.\-]+$ | The ID of the Metric this value belongs to. |
Timestamp | DateTime | Required | The date and time the value was recorded or measured, in UTC. |
Value | object? | See MetricValueType | The actual recorded value. null means "no value". |
Constructors
| Constructor | Description |
|---|---|
MetricValue(string id, object? value) | Creates a value with the timestamp set to DateTime.UtcNow. |
MetricValue(string id, DateTime timestamp, object? value) | Creates a value measured at the given UTC timestamp. |
MetricValue(string id, DateTimeOffset timestamp, object? value) | Creates a value measured at the given timestamp (converted to UTC). |
Example
var values = new List<MetricValue>
{
new("cpu_usage", 42.5),
new("ram_in_use", DateTime.UtcNow, 8_000_000_000)
};
_mobro.UpdateMetricValues(values);
Widget packs
On the dashboard side, the same reading is available to widgets as a ChannelValue.
See Widget Packs: Types.