> ## Documentation Index
> Fetch the complete documentation index at: https://docs.molesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建规则

> 创建告警规则。

```http theme={null}
POST /api/v1/alerts/rules
```

规则的 `kind` 为 `scheduled`、`real_time` 或 `anomaly`。创建和修改规则需要
`alerts.manage`。不同检测器的字段见[告警](/zh-Hans/alerting)。

<RequestExample>
  ```json body theme={null}
  {
    "name": "High error rate",
    "description": "More than 100 errors in one minute",
    "enabled": true,
    "kind": "scheduled",
    "query": {
      "language": "sql",
      "statement": "SELECT count(*) AS c FROM app WHERE level = 'error'",
      "period_secs": 60,
      "stream": { "name": "app", "stream_type": "logs" }
    },
    "trigger": {
      "operator": "gt",
      "threshold": 100,
      "for_periods": 1,
      "silence_secs": 300
    },
    "thresholds": [],
    "severity": "critical",
    "escalation_policy_id": "<policy-id>",
    "labels": { "team": "checkout" },
    "annotations": {}
  }
  ```
</RequestExample>
