Deploy Metrics
When persisting developed metrics into the C3 Agentic AI Platform, metrics should be defined in JSON files. A single JSON file may contain one or many metric definitions.
Location in package for deploying
Metric JSON files must be in the metadata directory under the application directory. Additionally, metric JSON files should be sub-organized by Type of the JSON files (for example, CompoundMetric or SimpleMetric).
├── metadata
│ ├── CompoundMetric
│ │ ├── CumulativeSwitchCount.json
│ | ├── DurationOnInHours.json
│ | ├── HasEverFailed.json
│ | ├── IsDefective.json
│ | ├── PwerConsumption.json
| ├── Role
│ ├── SimpleMetric
│ │ ├── AverageLumens_SmartBulb.json
│ | ├── AveragePower_SmartBulb.json
| | ├── AverageTemperature_SmartBulb.json
| | ├── AverageVoltage_SmartBulb.json
│ ├── UIConfigAfter deploying, check that the metric is available on the environment by running SmartBulb.listMetrics() from the console to list all metrics available on the SmartBulb Type.
Example of creating single metrics
Below is an example of creating one file per metric. In this case, the file name must be the id of the metric.
This is a clean approach to organize metrics.
{
"id": "ManufacturerNameStartsWithG_SmartBulb",
"name": "ManufacturerNameStartsWithG",
"srcType": "SmartBulb",
"expression": "startsWith(lowerCase(manufacturer.name), 'g')"
}{
"id": "ManufacturerNameStartsWithJ_SmartBulb",
"name": "ManufacturerNameStartsWithJ",
"srcType": "SmartBulb",
"expression": "startsWith(lowerCase(manufacturer.name), 'j')"
}Example of creating collection of metrics
Often it may be desirable to thematically organize metrics in a single file.
In the example below, the two metrics are put into one JSON file.
It makes organizational sense to put two simple metrics together because they are similar in nature. This way metrics are easier to find, and it is easier to refactor in the future.
Either way, the platform can recognize the metric definition.
{
"type": "[SimpleMetric]",
"value": [
{
"id": "ManufacturerNameStartsWithG_SmartBulb",
"name": "ManufacturerNameStartsWithG",
"srcType": "SmartBulb",
"expression": "startsWith(lowerCase(manufacturer.name), 'g')"
},
{
"id": "ManufacturerNameStartsWithJ_SmartBulb",
"name": "ManufacturerNameStartsWithJ",
"srcType": "SmartBulb",
"expression": "startsWith(lowerCase(manufacturer.name), 'j')"
}
]
}Deploying metrics in the console
Metrics can also be defined and deployed in the console on using following syntax: <MetricType>.make()
Warning: If you choose to define metrics in the console, they cannot be saved during deployment and can disappear.
Examples: SimpleMetric.make(), CompoundMetric.make().