レガシの Log Analytics Alert REST API

この記事では、レガシ API を利用するアラートの管理方法について説明します。

重要

発表されたとおり、Log Analytics Alert API は 2025 年 10 月 1 日に廃止されます。 その日付までに、ログ検索アラートに対してスケジュールされたクエリ ルール API を使用するように移行する必要があります。 2019 年 6 月 1 日以降に作成された Log Analytics ワークスペースは、scheduledQueryRules API を使用してアラート ルールを管理しています。 上記以前に作成されたワークスペースでは、Azure Monitor の scheduledQueryRules のメリットを活用するために現行の API に切り替えてください。

Log Analytics のアラート REST API は、Log Analytics でアラートを作成し、管理するために使用できます。 この記事では、API の詳細についてと、さまざまな操作を実行するいくつかの例を説明します。

Log Analytics の検索 REST API は RESTful であり、Azure Resource Manager REST API を使用してアクセスできます。 この記事では、 ARMClient を使用して PowerShell コマンド ラインから API にアクセスする例を示します。 これは、Azure Resource Manager API の呼び出しを簡略化する、オープン ソースのコマンドライン ツールです。

Log Analytics 検索 API には、ARMClient や PowerShell を使用する以外にもさまざまな方法でアクセスできます。 これらのツールを使用すると、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

保存した検索条件に関して特定のスケジュールを取得するには、Get メソッドにスケジュール ID を渡します。

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,
      }
   }]
}

スケジュールを作成する

新しいスケジュールを作成するには、Put メソッドに一意のスケジュール ID を渡します。 たとえ異なる保存された検索に関連付けられている場合であっても、2 つのスケジュールが同じ ID を持つことはできません。 Log Analytics コンソールでスケジュールを作成すると、スケジュール ID に対して GUID が作成されます。

Note

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

Actions

スケジュールでは複数のアクションを使用できます。 アクションでは、メールの送信や 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

Get メソッドと共にアクション ID を使用して、スケジュールの特定のアクションを取得します。

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 を定義するためのものです。

Note

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 つ以上含まれています。

Section 説明 使用法
Threshold アクションがいつ実行されるかの条件。 Azure に拡張される前と後の両方の、すべてのアラートで必要です。
重大度 アラートがトリガーされるときに分類に使用されるラベル。 Azure に拡張される前と後の両方の、すべてのアラートで必要です。
Suppress アラートからの通知を停止するオプション。 Azure に拡張される前と後の両方の、すべてのアラートで省略可能です。
アクション グループ メール、SMS、音声通話、Webhook、自動化ランブック、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

スケジュールのしきい値アクションを編集するには、既存のアクション ID を Put メソッドに渡します。 要求の本体には、アクションの 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 を使用するとアラートをカテゴリに分類し、簡単に管理およびトリアージできます。 アラートの重大度レベルは informationalwarning、および critical です。 これらのカテゴリは、次の表に示すように、Azure アラートの正規化された重大度スケールにマップされます。

Log Analytics の重大度レベル Azure Alerts の重大度レベル
critical 重大度 0
warning 重大度 1
informational 重大度 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
}

スケジュールの新しいアクションを Severity で作成するには、Put メソッドに一意のアクション ID を渡します。

$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

スケジュールの重大度アクションを編集するには、既存のアクション ID を Put メソッドに渡します。 要求の本体には、アクションの 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

Suppress

Log Analytics ベースのクエリ アラートは、しきい値に達するか超過するたびに発生します。 クエリに暗黙的に示されているロジックに基づいて、一連の間隔でアラートが発生する可能性があります。 その結果、通知は常に送信されます。 このようなシナリオを防ぐには、ユーザーは、指定した時間待機してからアラート ルールの 2 回目の通知が発生するように Log Analytics に指示する Suppress オプションを設定することができます。

たとえば、Suppress が 30 分に設定された場合、まず最初のアラートが生成され、構成された通知が送信されます。 その後、アラート ルールの通知が再び使用されるまで、30 分待機されます。 中間期間では、アラート ルールは引き続き実行されます。 この期間にアラート ルールが何回生成されたかにかかわらず、指定した期間は Log Analytics によって通知のみが抑制されます。

ログ検索アラート ルールの プロパティは Suppress 、 値を使用 Throttling して指定します。 抑制期間は、DurationInMinutes の値を使用して指定します。

次の応答例は、ThresholdSeverity、および 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
}

スケジュールの新しいアクションを Severity で作成するには、Put メソッドに一意のアクション ID を渡します。

$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

スケジュールの重大度アクションを編集するには、既存のアクション ID を Put メソッドに渡します。 要求の本体には、アクションの 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

アクションをカスタマイズする

既定のアクションで、通知の標準のテンプレートとフォーマットに従います。 ただし、アクション グループによって制御されている場合でも、ユーザーは一部のアクションをカスタマイズできます。 現在、EmailSubjectWebhookPayload のカスタマイズが可能です。

アクション グループの EmailSubject をカスタマイズする

既定では、アラートの電子メールの件名は、<WorkspaceName> に関するアラートの通知 <AlertName> のように表示されます。 ただし、サブジェクトはカスタマイズできるため、言葉やタグを指定できます。これにより、受信トレイにフィルター規則を簡単に適用できます。 次の例のように、カスタマイズしたメール ヘッダーの詳細は 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 をカスタマイズする

既定では、ログ分析のためにアクション グループを介して送信される 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

次のステップ