Metric threshold policy-template

Use the metric threshold policy-template to monitor a specific metric and evaluate it against a JSONata threshold condition. When the JSONata expression returns true, the system generates an alert with the severity level that you configure.

Note: This policy template is disabled by default. To use the metric threshold policy-template, you must enable it by setting the required feature flag. For more information on enabling the feature, see Enabling fixed threshold for metric anomalies.

When to use this template

Use this template when you need a deterministic, static threshold for a metric. This template does not use behavioral or dynamic thresholds.

Configuration fields

The metric threshold policy-template includes the following configuration fields.

Common fields

These fields work the same way as in other policy templates:

  • Name
  • Description
  • Execution order
Metric group
  • Description: Select the metric group that contains the metric you want to monitor.
  • Allowed values: Any metric group that the system provides.
  • Required: Yes
  • Validation: The system shows an error if you try to save without selecting a value.
Metric
  • Description: Select the metric that you want to evaluate.
  • Allowed values: Metrics within the selected metric group.
  • Required: Yes
  • Validation: The system shows an error if you do not select a metric.
Resource
  • Description: Select one or more resources that relate to the metric. You can leave this option empty.
  • Allowed values: Any resource that the metric context supports.
  • Required: No
  • Validation: None.
JSONata metric threshold condition
  • Description: Enter the JSONata expression that defines the threshold condition.
  • Allowed values: Any valid JSONata expression.
  • Required: Yes
  • Validation:
    • The editor validates JSONata syntax in real time.
    • The output panel displays the evaluation result so you can verify the condition.
Alert severity
  • Description: Select the alert severity that the system uses when the threshold condition is met.
  • Allowed values:
    1. Indeterminate
    2. Information
    3. Warning
    4. Minor
    5. Major
    6. Critical
  • Required: Yes
  • Validation: The system shows an error if the field is empty.

Limits and constraints

  • Supported metric types: All metric types that Cloud Pak for AIOps supports.
  • Threshold range limits: No limits identified.
  • Metrics per policy: Each policy supports one metric.
  • Backend restrictions: No backend or model restrictions identified.

Trigger behavior

The system evaluates the policy every time it receives a metric event.

  1. The system receives a metric.
  2. The system checks whether the metric name and resource match the policy configuration.
  3. The system evaluates the JSONata expression.
  4. If the expression returns true, the system generates an alert with the configured severity.

Example

The following example shows a basic metric threshold policy configuration. In this example, the policy evaluates a metric named cpuUsagePercent and generates a Warning alert when the metric value is greater than 80.
{
  "id": "9b402df0-12d3-11f1-95a1-c96b13f72bb0",
  "revision": "ed699e1104c74409a0cf6f05f320031f731fc9d8",
  "hash": "13cc7553add6710e170a387055084139b0bc775d",
  "state": "enabled",
  "executionPriority": 50,
  "metadata": {
    "labels": {
      "ibm.com/aiops/uitemplate": "alert:metrics",
      "ibm.com/is-default": "false"
    },
    "name": "sample metric policy",
    "description": "",
    "creationTimestamp": "2026-02-26T05:25:47.725Z",
    "lastUpdatedTimestamp": "2026-02-26T05:25:47.725Z",
    "createdBy": {
      "id": "cpadmin",
      "type": "user"
    },
    "lastUpdatedBy": {
      "id": "cpadmin",
      "type": "user",
      "changeDetails": "Created"
    }
  },
  "spec": {
    "constants": {
      "metricGroup": "alertGroup"
    },
    "triggers": [
      {
        "triggerId": "aiops.ibm.com/trigger/metric-received",
        "entityId": "metric",
        "arguments": {
          "condition": "({{metric.metric_name}} == \"alertCreationCount\") and (({{metric.resource_name}} == \"AIOps Alert Rate Monitoring\"))"
        }
      }
    ],
    "actions": [
      {
        "actionId": "lang/if",
        "arguments": {
          "conditions": {
            "actionId": "lang/scripting/runScript",
            "arguments": {
              "language": "jsonata",
              "script": "metric.value > 90"
            }
          },
          "then": [
            {
              "actionId": "aiops/metrics/setExceedsThreshold",
              "arguments": {
                "mrId": {
                  "$variable": "metric.mr_id"
                },
                "policyId": {
                  "$variable": "policy.id"
                },
                "value": true
              }
            },
            {
              "actionId": "aiops/metrics/deriveBaselineAnomalyMessage",
              "arguments": {
                "metric": {
                  "$variable": "metric"
                }
              },
              "output": "baselineMessage"
            },
            {
              "actionId": "aiops/io/sendMessage",
              "arguments": {
                "channel": "metrics-baselines",
                "entityType": "com.ibm.aiops.metric.anomaly",
                "key": {
                  "$variable": "metric.mr_id"
                },
                "entity": {
                  "$variable": "baselineMessage"
                }
              }
            },
            {
              "actionId": "aiops/metrics/deriveThresholdAnomalyEvent",
              "arguments": {
                "metric": {
                  "$variable": "metric"
                },
                "summary": "Metric exceeds fixed threshold",
                "severity": 3
              },
              "output": "anomalyEvent"
            },
            {
              "actionId": "aiops/io/sendMessage",
              "arguments": {
                "channel": "events-input",
                "entityType": "com.ibm.aiops.event.pre-insert",
                "key": {
                  "$variable": "metric.mr_id"
                },
                "entity": {
                  "$variable": "anomalyEvent"
                }
              }
            }
          ],
          "else": [
            {
              "actionId": "lang/if",
              "arguments": {
                "conditions": {
                  "actionId": "aiops/metrics/checkExceedsThreshold",
                  "arguments": {
                    "mrId": {
                      "$variable": "metric.mr_id"
                    },
                    "policyId": {
                      "$variable": "policy.id"
                    }
                  }
                },
                "then": [
                  {
                    "actionId": "aiops/metrics/setExceedsThreshold",
                    "arguments": {
                      "mrId": {
                        "$variable": "metric.mr_id"
                      },
                      "policyId": {
                        "$variable": "policy.id"
                      },
                      "value": false
                    }
                  },
                  {
                    "actionId": "aiops/metrics/deriveThresholdAnomalyEvent",
                    "arguments": {
                      "metric": {
                        "$variable": "metric"
                      },
                      "summary": {
                        "$variable": "constants.thresholdExceededSummary"
                      },
                      "severity": {
                        "$variable": "constants.thresholdExceededSeverity"
                      },
                      "eventType": "resolution"
                    },
                    "output": "resolutionEvent"
                  },
                  {
                    "actionId": "aiops/io/sendMessage",
                    "arguments": {
                      "channel": "events-input",
                      "entityType": "com.ibm.aiops.event.pre-insert",
                      "key": {
                        "$template": "metric.mr_id"
                      },
                      "entity": {
                        "$variable": "resolutionEvent"
                      }
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  }
}