...
Simple metrics form the 'base' of the Metrics system. They are defined on a specific Type and reference timeseries data stored within.
Essentially, the Simple metric defines:
- The Type on which the metric is defined
- How to find the timeseries data on the Type
- Configuration of the Normalization engine
- The name of the metric
An example SimpleMetric is:
Code Block | ||
---|---|---|
| ||
sample_met = c3.SimpleMetric.make({
'id': 'SampleMetric_SampleType',
'name': 'SampleMetric',
'srcType': 'SampleType',
'path': 'timeseriesValues',
'expression': 'avg(avg(normalized.data.x))'
}) |
Please note that the above example does not have an example context in which it will work. This will be updated soon with a version backed up by a working exercise.
For more detail, see the C3 documentation on SimpleMetrics here: https://developer.c3.ai/docs/7.12.0/guide/guide-c3aisuite-basic/metrics-simple-metrics
CompoundMetrics
Compound metrics are generally easier to define and use as they operate on already defined metrics either Simple or Compound.
They essentially just consist of and id/name, and an expression defining the metric in terms of constants and already defined metrics.
If you try and execute a CompoundMetric on a type for which some necessary SimpleMetric is not defined, you'll get an error.
Essentially, a CompoundMetric defines:
- The name/id of the metric
- The expression defining the metric
An example CompoundMetric is:
Code Block |
---|
sample_compound_met = c3.SimpleMetric.make({
'id': 'CompoundMetric',
'name': 'CompoundMetric',
'expression': 'window("AVG", SimpleMetric, 0, 7)',
}) |
Please note that the above example does not have an example context in which it will work. This will be updated soon with a version backed up by a working exercise.
For more detail, see the C3 documentation on CompoundMetrics here: https://developer.c3.ai/docs/7.12.0/guide/guide-c3aisuite-basic/metrics-compound-metrics
Evaluating Metrics
Not all SimpleMetrics are defined on all types. Types on which you can evaluate a metric mixin the Type 'MetricEvaluatable' (C3 Docs here: https://developer.c3.ai/docs/7.12.0/type/MetricEvaluatable)
This bestows the function 'listMetrics' to that type, so if you're unsure what kind of metrics are available for a given type, execute that function to get a list, for example:
...