Перейти к содержимому
Войти
Справочник API
Ресурс

AI Rule

Which new incidents or alerts OneUptime AI investigates and fixes, and how. A rule investigates what it matches (right away, or only if still open after a wait), and fixes it or not, asking first or not. A fix may run the project's runbooks (only the rule's, when it names some), Bash commands on a Runner the rule picks, the tools of the project's external MCP servers (only the rule's, when it names some), and open fix and telemetry pull requests in the project's code repositories (only the rule's, when it names some). With no rule, OneUptime AI investigates every one, and fixes every one while automatic fixing is on. These were auto remediation rules, and investigation rules are AI rules now too.

Модель AI Rule

Свойства

  • Название
    _id
    Тип
    Object ID
    Описание

    ID of this object

  • Название
    createdAt
    Тип
    Date
    Описание

    Date and Time when the object was created.

  • Название
    updatedAt
    Тип
    Date
    Описание

    Date and Time when the object was updated.

  • Название
    criteria
    Тип
    JSON
    Описание

    Versioned conditions that determine whether this rule matches a resource.

  • Название
    project
    Тип
    Project
    Описание

    Relation to Project Resource in which this object belongs

  • Название
    projectId
    Тип
    Object ID Обязательно
    Описание

    ID of your OneUptime Project in which this object belongs

  • Название
    name
    Тип
    Text Обязательно
    Описание

    Name of this AI rule.

  • Название
    description
    Тип
    Long Text
    Описание

    Description of this AI rule.

  • Название
    isEnabled
    Тип
    Boolean Обязательно
    Описание

    Whether this rule is enabled.

  • Название
    triggerEntityType
    Тип
    Text Обязательно
    Описание

    Which kind of new signal this rule decides about: Incident or Alert.

  • Название
    investigates
    Тип
    Boolean Обязательно
    Описание

    Whether OneUptime AI investigates the incidents or alerts this rule matches. With enabled rules that investigate, only their matches are investigated. Off, the rule only fixes, and does not change which incidents are investigated. The dashboard turns it on for every rule; left out of an API write, it is off.

  • Название
    onlyIfOpenAfterMinutes
    Тип
    Number
    Описание

    Investigate only incidents or alerts still open this many minutes after they were created: OneUptime AI waits that long, then investigates if it is still open. Leave empty to investigate right away. When several rules match, the shortest wait decides. At most 1440 minutes (a day).

  • Название
    fixes
    Тип
    Boolean Обязательно
    Описание

    Whether OneUptime AI fixes the incidents or alerts this rule matches, the way its Execution Mode says. Off, the rule only investigates them. With enabled rules, an incident is fixed only when a rule that fixes matches it. On by default.

  • Название
    executionMode
    Тип
    Text Обязательно
    Описание

    How a rule that fixes asks. Suggest asks before fixing: every fix the rule starts waits for one-click human approval. FullAuto fixes without asking: OneUptime AI fixes on its own where the cluster's or resource's AI agent page allows, a runbook it picks from the ones the rule names starts right away (one it picks from all of the project's runbooks still waits for approval), a change through an MCP server the rule names is made right away (through any of the project's MCP servers, it still waits for approval), and a rule that runs its runbooks every time starts them immediately.

  • Название
    remediationAction
    Тип
    Text Обязательно
    Описание

    OneUptimeAI (the default): OneUptime AI fixes the matched incident or alert - on the Kubernetes clusters and infrastructure it is linked to, the way each one's AI agent page allows, with the project's runbooks (only the rule's Runbooks when it names some) and with commands on the rule's Runner when it picks one. Runbooks: the rule starts every one of its Runbooks for every match, without OneUptime AI deciding. Whether a person approves first is the rule's Execution Mode.

  • Название
    aiSelectsRunbook
    Тип
    Boolean Обязательно
    Описание

    Kept for rules saved before rules were simplified: an AI planning run reads the incident/alert context and picks the most applicable runbook (from the attached candidates, or all enabled runbooks when none are attached), always proposing it for approval, and the rule does nothing else. Every OneUptime AI rule now lets AI pick a runbook on its own, so new rules leave this off.

  • Название
    aiComposesCommands
    Тип
    Boolean Обязательно
    Описание

    Kept for rules saved before rules were simplified: the AI investigates the incident/alert and composes Bash commands for the rule's Runner and Command Runners, and the rule does nothing else. Suggest mode proposes a command plan for one-click approval; FullAuto mode may execute commands inline, but only ones matching the command allowlist. A OneUptime AI rule now composes commands on its Runner when it picks one, so new rules leave this off.

  • Название
    commandAllowlist
    Тип
    JSON
    Описание

    Glob patterns for commands the AI may execute WITHOUT human approval under FullAuto (for example: systemctl restart *). Commands that do not match are proposed for one-click approval instead. Destructive commands are always refused by the built-in policy.

  • Название
    commandRunners
    Тип
    Runner
    Описание

    Kept for rules saved before rules were simplified: more Runners the AI may target with composed commands, besides the rule's Runner. A Runner runs a rule's commands only when the rule names it.

  • Название
    monitors
    Тип
    Monitor
    Описание

    Only trigger for incidents/alerts from these monitors. Leave empty to match any monitor.

  • Название
    incidentSeverities
    Тип
    Incident Severity
    Описание

    Only trigger for incidents with these severities (incident rules only). Leave empty to match any severity.

  • Название
    alertSeverities
    Тип
    Alert Severity
    Описание

    Only trigger for alerts with these severities (alert rules only). Leave empty to match any severity.

  • Название
    labels
    Тип
    Label
    Описание

    Only trigger for incidents/alerts that carry at least one of these labels. Leave empty to match any label.

  • Название
    monitorLabels
    Тип
    Label
    Описание

    Only trigger when the incident/alert's monitor carries at least one of these labels — the natural way to scope rules to environments (e.g. staging vs production). Leave empty to match any monitor label.

  • Название
    titlePattern
    Тип
    Long Text
    Описание

    Case-insensitive regex matched against the entity's title. Leave empty to match any title.

  • Название
    descriptionPattern
    Тип
    Long Text
    Описание

    Case-insensitive regex matched against the entity's description. Leave empty to match any description.

  • Название
    runbooks
    Тип
    Runbook
    Описание

    The runbooks OneUptime AI may pick and run for this rule. Leave empty to let it pick any of the project's runbooks. A rule whose Fix With is Runbooks starts every one of them for every match instead.

  • Название
    externalMcpServers
    Тип
    External MCP Server
    Описание

    The external MCP servers OneUptime AI may use while it investigates and fixes what this rule matches (an investigation uses only their tools that read). Leave empty to let it use all of the project's MCP servers; changes through them are then always proposed for approval first.

  • Название
    runner
    Тип
    Runner
    Описание

    The Runner OneUptime AI runs this rule's Bash commands on, inside your network. Empty means none: OneUptime AI runs no commands of its own for the rule. Commands on the affected Kubernetes cluster or host always go through its AI agent.

  • Название
    runnerId
    Тип
    Object ID
    Описание

    ID of the Runner OneUptime AI runs this rule's Bash commands on: one of the project's own Runners. Empty means none: OneUptime AI runs no commands of its own for the rule. Commands on the affected Kubernetes cluster or host always go through its AI agent.

  • Название
    codeRepositories
    Тип
    Code Repository
    Описание

    The code repositories OneUptime AI may read while it investigates and fixes what this rule matches, and open the rule's pull requests in. Leave empty to let it use every repository the project has connected.

  • Название
    llmProvider
    Тип
    LLM Provider
    Описание

    The LLM provider OneUptime AI uses for everything this rule starts: one of the project's providers or a global one. Empty: the project's default provider, else the global one.

  • Название
    llmProviderId
    Тип
    Object ID
    Описание

    ID of the LLM provider OneUptime AI uses for everything this rule starts. Empty: the project's default provider, else the global one.

  • Название
    openCodeFixPullRequests
    Тип
    Boolean Обязательно
    Описание

    When an investigation of an incident or alert this rule matches finds the cause in your code, OneUptime AI opens a pull request with the fix, for review. Nothing is merged. Acts only while fixing new incidents (or alerts) automatically is on. On by default.

  • Название
    openTelemetryPullRequests
    Тип
    Boolean Обязательно
    Описание

    When missing logs, traces or metrics stop an investigation of an incident or alert this rule matches, OneUptime AI opens a pull request that adds them, for review. Nothing is merged. Acts only while fixing new incidents (or alerts) automatically is on. On by default.

  • Название
    verificationWindowMinutes
    Тип
    Number
    Описание

    How long after the runbook starts the subject's monitors get to recover before verification fails. Defaults to 15 minutes.

  • Название
    autoResolveOnVerifiedRecovery
    Тип
    Boolean Обязательно
    Описание

    When verification confirms the monitors recovered inside the window, automatically resolve the incident/alert. Off by default — the timeline note is posted either way.

  • Название
    createdByUser
    Тип
    User
    Описание

    Relation to User who created this object (if this object was created by a User)

  • Название
    createdByUserId
    Тип
    Object ID
    Описание

    User ID who created this object.

GET или POST
/api/auto-remediation-rule/get-list

Список

Эта конечная точка позволяет получить разбитый на страницы список всех ваших AI Rule. По умолчанию на каждой странице отображается максимум десять AI Rule.

Необязательные параметры запроса

  • Limit
    limit
    Тип
    number
    Описание
    Количество объектов для получения. По умолчанию 10, вы можете увеличить это значение до 100
  • Skip
    skip
    Тип
    number
    Описание
    Количество объектов для пропуска. Это может быть полезно при пагинации

Необязательное тело запроса

Запрос списка

POST
/api/auto-remediation-rule/get-list?skip=0&limit=10
Заголовки
Content-Type: application/json
ApiKey: YOUR_API_KEY
Тело
{
  "select": {
    "fixes": true,
    "investigates": true,
    "openCodeFixPullRequests": true,
    "openTelemetryPullRequests": true,
    "onlyIfOpenAfterMinutes": true
  },
  "query": {
    "executionMode": "Example execution mode"
  },
  "sort": {
    "createdAt": -1
  }
}

Ответ

{
    "count": 10,
    "limit": 10,
    "skip": 0,
    "data": [
        {
            "_id": "929f6575-e3dd-4055-b17f-ea2ed1964260",
            "fixes": true,
            "investigates": true,
            "openCodeFixPullRequests": true,
            "openTelemetryPullRequests": true,
            "onlyIfOpenAfterMinutes": 10
        },
        {
            "_id": "f7c89fcc-54f2-4f96-bb80-e026fb92093e",
            "fixes": true,
            "investigates": true,
            "openCodeFixPullRequests": true,
            "openTelemetryPullRequests": true,
            "onlyIfOpenAfterMinutes": 10
        },
        {
            "_id": "e315dc9f-2744-49b7-9d0f-aaf946d965a6",
            "fixes": true,
            "investigates": true,
            "openCodeFixPullRequests": true,
            "openTelemetryPullRequests": true,
            "onlyIfOpenAfterMinutes": 10
        }
    ]
}
GET или POST
/api/auto-remediation-rule/:id/get-item

Получить элемент по ID

Эта конечная точка позволяет получить AI Rule по ID.

Обязательные параметры запроса

  • ID
    id
    Тип
    text
    Описание
    ID объекта

Необязательное тело запроса

Запрос получения элемента

POST
/api/auto-remediation-rule/:id/get-item
Заголовки
Content-Type: application/json
ApiKey: YOUR_API_KEY
Тело
{
  "select": {
    "fixes": true,
    "investigates": true,
    "openCodeFixPullRequests": true,
    "openTelemetryPullRequests": true,
    "onlyIfOpenAfterMinutes": true
  }
}

Ответ

{
    "_id": "929f6575-e3dd-4055-b17f-ea2ed1964260",
    "fixes": true,
    "investigates": true,
    "openCodeFixPullRequests": true,
    "openTelemetryPullRequests": true,
    "onlyIfOpenAfterMinutes": 10
}
POST
/api/auto-remediation-rule/count

Количество

Эта конечная точка позволяет получить количество всех ваших AI Rule.

Необязательное тело запроса

Запрос количества

POST
/api/auto-remediation-rule/count
Заголовки
Content-Type: application/json
ApiKey: YOUR_API_KEY
Тело
{
  "query": {
    "executionMode": "Example execution mode"
  }
}

Ответ

{
    "count": 107
}
POST
/api/auto-remediation-rule

Создать AI Rule

Эта конечная точка позволяет создать новый объект.

Тело запроса

  • Data
    data
    Тип
    JSON
    Описание
    Объект для создания в формате JSON

Запрос создания

POST
/api/auto-remediation-rule
Заголовки
Content-Type: application/json
ApiKey: YOUR_API_KEY
Тело
{
  "data": {
    "fixes": true,
    "investigates": true,
    "openCodeFixPullRequests": true,
    "openTelemetryPullRequests": true,
    "onlyIfOpenAfterMinutes": 10
  }
}

Ответ

{
    "_id": "929f6575-e3dd-4055-b17f-ea2ed1964260",
    "fixes": true,
    "investigates": true,
    "openCodeFixPullRequests": true,
    "openTelemetryPullRequests": true,
    "onlyIfOpenAfterMinutes": 10
}
PUT
/api/auto-remediation-rule/:id

Обновить по ID

Эта конечная точка позволяет обновить объект по его ID.

Тело запроса

  • Data
    data
    Тип
    JSON
    Описание
    Объект для обновления в формате JSON

Альтернативные методы

Для клиентов, которые не поддерживают запросы PUT, вы можете использовать POST или GET с теми же заголовками запроса и телом:

POST /api/auto-remediation-rule/:id/update-item

Запрос обновления

PUT
/api/auto-remediation-rule/:id
Заголовки
Content-Type: application/json
ApiKey: YOUR_API_KEY
Тело
{
  "data": {
    "fixes": true,
    "investigates": true,
    "openCodeFixPullRequests": true
  }
}

Ответ

{}
DELETE
/api/auto-remediation-rule/:id

Удалить по ID

Эта конечная точка позволяет удалить объект по его ID.

Альтернативные методы

Для клиентов, которые не поддерживают запросы DELETE, вы можете использовать POST или GET с теми же заголовками запроса и телом:

POST /api/auto-remediation-rule/:id/delete-item

Запрос удаления

DELETE
/api/auto-remediation-rule/:id
Заголовки
Content-Type: application/json
ApiKey: YOUR_API_KEY

Ответ

{}

Права доступа

Вашему API-токену нужны права доступа для создания, обновления, чтения или удаления этого ресурса. Если у вас нет прав на выполнение запроса, в качестве ответа будет отправлен статус 4xx.

Права на чтение

Требуется для чтения AI Rule

  • ProjectOwner
    Project Owner
    Owner of this project. Does everything Project Admin does, and also manages billing and payment methods, sets up SCIM, and can delete the project.
  • ProjectAdmin
    Project Admin
    Admin of this project. Creates, changes and deletes everything in it, including team members and their permissions, API keys, labels, SSO, rules and custom fields, and reads the audit log. Cannot manage billing, set up SCIM or delete the project.
  • ProjectMember
    Project Member
    Member of this project. Creates, changes and deletes monitors, incidents, alerts, status pages, on-call policies, scheduled maintenance, services and infrastructure, and runs runbooks. Project settings take Project Admin: team members and permissions, API keys, labels, SSO, rules, custom fields, states, secrets, dashboards, SLOs, and changing workflows and runbooks. Does not see API keys, the audit log, invoices, secrets, session replays or security data.
  • Viewer
    Viewer
    Reads the project's resources and changes nothing. Does not see API keys, the audit log, invoices, secrets, session replays, security data, or AI conversations, insights and remediation suggestions.
  • ReadAutoRemediationRule
    Read AI Rule
    This permission can read AI Rules in this project.

Права на создание

Требуется для создания AI Rule

  • ProjectOwner
    Project Owner
    Owner of this project. Does everything Project Admin does, and also manages billing and payment methods, sets up SCIM, and can delete the project.
  • ProjectAdmin
    Project Admin
    Admin of this project. Creates, changes and deletes everything in it, including team members and their permissions, API keys, labels, SSO, rules and custom fields, and reads the audit log. Cannot manage billing, set up SCIM or delete the project.
  • CreateAutoRemediationRule
    Create AI Rule
    This permission can create AI Rules in this project: which incidents and alerts OneUptime AI investigates and fixes.

Права на обновление

Требуется для обновления AI Rule

  • ProjectOwner
    Project Owner
    Owner of this project. Does everything Project Admin does, and also manages billing and payment methods, sets up SCIM, and can delete the project.
  • ProjectAdmin
    Project Admin
    Admin of this project. Creates, changes and deletes everything in it, including team members and their permissions, API keys, labels, SSO, rules and custom fields, and reads the audit log. Cannot manage billing, set up SCIM or delete the project.
  • EditAutoRemediationRule
    Edit AI Rule
    This permission can edit AI Rules in this project.

Права на удаление

Требуется для удаления AI Rule

  • ProjectOwner
    Project Owner
    Owner of this project. Does everything Project Admin does, and also manages billing and payment methods, sets up SCIM, and can delete the project.
  • ProjectAdmin
    Project Admin
    Admin of this project. Creates, changes and deletes everything in it, including team members and their permissions, API keys, labels, SSO, rules and custom fields, and reads the audit log. Cannot manage billing, set up SCIM or delete the project.
  • DeleteAutoRemediationRule
    Delete AI Rule
    This permission can delete AI Rules in this project.