Metric
A metric represents a single data value provided by a plugin, such as a CPU temperature or the name of the
operating system.
Each metric has a core or custom MetricType, which defines the kind of value and its units, and
always belongs to a Category.
A metric only describes the data. Its actual value is pushed separately as a MetricValue.
See also: Registering Items, Updating Metric Values
Properties
| Property | Type | Restrictions | Description |
|---|---|---|---|
| Id | string | Required Length: 1 - 256Pattern: ^[\w\.\-]+$ | The unique identifier of the metric. |
| Label | string | Required Length: 1 - 64 | The textual label of the metric. Longer labels are truncated. |
| TypeId | string | Required Length: 1 - 256Pattern: ^[\w\.\-]+$ | The type of this metric: a core type or the ID of a registered MetricType. |
| CategoryId | string | Required Length: 1 - 256Pattern: ^[\w\.\-]+$ | The category of this metric: a core category or the ID of a registered Category. |
| IsStatic | bool | Default: false | Whether the value of the metric is static. See Static and Dynamic Metrics. |
| Description | string? | Max length: 256 | An optional textual description of the metric. |
| GroupId | string? | Length: 1 - 256Pattern: ^[\w\.\-]+$ | An optional group the metric belongs to (the ID of a registered Group). |
Static and Dynamic Metrics
- Dynamic metrics (the default) change over time, e.g. CPU usage or a temperature. Their values are typically updated periodically using the scheduler.
- Static metrics have a value that does not change until the next system reboot, e.g. the name of the CPU or the
operating system. Mark them with
.AsStaticValue()and set their value only once.
Creating a Metric
Metrics are created using the MoBroItem.CreateMetric() builder, which guides you through all required properties in
the following order:
WithId(id)WithLabel(label)orWithLabel(label, description)OfType(...)— aCoreMetricType, aCoreMetricTypeCurrency, a registeredMetricTypeor its IDOfCategory(...)— aCoreCategory, a registeredCategoryor its ID — orOfNoCategory()forCoreCategory.MiscellaneousOfGroup(...)— a registeredGroupor its ID — orOfNoGroup()- Optional:
AsStaticValue()orAsDynamicValue() Build()
var cpuName = MoBroItem
.CreateMetric()
.WithId("cpu_name")
.WithLabel("CPU Name", "The model name of the processor")
.OfType(CoreMetricType.Text)
.OfCategory(CoreCategory.Cpu)
.OfNoGroup()
.AsStaticValue()
.Build();