Producing Metrics

Producing Metrics
This article provides information about producing metrics from a probe.
How to Produce Metrics
The probe framework greatly simplifies the process of producing metrics. The only action required is to set a metric value on the associated inventory element, and the framework takes care of the rest. The framework determines if the metric value should be published to the bus, based on threshold settings.
The following statements, taken from the mock_vm_host example probe, show how to create an inventory element and set a metric on it. The first line instantiates an inventory element that represents a VM CPU. The second line sets the metric value for the CPU load.
MyVMCPU myCPUElement = MyVMCPU.addInstance(inventoryDataset, new EntityId(myVM1, "cpu-1"), "cpu-1", vmCPUFolder); myCPUElement.setMetric(MyVMCPU.CPULoad, 23);
How a Metric Source is Determined
For every metric produced by the probe, the source for that metric is set using the following algorithm:
  • If the element the metric is attached to is an IP device, then the source is that device name.
  • If the element the metric is attached to is not an IP device, then look up the tree until the first IP device is found and use its name for the source.
  • If no IP device is found in the tree, then use the profile name as the source.
This algorithm is applicable when a probe is a typical remote probe. For local probes, the source is the name of the robot the probe is running on.
Refining How a Metric Target Name is Constructed
By default, the metric target name resembles a path to the element the metric is attached to. Optionally, if you want the framework to use the short element name, invoke ProbeBase.useShortTargetName(true) in a the probe constructor. See the Javadoc in the docs directory of the Probe SDK package.