すべてのプロダクト
Search
ドキュメントセンター

Simple Log Service:アラートリソースデータのデータ構造

最終更新日:Jun 17, 2026

ユーザー、ポリシー、テンプレートなどの各アラートリソースタイプには、リソースとレコードで構成される定義済みのデータ構造があります。

概要

アラートリソースデータには、ユーザー、ユーザーグループ、オンコールグループ、Webhook インテグレーション、ルート統合、抑制、サイレンスポリシーなどのアラートポリシー、アクションポリシー、コンテンツテンプレート、およびその他のカスタムリソースデータが含まれます。

説明

抑制ポリシーは推奨されません。

アラートリソースデータは、リソースとレコードの 2 つのカテゴリに分類されます。たとえば、ユーザーはリソースであり、そのユーザーに関する情報はレコードです。

カテゴリ

プロパティ

説明

リソース

resource_name

リソースを識別する名前。たとえば、ユーザーのリソース名は sls.common.user です。

レコード

id

レコードの一意の ID。データ型:文字列。

tag

レコードのタグ。データ型:文字列。

value

レコードの完全な値。データ型: JSON 文字列。

アラートリソースデータの構造

リソースタイプ

resource_name フィールド

record_id フィールド

record_tag フィールド

備考

ユーザー

sls.common.user

user_id

user_name

{
    "user_id": "tanaka_ichiro",
    "user_name": "田中一郎",
    "email": [
        "***@example.com"
    ],
    "country_code": "86",
    "phone": "133****3333",
    "enabled": true,
    "sms_enabled": true,
    "voice_enabled": true
}

なし

ユーザーグループ

sls.common.user_group

user_group_id

user_group_name

{
    "user_group_id": "devops",
    "user_group_name": "DevOps チーム",
    "enabled": true,
    "members": [
        "tanaka_ichiro"
    ]
}

なし

オンコールグループ

sls.alert.oncall_group

oncall_id

oncall_name

{
    "oncall_id": "default_oncall",
    "oncall_name": "デフォルトオンコール",
    "enabled": true,
    "overrides": [],
    "rotations": [
        {
            "targets": [
                {
                    "type": "user",
                    "target_id": "tanaka_ichiro"
                },
                {
                    "type": "user_group",
                    "target_id": "devops"
                }
            ],
            "end_time": 0,
            "shift_day": "",
            "shift_time": "12:00",
            "shift_type": "day",
            "start_time": 1633017600,
            "shift_minute": 0,
            "end_time_type": "none",
            "shift_interval": 1,
            "shift_week_custom": null,
            "restriction_date_type": "workday",
            "restriction_time_type": "allday",
            "restriction_week_range": null,
            "restriction_time_custom_range": null
        }
    ],
    "calendar_id": "default_calendar"
}

この設定は複雑なため、コンソールを使用することを推奨します。

Webhook インテグレーション

sls.alert.action_webhook

id

name

{
    "id": "custom-webhook",
    "name": "カスタム Webhook",
    "type": "custom",
    "url": "http://localhost:9099/data/webhook",
    "method": "POST",
    "headers": [
        {
            "key": "Content-Type",
            "value": "application/json"
        },
        {
            "key": "Foo",
            "value": "bar"
        }
    ]
}
{
    "id": "dingtalk",
    "name": "DingTalk Webhook",
    "type": "dingtalk",
    "url": "https://oapi.dingtalk.com/robot/send?access_token=**********",
    "method": "POST",
    "secret": "SEC**********",
    "headers": []
}
  • type を Webhook タイプに設定します。有効な値:

    • dingtalk:DingTalk。

    • wechat:WeCom。

    • lark:Lark。

    • slack:Slack。

    • custom:カスタム Webhook。

  • カスタム以外のすべてのタイプでは、method を POST に設定し、headers を空の配列に設定します。

  • type を dingtalk または lark に設定し、DingTalk または Lark でセキュリティチェック方法を署名検証に設定する場合は、secret フィールドを追加する必要があります。

    署名キーは、DingTalk または Lark のボット管理インターフェイスから取得できます。

アラートポリシー

sls.alert.alert_policy

policy_id

policy_name

{
    "policy_id": "sls.builtin",
    "policy_name": "SLS 組み込みアラートポリシー",
    "parent_id": "sls.root",
    "is_default": false,
    "group_script": "fire(action_policy=\"sls.builtin\", group={\"project\": \"__a__\", \"uid\": alert.aliuid}, group_wait=\"5s\", group_interval=\"2m\", repeat_interval=\"2m\")\nstop()\nfire(action_policy=\"sls.builtin\", group={\"alert_id\": alert.alert_id}, group_wait=\"5s\", group_interval=\"10s\", repeat_interval=\"2m\")\nif alert.labels.name ~= \"^\\\\w+s$\":\n\tfire(action_policy=\"sls.builtin\", group={\"product\": \"xxs\"}, group_wait=\"5s\", group_interval=\"10s\", repeat_interval=\"2m\")\n\tstop()\nstop()\nfire(action_policy=\"sls.builtin\", group={\"label_name\": alert.labels.name}, group_wait=\"10s\", group_interval=\"10s\", repeat_interval=\"2m\")",
    "inhibit_script": "if alert.severity >= 8:\n    silence alert.severity < 6",
    "silence_script": ""
}
  • is_default を false に設定します。

  • group_script はルート集約ポリシーです。

  • inhibit_script は抑制ポリシーです。

  • silence_script はサイレンスポリシーです。

  • SDK を使用してこれらのフィールドを設定する場合、group_scriptinhibit_script、および silence_script には UI メタデータなしで DSL スクリプト情報のみが含まれるため、コンソールは対応するグラフィカル構造をレンダリングできません。

アクションポリシー

sls.alert.action_policy

action_policy_id

action_policy_name

{
    "action_policy_id": "sls.builtin",
    "action_policy_name": "SLS 組み込みアクションポリシー",
    "labels": {},
    "is_default": false,
    "primary_policy_script": "fire(type=\"webhook_integration\", integration_type=\"dingtalk\", webhook_id=\"dingtalk-test\", template_id=\"default-template\", period=\"any\")",
    "secondary_policy_script": "fire(type=\"voice\", users=[\"suzuki\"], groups=[\"group-suzuki\"], template_id=\"default-template\")",
    "escalation_start_enabled": false,
    "escalation_start_timeout": "10s",
    "escalation_inprogress_enabled": false,
    "escalation_inprogress_timeout": "10s",
    "escalation_enabled": false,
    "escalation_timeout": "4h0m0s"
}
  • is_defaultfalse に設定します。

  • labels は予約済みのパラメーターです。 null オブジェクトに設定します。

  • primary_policy_script は主要なアクションポリシーです。

  • secondary_policy_script はセカンダリアクションポリシーです。

  • escalation_* フィールドは、セカンダリアクションポリシーを有効にするかどうかを制御します。詳細については、コンソール上の設定項目をご参照ください。

  • SDK を使用してこれらのフィールドを設定する場合、primary_policy_scriptsecondary_policy_script には UI メタデータを含まない DSL スクリプト情報のみが含まれるため、コンソールでは対応するグラフィカル構造をレンダリングできません。

コンテンツテンプレート

sls.alert.content_template

template_id

template_name

{
    "template_id": "default-template",
    "template_name": "デフォルトテンプレート",
    "is_default": false,
    "templates": {
        "fc": {
            "limit": 0,
            "locale": "zh-CN",
            "content": "",
            "send_type": "merged"
        },
        "sms": {
            "locale": "zh-CN",
            "content": ""
        },
        "lark": {
            "title": "Alerthub アラートテスト ${alert_name}",
            "locale": "zh-CN",
            "content": ""
        },
        "email": {
            "locale": "zh-CN",
            "content": "",
            "subject": "SLS アラートテスト-suzuki-test"
        },
        "slack": {
            "title": "Alerthub アラートテスト ${alert_name}",
            "locale": "zh-CN",
            "content": ""
        },
        "voice": {
            "locale": "zh-CN",
            "content": ""
        },
        "wechat": {
            "title": "Alerthub アラートテスト ${alert_name}",
            "locale": "zh-CN",
            "content": ""
        },
        "webhook": {
            "limit": 0,
            "locale": "zh-CN",
            "content": "",
            "send_type": "batch"
        },
        "dingtalk": {
            "title": "Alerthub アラートテスト ${alert_name}",
            "locale": "zh-CN",
            "content": ""
        },
        "event_bridge": {
            "locale": "zh-CN",
            "content": "",
            "subject": "wkb-test"
        },
        "message_center": {
            "locale": "zh-CN",
            "content": ""
        }
    }
}
  • is_default を false に設定します。

  • templates には、各通知チャネルのテンプレート設定が含まれます。チャネルの content の値が空の場合、システムのデフォルトテンプレートが使用されます。詳細については、「デフォルトのコンテンツテンプレート」をご参照ください。

  • locale の値は zh-CN または en-US です。

  • webhook および fc チャネルの場合、send_type の値は single または batch です。single の場合、アラートごとに通知が送信されます。batch の場合、アラートはマージされ、1 つの通知として送信されます。

デフォルトカレンダー

sls.common.calendar

calendar_id

calendar_name

{
    "calendar_id": "default_calendar",
    "calendar_name": "デフォルトカレンダー",
    "timezone": "Asia/Shanghai",
    "workdays": [
        1,
        2,
        3,
        4,
        5
    ],
    "worktime": [
        {
            "end_time": "21:00",
            "start_time": "09:00"
        }
    ],
    "reset_days": [],
    "holiday_sync": "china"
}
  • デフォルトカレンダーの ID は default_calendar に固定されています。

  • この設定は複雑なため、コンソールを使用することを推奨します。

DSL 構文の説明

以下のセクションでは、各ポリシータイプの DSL 設定例を示します。

重要

DSL の設定は複雑です。最初にコンソールでポリシーを設定し、次にネットワークリクエストのペイロードを検査することを推奨します。

ルート統合ポリシーの設定

  • コンソールでの設定 告警策略

  • DSL 設定

    if alert.severity >= 8:
        fire(action_policy="sls.builtin", group={"alert.project": alert.project, "alert.alert_id": alert.alert_id}, group_by_all_labels=true, group_wait="15s", group_interval="5m", repeat_interval="1h")
        stop()
    fire(action_policy="sls.builtin", group={"alert.project": alert.project}, group_by_all_labels=false, group_wait="15s", group_interval="5m", repeat_interval="1h")

    基本的な構文は次のとおりです:

    • if alert.severity >= 8は条件ノードです。

    • fire() はルート統合ノードです。

      • action_policy はアクションポリシー ID です。

      • group は集約の基準で、データ型は dict です。

      • group_by_all_labels は、すべてのラベルに基づいてアラートを集約するかどうかを指定します。有効な値: true と false。

      • group_wait は初期待機時間です。

      • group_interval は変更の待機時間です。

      • repeat_intervalrepeat_interval繰り返し待機時間です。注意:この値は 推奨されません

    • stop() は終了ノードです。

抑制ポリシーの設定

  • コンソールでの設定 告警策略

  • DSL 設定

    if alert.severity >= 8:
        silence alert.severity < 8
        stop()

    基本的な構文は次のとおりです:

    • if alert.severity >= 8 は条件ノードです。

    • silence alert.severity < 8 は抑制ノードです。

    • stop() は終了ノードです。

サイレンスポリシーの設定

  • コンソールでの設定 告警策略

  • DSL 設定

    drop(end=1638189177) alert.alert_name == "test-alert"
    accept alert.labels.env == "prod"

    基本的な構文は次のとおりです:

    • drop は無音を示します。

    • accept は、アラートがサイレント化されないことを示します。

    • startend は、秒単位の UNIX タイムスタンプで時間範囲を指定します。

      • 期間指定: 開始終了を設定します。

      • 特定の時刻まで:end のみ設定します。

      • 一定期間: end のみ設定します。

      • 無期限: startend も設定しません。

アクションポリシーの設定

  • コンソールでの設定 行动策略

  • DSL 設定

    if alert.severity >= 8:
        fire(type="sms", users=[], groups=[], oncall_groups=["alert-test-oncall"], template_id="sls.builtin.cn", check_quota="true", period="any")
        stop()
    if alerts.severity < 8:
        fire(type="webhook_integration", integration_type="dingtalk", webhook_id="suzuki-test", template_id="sls.builtin.cn", period="any")
        stop()
    重要
    • if alert.xxx は、いずれかのアラートが一致すると条件が満たされることを示します。

    • if alerts.xxx は、すべてのアラートが一致した場合に条件が満たされることを示します。

次のセクションでは、各チャネルの設定例を示します:

  • コンソールでの設定 行动策略

  • DSL 設定

    fire(type="sms", users=["suzuki"], groups=[], oncall_groups=[], template_id="sls.builtin.cn", check_quota="true", period="workday")
    fire(type="voice", users=[], groups=[], oncall_groups=["alert-test-oncall"], template_id="sls.builtin.cn", check_quota="true", period="worktime")
    fire(type="email", users=[], groups=["alert-test"], oncall_groups=[], template_id="sls.builtin.cn", check_quota="true", period="any")
    fire(type="webhook_integration", integration_type="dingtalk", webhook_id="suzuki-test", template_id="sls.builtin.cn", period="any")
    fire(type="webhook_integration", integration_type="wechat", webhook_id="wechat-test", template_id="sls.builtin.cn", period="any")
    fire(type="message_center", template_id="sls.builtin.cn", check_quota="true", period="any")
    fire(type="event_bridge", region="cn-hangzhou", bus_name="bus-demo", template_id="sls.builtin.cn", period="any")
    fire(type="fc", region="cn-shanghai", service="suzuki-test", qualifier="LATEST", function="sls-ops-1", template_id="sls.builtin.cn", period="any")
    fire(type="set_ticket_owner", choice="random", users=[], groups=[], oncall_groups=["alert-test-oncall"])

    基本的な構文は次のとおりです:

    fire() を使用して通知チャネルを設定します。詳細については、「通知チャネル」をご参照ください。