アラートアクションは、イベントアラートに対する応答です。アラートアクションを作成するには、1 つ以上のイベントを指定し、電子メールの送信やワークフローの実行など、そのイベントに対してアラートが送信されたときに実行する 1 つ以上のアクションを指定します。特定のイベントアラートに対して複数のアラートアクションを指定できます。
category プロパティーは、アラートアクションが実行されるイベントのカテゴリを指定します。各カテゴリには、1 つ以上のイベントが含まれます。アラートアクションを作成または一覧表示すると、各カテゴリ内のイベントが一覧表示されます。デフォルトでは、アラートアクションはカテゴリ内のすべてのイベントに対して実行されます。アラートアクションがイベントのサブセットに対してのみ実行される場合、このアラートアクションを実行することのないイベントを表すプロパティーの値を false に変更してください。
次の表では、指定できるイベントカテゴリについて説明します。
|
handler プロパティーは、指定されたイベントが発生したときに実行するアクションのタイプを指定します。次の表に示すように、handler のほとんどの値には、追加のプロパティーを設定する必要があります。
|
すべてのアラートアクションを一覧表示すると、各アラートアクションについて、イベントカテゴリとそのカテゴリ内の各イベントのみが一覧表示されます。アラートアクションに対して定義されている応答も表示するには、単一アラートアクションの一覧表示を参照してください。
警告アクションを取得するリクエストの例:
GET /api/alert/v1/actions HTTP/1.1 Authorization: Basic Tm8gcGVla2luZyE= Host: zfs-storage.example.com:215 Accept: application/json
結果例:
HTTP/1.1 200 OK
X-Zfssa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 1395
{
"actions": [
{
"category": "smf",
"uuid": "actions-uuid1",
"failed_services": true,
"degraded_services": true,
"repaired_services": false,
"actions": "actions-000",
"href": "/api/alert/v2/actions/actions-000"
},
{
"category": "analytics",
"uuid": "actions-uuid2",
"analytics_datasets_auto-suspend_notify": false,
"analytics_datasets_auto-suspend_warning": false,
"analytics_memory_total_exceeded": true,
"analytics_memory_total_normal": false,
"analytics_usage_exceeded": true,
"analytics_usage_normal": false,
"actions": "actions-001",
"href": "/api/alert/v2/actions/actions-001"
}
]
}
一覧表示する特定のアラートアクションを指定すると、そのアラートアクションについて、イベントカテゴリ、そのカテゴリ内の各イベント、および各応答やアクションが一覧表示されます。
次のアラートアクションには 3 つの応答があり、true イベントの 1 つが発生したときにすべて実行されます。
リクエストの例:
GET /api/alert/v1/actions/actions-000 HTTP/1.1
結果例:
HTTP/1.1 200 OK
X-Zfssa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 331
{
"actions": {
"href": "/api/alert/v2/actions/actions-000",
"category": "smf",
"uuid": "actions-uuid1",
"failed_services": true,
"degraded_services": true,
"repaired_services": false,
"action-000": {
"handler": "email",
"address": "admin@example.com",
"subject": "failed or degraded service",
"href": "/api/alert/v2/actions/actions-000/action-000"
},
"action-001": {
"handler": "email",
"address": "it-team@example.com",
"subject": "failed or degraded service",
"href": "/api/alert/v2/actions/actions-000/action-001"
},
"action-002": {
"handler": "syslog",
"href": "/api/alert/v2/actions/actions-000/action-002"
}
}
}
アラートアクションを作成する際には、このカスタム応答を定義するイベントのカテゴリである category プロパティーの値を指定する必要があります。category の値のリストについては、表 8, アラートアクションイベントカテゴリを参照してください。
リクエストの例:
POST /api/alert/v1/actions HTTP/1.1
Host: zfs-storage.example.com:215
X-Auth-Session: uerqghq84vbdv
Content-Type: application/json
Content-Length: 30
{"category": "smf"}
結果例:
結果には、指定されたイベントカテゴリのすべてのイベントが一覧表示されます。デフォルトでは、カテゴリ内のすべてのイベントによって応答アクションが実行されます (これらはすべて true に設定されています)。
HTTP/1.1 201 Created
X-Zfssa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 118
Location: /api/alert/v1/actions/actions-000
{
"actions": {
"href": "/api/alert/v2/actions/actions-000",
"category": "smf",
"uuid": "actions-uuid",
"failed_services": true,
"degraded_services": true,
"repaired_services": true
}
}
指定されたイベントカテゴリの一部のイベントで応答アクションが実行されないようにする場合は、それらのイベントを表すプロパティーを false に設定します。
次の例では、修復されたサービスに対して、障害が発生したサービスや劣化したサービスとは異なる応答を定義できます。
リクエストの例:
PUT /api/alert/v1/actions/actions-000 HTTP/1.1
Host: zfs-storage.example.com:215
X-Auth-Session: uerqghq84vbdv
Content-Type: application/json
Content-Length: 30
{"repaired_services": false}
結果例:
HTTP/1.1 202 Accepted
X-Zfssa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 195
{
"actions": {
"href": "/api/alert/v2/actions/actions-000",
"category": "smf",
"uuid": "actions-uuid",
"failed_services": true,
"degraded_services": true,
"repaired_services": false
}
}
デフォルトでは、イベントアラートはアラートログに記録されます。前述の例では、アラートログへの送信に加えて、応答を定義するイベントを指定しました。これらのイベントへの応答を定義するには、特定のアラートアクションの handler プロパティーの値を指定します。handler の値のリストについては、表 9, アラートアクションの応答タイプを参照してください。
リクエストの例:
この例では、actions-000 アラートの admin に電子メールを送信するアラートアクションを作成します。
POST /api/alert/v1/actions/actions-000 HTTP/1.1
Host: zfs-storage.example.com:215
X-Auth-Session: uerqghq84vbdv
Content-Type: application/json
Content-Length: 68
{"handler": "email", "address": "admin@example.com", "subject": "failed or degraded service"}
結果例:
HTTP/1.1 201 Created
X-Zfssa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 177
Location: /api/alert/v1/actions/actions-000/action-000
{
"action": {
"href": "/api/alert/v1/actions/actions-002/action-000",
"handler": "email",
"address": "admin@example.com",
"subject": "failed or degraded service"
}
}
同じイベントに対して追加の応答を指定するには、同じアラートアクションに対して POST リクエストを再度発行し、別のハンドラを指定するか、同じハンドラとそのハンドラの別の引数を指定します。1 つのリクエストで複数の handler プロパティーを指定した場合、最後のプロパティーを除くすべての handler プロパティーは無視されます。
次の例は短縮されています。これらのリクエストは、単一アラートアクションの一覧表示に示すように、/api/alert/v1/actions/actions-000/action-001 および /api/alert/v1/actions/actions-000/action-002 を作成します。
POST /api/alert/v1/actions/actions-002 HTTP/1.1
...
{"handler": "email", "address": "it-team@example.com", "subject": "failed or degraded service"}
POST /api/alert/v1/actions/actions-002 HTTP/1.1
...
{"handler": "syslog"}
応答を変更するには、変更する応答の HREF を指定します。
PUT /api/alert/v1/actions/actions-000/action-001 HTTP/1.1
Host: zfs-storage.example.com:215
X-Auth-Session: uerqghq84vbdv
Content-Type: application/json
Content-Length: 28
{"address": "it-group@example.com"}
応答を削除するには、削除する応答の HREF を指定します。
DELETE /api/alert/v1/actions/actions-000/action-000 HTTP/1.1 Host: zfs-storage.example.com:215 X-Auth-Session: uerqghq84vbdv HTTP/1.1 204 No Content
アラートアクションを削除するには、削除するアラートアクションの HREF を指定します。
リクエストの例:
DELETE /api/alert/v1/actions/actions-003 HTTP/1.1 Authorization: Basic Tm8gcGVla2luZyE= Host: zfs-storage.example.com:215
結果例:
HTTP/1.1 204 No Content X-Zfssa-Appliance-Api: 1.0