{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Create Instance Alarm",
  "description": "Register a cloud metric alarm with an instance. The alarm appears in the UI immediately and receives state transitions as soon as the cloud provider reports them. Webhooks from AWS CloudWatch, Azure Monitor, GCP Cloud Monitoring, and Prometheus Alertmanager match against `cloudResourceId` to attach state.",
  "type": "object",
  "required": ["displayName", "cloudResourceId"],
  "properties": {
    "displayName": {
      "type": "string",
      "title": "Display Name",
      "description": "Human-readable name for the alarm. Shown in the UI and in notifications. Typically the alarm name registered with the cloud provider.",
      "examples": ["High CPU", "Memory pressure"]
    },
    "cloudResourceId": {
      "type": "string",
      "title": "Cloud Resource ID",
      "description": "The cloud provider's unique identifier for the alarm. Used to correlate incoming state transition webhooks back to this alarm. Examples: a CloudWatch AlarmArn, a GCP alert policy name, an Azure alert id.",
      "examples": ["arn:aws:cloudwatch:us-east-1:123456789012:alarm:db-cpu"]
    },
    "comparisonOperator": {
      "type": "string",
      "title": "Comparison Operator",
      "description": "How the metric is compared against `threshold` (e.g., `GREATER_THAN`, `LESS_THAN`). Optional for providers that don't expose this concept (e.g., Alertmanager, GCP).",
      "examples": ["GREATER_THAN", "LESS_THAN", "GREATER_THAN_OR_EQUAL_TO", "LESS_THAN_OR_EQUAL_TO"]
    },
    "threshold": {
      "type": "number",
      "title": "Threshold",
      "description": "The value crossed to trigger the alarm. Compared against the metric using `comparisonOperator`. Optional.",
      "examples": [80.0, 0.95]
    },
    "period": {
      "type": "integer",
      "title": "Period (seconds)",
      "description": "Evaluation window in seconds over which the metric is aggregated before the comparison is applied. Optional.",
      "minimum": 1,
      "examples": [60, 300]
    },
    "metric": {
      "type": "object",
      "x-gql-type": "alarm_metric_input",
      "title": "Metric",
      "description": "The cloud metric this alarm evaluates. Optional; not all providers expose structured metric data."
    }
  }
}
