この記事では、レガシ API を使用してアラート ルールを管理する方法について説明します。
重要
発表されたとおり、Log Analytics アラート API は 2025 年 10 月 1 日に廃止されます。 スケジュールされたクエリ ルール API を使用して、その日付までにログ検索アラートに移行する必要があります。 2019 年 6 月 1 日以降に作成された Log Analytics ワークスペースでは、scheduledQueryRules API を使用してアラート ルールを管理します。 古いワークスペースの現在の API に切り替えて、Azure Monitor scheduledQueryRules 利点を活用。
Log Analytics アラート REST API を使用すると、Log Analytics でアラートを作成および管理できます。 この記事では、API の詳細と、さまざまな操作を実行するためのいくつかの例を示します。
Log Analytics Search REST API は RESTful であり、Azure Resource Manager REST API 経由でアクセスできます。 この記事では、PowerShell コマンド ラインから ARMClient を使用して API にアクセスする例を示します。 このオープン ソースのコマンド ライン ツールを使用すると、Azure Resource Manager API の呼び出しが簡略化されます。
ARMClient と PowerShell の使用は、Log Analytics Search API にアクセスするために使用できる多くのオプションの 1 つです。 これらのツールを使用すると、RESTful Azure Resource Manager API を使用して Log Analytics ワークスペースを呼び出し、その中で検索コマンドを実行できます。 API は、さまざまな方法でプログラムで検索結果を使用できるように、JSON 形式で検索結果を出力します。
前提条件
現時点では、アラートは Log Analytics の保存された検索でのみ作成できます。 詳細については、ログ検索 REST APIを参照してください。
スケジュール
保存された検索には、1 つ以上のスケジュールを設定できます。 スケジュールでは、検索を実行する頻度と、条件を特定する時間間隔を定義します。 スケジュールには、次の表で説明するプロパティがあります。
プロパティ | 説明 |
---|---|
Interval |
検索を実行する頻度。 分単位で測定されます。 |
QueryTimeSpan |
条件が評価される時間間隔。
Interval に等しいかそれ以上である必要があります。 分単位で測定されます。 |
Version |
使用されている API バージョン。 現時点では、この設定は常に 1 する必要があります。 |
たとえば、Interval
が 15 分で、Timespan
が 30 分のイベント クエリを考えてみましょう。 この場合、クエリは 15 分ごとに実行されます。 条件が引き続き 30 分間にわたって true
に解決された場合、アラートがトリガーされます。
スケジュールを取得する
Get メソッドを使用して、保存された検索のすべてのスケジュールを取得します。
armclient get /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules?api-version=2015-03-20
保存された検索の特定のスケジュールを取得するには、スケジュール ID を指定して Get メソッドを使用します。
armclient get /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Subscription ID}/schedules/{Schedule ID}?api-version=2015-03-20
次の応答例は、スケジュールに対する応答です。
{
"value": [{
"id": "subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/sampleRG/providers/Microsoft.OperationalInsights/workspaces/MyWorkspace/savedSearches/0f0f4853-17f8-4ed1-9a03-8e888b0d16ec/schedules/a17b53ef-bd70-4ca4-9ead-83b00f2024a8",
"etag": "W/\"datetime'2016-02-25T20%3A54%3A49.8074679Z'\"",
"properties": {
"Interval": 15,
"QueryTimeSpan": 15,
"Enabled": true,
}
}]
}
スケジュールを作成する
新しいスケジュールを作成するには、一意のスケジュール ID で Put メソッドを使用します。 2 つのスケジュールは、異なる保存された検索に関連付けられている場合でも、同じ ID を持つことはありません。 Log Analytics コンソールでスケジュールを作成すると、スケジュール ID の GUID が作成されます。
注
Log Analytics API で作成されたすべての保存済み検索、スケジュール、アクションの名前は小文字にする必要があります。
$scheduleJson = "{'properties': { 'Interval': 15, 'QueryTimeSpan':15, 'Enabled':'true' } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/mynewschedule?api-version=2015-03-20 $scheduleJson
スケジュールを編集する
同じ保存された検索の既存のスケジュール ID で Put メソッドを使用して、そのスケジュールを変更します。 次の例では、スケジュールは無効になっています。 要求の本文には、スケジュールの etag が含まれている必要があります。
$scheduleJson = "{'etag': 'W/\"datetime'2016-02-25T20%3A54%3A49.8074679Z'\""','properties': { 'Interval': 15, 'QueryTimeSpan':15, 'Enabled':'false' } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/mynewschedule?api-version=2015-03-20 $scheduleJson
スケジュールを削除する
スケジュールを削除するには、スケジュール ID で Delete メソッドを使用します。
armclient delete /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Subscription ID}/schedules/{Schedule ID}?api-version=2015-03-20
アクション
スケジュールには複数のアクションを含めることができます。 アクションでは、電子メールの送信や Runbook の開始など、実行する 1 つ以上のプロセスを定義できます。 アクションでは、検索条件の結果が一部の条件と一致するタイミングを決定するしきい値を定義することもできます。 一部のアクションでは、しきい値が満たされたときにプロセスが実行されるように、両方を定義します。
すべてのアクションには、次の表で説明するプロパティがあります。 さまざまな種類のアラートには、次の表に示す他の異なるプロパティがあります。
プロパティ | 説明 |
---|---|
Type |
アクションの種類。 現在、使用可能な値は Alert と Webhook です。 |
Name |
アラートの表示名。 |
Version |
使用されている API バージョン。 現時点では、この設定は常に 1 する必要があります。 |
アクションを取得する
Get メソッドを使用して、スケジュールのすべてのアクションを取得します。
armclient get /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions?api-version=2015-03-20
アクション ID を指定して Get メソッドを使用して、スケジュールの特定のアクションを取得します。
armclient get /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Subscription ID}/schedules/{Schedule ID}/actions/{Action ID}?api-version=2015-03-20
アクションの作成または編集
新しいアクションを作成するには、スケジュールに固有のアクション ID で Put メソッドを使用します。 Log Analytics コンソールでアクションを作成する場合、GUID はアクション ID 用です。
注
Log Analytics API で作成されたすべての保存済み検索、スケジュール、アクションの名前は小文字にする必要があります。
同じ保存された検索の既存のアクション ID で Put メソッドを使用して、そのスケジュールを変更します。 要求の本文には、スケジュールの etag を含める必要があります。
新しいアクションを作成するための要求形式はアクションの種類によって異なるため、次のセクションでこれらの例を示します。
アクションの削除
アクションを削除するには、アクション ID と共に Delete メソッドを使用します。
armclient delete /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Subscription ID}/schedules/{Schedule ID}/Actions/{Action ID}?api-version=2015-03-20
アラート アクション
スケジュールには、アラート アクションを 1 つだけ含める必要があります。 アラート アクションには、次の表で説明するセクションが 1 つ以上含まれています。
セクション | 説明 | 使用方法 |
---|---|---|
しきい値 | アクションが実行されるタイミングの条件。 | Azure に拡張される前または後のすべてのアラートに必要です。 |
深刻さ | トリガーされたときにアラートを分類するために使用されるラベル。 | Azure に拡張される前または後のすべてのアラートに必要です。 |
抑制する | アラートからの通知を停止するオプション。 | Azure に拡張される前または後の、すべてのアラートに対して省略可能です。 |
アクション グループ | 電子メール、SMS、音声通話、Webhook、Automation Runbook、ITSM コネクタなど、必要なアクションが指定されている Azure ActionGroup の ID。 |
アラートが Azure に拡張された後に必要です。 |
アクションをカスタマイズする |
ActionGroup からの選択アクションの標準出力を変更します。 |
すべてのアラートに対して省略可能で、アラートが Azure に拡張された後に使用できます。 |
しきい値
アラート アクションには、しきい値が 1 つだけ必要です。 保存された検索の結果が、その検索に関連付けられているアクションのしきい値と一致すると、そのアクション内の他のすべてのプロセスが実行されます。 また、しきい値を含まない他の種類のアクションで使用できるように、アクションにはしきい値のみを含めることもできます。
しきい値には、次の表で説明するプロパティがあります。
プロパティ | 説明 |
---|---|
Operator |
しきい値比較の演算子。 gt = より大きい lt = 未満 |
Value |
しきい値の値。 |
たとえば、Interval
が 15 分、Timespan
が 30 分、Threshold
が 10 より大きいイベント クエリを考えてみましょう。 この場合、クエリは 15 分ごとに実行されます。 アラートは、30 分間に作成された 10 個のイベントを返した場合にトリガーされます。
次の応答例は、Threshold
のみのアクションに対する応答です。
"etag": "W/\"datetime'2016-02-25T20%3A54%3A20.1302566Z'\"",
"properties": {
"Type": "Alert",
"Name": "My threshold action",
"Threshold": {
"Operator": "gt",
"Value": 10
},
"Version": 1
}
Put メソッドを一意のアクション ID と共に使用して、スケジュールの新しいしきい値アクションを作成します。
$thresholdJson = "{'properties': { 'Name': 'My Threshold', 'Version':'1', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 10 } } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/mythreshold?api-version=2015-03-20 $thresholdJson
Put メソッドを既存のアクション ID と共に使用して、スケジュールのしきい値アクションを変更します。 要求の本文には、アクションの etag を含める必要があります。
$thresholdJson = "{'etag': 'W/\"datetime'2016-02-25T20%3A54%3A20.1302566Z'\"','properties': { 'Name': 'My Threshold', 'Version':'1', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 10 } } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/mythreshold?api-version=2015-03-20 $thresholdJson
深刻さ
Log Analytics を使用すると、管理とトリアージを容易にするために、アラートをカテゴリに分類できます。 アラートの重大度レベルは、informational
、warning
、および critical
です。 これらのカテゴリは、次の表に示すように、Azure アラートの正規化された重大度スケールにマップされます。
Log Analytics の重大度レベル | Azure アラートの重大度レベル |
---|---|
critical |
Sev 0 |
warning |
Sev 1 |
informational |
Sev 2 |
次の応答例は、Threshold
と Severity
のみを含むアクションを対象としています。
"etag": "W/\"datetime'2016-02-25T20%3A54%3A20.1302566Z'\"",
"properties": {
"Type": "Alert",
"Name": "My threshold action",
"Threshold": {
"Operator": "gt",
"Value": 10
},
"Severity": "critical",
"Version": 1
}
一意のアクション ID を持つ Put メソッドを使用して、Severity
スケジュールの新しいアクションを作成します。
$thresholdWithSevJson = "{'properties': { 'Name': 'My Threshold', 'Version':'1','Severity': 'critical', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 10 } } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/mythreshold?api-version=2015-03-20 $thresholdWithSevJson
Put メソッドを既存のアクション ID と共に使用して、スケジュールの重大度アクションを変更します。 要求の本文には、アクションの etag を含める必要があります。
$thresholdWithSevJson = "{'etag': 'W/\"datetime'2016-02-25T20%3A54%3A20.1302566Z'\"','properties': { 'Name': 'My Threshold', 'Version':'1','Severity': 'critical', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 10 } } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/mythreshold?api-version=2015-03-20 $thresholdWithSevJson
抑制する
Log Analytics ベースのクエリ アラートは、しきい値に達するか超えるたびに発生します。 クエリに示されているロジックに基づいて、一連の間隔でアラートが発生する可能性があります。 その結果、通知は常に送信されます。 このようなシナリオを回避するには、アラート ルールの 2 回目の通知が発生するまで、指定された時間待機するように Log Analytics に指示する Suppress
オプションを設定します。
たとえば、Suppress
が 30 分間設定されている場合、アラートは初めて発生し、構成された通知を送信します。 その後、アラート ルールの通知が再び使用されるまで 30 分間待機します。 中間期間に、アラート ルールは引き続き実行されます。 この期間中にアラート ルールが発生した回数に関係なく、Log Analytics によって指定された時間だけ通知のみが抑制されます。
ログ検索アラート ルールの Suppress
プロパティは、Throttling
値を使用して指定します。 抑制期間は、DurationInMinutes
値を使用して指定します。
次の応答例は、Threshold
、Severity
、および Suppress
プロパティのみを持つアクションに対しています。
"etag": "W/\"datetime'2016-02-25T20%3A54%3A20.1302566Z'\"",
"properties": {
"Type": "Alert",
"Name": "My threshold action",
"Threshold": {
"Operator": "gt",
"Value": 10
},
"Throttling": {
"DurationInMinutes": 30
},
"Severity": "critical",
"Version": 1
}
一意のアクション ID を持つ Put メソッドを使用して、Severity
スケジュールの新しいアクションを作成します。
$AlertSuppressJson = "{'properties': { 'Name': 'My Threshold', 'Version':'1','Severity': 'critical', 'Type':'Alert', 'Throttling': { 'DurationInMinutes': 30 },'Threshold': { 'Operator': 'gt', 'Value': 10 } } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/myalert?api-version=2015-03-20 $AlertSuppressJson
Put メソッドを既存のアクション ID と共に使用して、スケジュールの重大度アクションを変更します。 要求の本文には、アクションの etag を含める必要があります。
$AlertSuppressJson = "{'etag': 'W/\"datetime'2016-02-25T20%3A54%3A20.1302566Z'\"','properties': { 'Name': 'My Threshold', 'Version':'1','Severity': 'critical', 'Type':'Alert', 'Throttling': { 'DurationInMinutes': 30 },'Threshold': { 'Operator': 'gt', 'Value': 10 } } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/myalert?api-version=2015-03-20 $AlertSuppressJson
アクション グループ
Azure のすべてのアラートは、アクションを処理するための既定のメカニズムとしてアクション グループを使用します。 アクション グループを使用すると、アクションを 1 回指定し、同じアクションを繰り返し宣言しなくても、Azure 全体でアクション グループを複数のアラートに関連付けることができます。 アクション グループは、電子メール、SMS、音声通話、ITSM 接続、Automation Runbook、Webhook URI などの複数のアクションをサポートします。
アラートを Azure に拡張したユーザーの場合、アラートを作成できるように、スケジュールにアクション グループの詳細が Threshold
と共に渡される必要があります。 アラートを作成する前に、電子メールの詳細、Webhook URL、Runbook Automation の詳細、およびその他のアクションをアクション グループ内で最初に定義する必要があります。 Azure Portal で Azure Monitor から アクション グループを作成するか、アクション グループ APIを使用できます。
アクション グループをアラートに関連付けるには、アラート定義でアクション グループの一意の Azure Resource Manager ID を指定します。 次の例は、その使用方法を示しています。
"etag": "W/\"datetime'2017-12-13T10%3A52%3A21.1697364Z'\"",
"properties": {
"Type": "Alert",
"Name": "test-alert",
"Description": "I need to put a description here",
"Threshold": {
"Operator": "gt",
"Value": 12
},
"AzNsNotification": {
"GroupIds": [
"/subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup"
]
},
"Severity": "critical",
"Version": 1
}
Put メソッドを一意のアクション ID と共に使用して、スケジュールの既存のアクション グループを関連付けます。 次の例は、その使用方法を示しています。
$AzNsJson = "{'properties': { 'Name': 'test-alert', 'Version':'1', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 12 },'Severity': 'critical', 'AzNsNotification': {'GroupIds': ['subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup']} } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{Resource Group Name}/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/myAzNsaction?api-version=2015-03-20 $AzNsJson
Put メソッドを既存のアクション ID と共に使用して、スケジュールに関連付けられているアクション グループを変更します。 要求の本文には、アクションの etag を含める必要があります。
$AzNsJson = "{'etag': 'datetime'2017-12-13T10%3A52%3A21.1697364Z'\"', 'properties': { 'Name': 'test-alert', 'Version':'1', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 12 },'Severity': 'critical', 'AzNsNotification': { 'GroupIds': ['subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup'] } } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{Resource Group Name}/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/myAzNsaction?api-version=2015-03-20 $AzNsJson
アクションをカスタマイズする
既定では、アクションは標準のテンプレートと通知の形式に従います。 ただし、アクション グループによって制御されている場合でも、一部のアクションをカスタマイズできます。 現在、EmailSubject
と WebhookPayload
のカスタマイズが可能です。
アクション グループの EmailSubject をカスタマイズする
既定では、アラートの電子メールの件名は、<AlertName>
のアラート通知 <WorkspaceName>
です。 ただし、件名をカスタマイズして、単語またはタグを指定して、受信トレイでフィルター ルールを簡単に使用できるようにすることができます。 次の例のように、カスタマイズした電子メール ヘッダーの詳細を ActionGroup
の詳細と共に送信する必要があります。
"etag": "W/\"datetime'2017-12-13T10%3A52%3A21.1697364Z'\"",
"properties": {
"Type": "Alert",
"Name": "test-alert",
"Description": "I need to put a description here",
"Threshold": {
"Operator": "gt",
"Value": 12
},
"AzNsNotification": {
"GroupIds": [
"/subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup"
],
"CustomEmailSubject": "Azure Alert fired"
},
"Severity": "critical",
"Version": 1
}
Put メソッドを一意のアクション ID と共に使用して、既存のアクション グループをスケジュールのカスタマイズに関連付けます。 次の例は、その使用方法を示しています。
$AzNsJson = "{'properties': { 'Name': 'test-alert', 'Version':'1', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 12 },'Severity': 'critical', 'AzNsNotification': {'GroupIds': ['subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup'], 'CustomEmailSubject': 'Azure Alert fired'} } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{Resource Group Name}/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/myAzNsaction?api-version=2015-03-20 $AzNsJson
Put メソッドを既存のアクション ID と共に使用して、スケジュールに関連付けられているアクション グループを変更します。 要求の本文には、アクションの etag を含める必要があります。
$AzNsJson = "{'etag': 'datetime'2017-12-13T10%3A52%3A21.1697364Z'\"', 'properties': { 'Name': 'test-alert', 'Version':'1', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 12 },'Severity': 'critical', 'AzNsNotification': {'GroupIds': ['subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup']}, 'CustomEmailSubject': 'Azure Alert fired' } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{Resource Group Name}/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/myAzNsaction?api-version=2015-03-20 $AzNsJson
アクション グループの WebhookPayload をカスタマイズする
既定では、Log Analytics のアクション グループを介して送信される Webhook の構造は固定されています。 ただし、Webhook エンドポイントの要件を満たすためにサポートされている特定の変数を使用して、JSON ペイロードをカスタマイズできます。 詳細については、ログ検索アラートルールのWebhookアクションを参照してください。
カスタマイズされた webhook の詳細は、ActionGroup
の詳細と共に送信する必要があります。 これらは、アクション グループ内で指定されたすべての Webhook URI に適用されます。 次の例は、その使用方法を示しています。
"etag": "W/\"datetime'2017-12-13T10%3A52%3A21.1697364Z'\"",
"properties": {
"Type": "Alert",
"Name": "test-alert",
"Description": "I need to put a description here",
"Threshold": {
"Operator": "gt",
"Value": 12
},
"AzNsNotification": {
"GroupIds": [
"/subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup"
],
"CustomWebhookPayload": "{\"field1\":\"value1\",\"field2\":\"value2\"}",
"CustomEmailSubject": "Azure Alert fired"
},
"Severity": "critical",
"Version": 1
},
Put メソッドを一意のアクション ID と共に使用して、既存のアクション グループをスケジュールのカスタマイズに関連付けます。 次の例は、その使用方法を示しています。
$AzNsJson = "{'properties': { 'Name': 'test-alert', 'Version':'1', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 12 },'Severity': 'critical', 'AzNsNotification': {'GroupIds': ['subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup'], 'CustomEmailSubject': 'Azure Alert fired','CustomWebhookPayload': '{\"field1\":\"value1\",\"field2\":\"value2\"}'} } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{Resource Group Name}/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/myAzNsaction?api-version=2015-03-20 $AzNsJson
Put メソッドを既存のアクション ID と共に使用して、スケジュールに関連付けられているアクション グループを変更します。 要求の本文には、アクションの etag を含める必要があります。
$AzNsJson = "{'etag': 'datetime'2017-12-13T10%3A52%3A21.1697364Z'\"', 'properties': { 'Name': 'test-alert', 'Version':'1', 'Type':'Alert', 'Threshold': { 'Operator': 'gt', 'Value': 12 },'Severity': 'critical', 'AzNsNotification': {'GroupIds': ['subscriptions/1234a45-123d-4321-12aa-123b12a5678/resourcegroups/my-resource-group/providers/microsoft.insights/actiongroups/test-actiongroup']}, 'CustomEmailSubject': 'Azure Alert fired','CustomWebhookPayload': '{\"field1\":\"value1\",\"field2\":\"value2\"}' } }"
armclient put /subscriptions/{Subscription ID}/resourceGroups/{Resource Group Name}/Microsoft.OperationalInsights/workspaces/{Workspace Name}/savedSearches/{Search ID}/schedules/{Schedule ID}/actions/myAzNsaction?api-version=2015-03-20 $AzNsJson
次のステップ
- REST API を使用して、Log Analytics で ログ検索を実行します。
- Azure Monitor でのログ検索アラートのについて説明します。
- Azure Monitor でログ検索アラート ルールを作成、編集、または管理方法について説明します。