"Parametric" Compound metric - HOW TO


#1

Which is the best practice to implement a parametric compound metric?

In the following a quite complete example. Please, give me a feedback if something is wrong. Thanks

Basic Simple Metric:

{
  "id": "PredictionSimpleMetric_MyType",
  "name": "PredictionSimpleMetric",
  "srcType": "MyType",
  "path": "useCases.(name=='combustionInstability').predictions",
  "expression": "avg(avg(normalized.data.value))"
}

Parametric compound metric 1:

{
  "id" : "AlertRollingMeanTh",
  "name" : "AlertRollingMeanTh",
  "expression" : "window('AVG', PredictionSimpleMetric, -TGWindow,TGWindow)>TGThreshold",
  "variables": [
    {
      "name": "TGWindow",
      "dataType": "int"
    },
    {
      "name": "TGThreshold",
      "dataType": "double"
    }
  ]
}

Parametric compound metric 2:

{
  "id" : "AlertTrigger",
  "name" : "AlertTrigger",
  "expression" : "rollingDiff(window('MIN', AlertRollingMeanTh, -MinDurationOverThreshold, MinDurationOverThreshold))==1",
  "variables": [
    {
      "name": "MinDurationOverThreshold",
      "dataType": "int"
    }
  ]
}

Final Compound Metric: Here the compount metric which feeds the parameters with actual values.

{
  "id" : "AlertTuned",
  "name" : "AlertTuned",
  "expression" : "AlertTrigger",
  "variables": [
    {
      "name":"MinDurationOverThreshold",
      "dataType": "int",
      "value": 1800
    },
    {
      "name":"TGWindow",
      "dataType": "int",
      "value": 300
    },
    {
      "name":"TGThreshold",
      "dataType": "double",
      "value": 0.05
    }
  ]
}