레거시 Log Analytics 경고 REST API

이 문서에서는 레거시 API를 사용하여 경고 규칙을 관리하는 방법을 설명합니다.

중요

발표된 대로 Log Analytics 경고 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 Search REST API는 RESTful이며 Azure Resource Manager REST API를 통해 액세스할 수 있습니다. 이 문서에서는 ARMClient를 사용하여 PowerShell 명령줄에서 API에 액세스하는 예를 찾을 수 있습니다. 이 오픈 소스 명령줄 도구는 Azure Resource Manager API 호출을 단순화합니다.

ARMClient 및 PowerShell 사용은 Log Analytics 검색 API에 액세스하는 데 사용할 수 있는 많은 옵션 중 하나입니다. 이러한 도구를 사용하면 RESTful Azure Resource Manager API를 활용하여 Log Analytics 작업 영역을 호출하고, 이 작업 영역 내에서 검색 명령을 수행할 수 있습니다. API는 프로그래밍 방식으로 다양한 방식으로 검색 결과를 사용할 수 있도록 검색 결과를 JSON 형식으로 출력합니다.

사전 요구 사항

현재 Log Analytics에 저장된 검색을 사용해서만 경고를 만들 수 있습니다. 자세한 내용은 로그 검색 REST API를 참조하세요.

일정

저장된 검색은 하나 이상의 일정을 가질 수 있습니다. 일정은 검색이 실행되는 빈도 및 조건이 식별되는 시간 간격을 정의합니다. 일정에는 다음 표에 설명된 속성이 있습니다.

속성 설명
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 메서드를 사용하여 새 일정을 만듭니다. 두 개의 일정은 서로 다른 저장된 검색과 연결되더라도 동일한 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 시작과 같이 수행할 하나 이상의 프로세스를 정의할 수 있습니다. 작업은 검색 결과가 일부 조건과 일치하는 시기를 결정하는 임계값을 정의할 수도 있습니다. 일부 작업은 임계값을 만족할 때 프로세스가 수행되도록 정의합니다.

모든 작업에는 다음 표에 설명된 속성이 있습니다. 다른 형식의 경고에는 다음 표에 설명된 다른 속성이 있습니다.

속성 설명
Type 작업의 유형입니다. 현재 가능한 값은 AlertWebhook입니다.
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

경고 작업

일정은 경고 작업을 한 개만 가져야 합니다. 경고 작업에는 다음 표에 설명된 하나 이상의 섹션이 있습니다.

섹션 Description 사용
임계값 작업이 실행되기 위한 조건입니다. Azure로 확장되기 이전 또는 이후에 모든 경고에 필요합니다.
심각도 트리거될 때 경고를 분류하기 위해 사용되는 레이블입니다. Azure로 확장되기 이전 또는 이후에 모든 경고에 필요합니다.
표시 안 함 경고의 알림을 중지하는 옵션입니다. 모든 경고(아직 Azure로 확장되지 않은 경고나 Azure로 확장된 경고)에서 선택 사항입니다.
작업 그룹 이메일, 문자 메시지, 음성 통화, 웹후크, 자동화 Runbook 및 ITSM 커넥터와 같이 필요한 작업이 지정된 Azure ActionGroup의 ID입니다. 경고가 Azure로 확장된 후 필요합니다.
작업 사용자 지정 ActionGroup에서 선택 작업에 대한 표준 출력을 수정합니다. 모든 경고에 대해 선택 사항이며 경고가 Azure로 확장된 후에 사용할 수 있습니다.

임계값

경고 작업은 임계값을 한 개만 가져야 합니다. 저장된 검색의 결과가 해당 검색과 연결된 작업의 임계값과 일치하는 경우 해당 작업의 다른 프로세스가 실행됩니다. 작업은 임계값을 포함하지 않은 다른 유형의 작업과 함께 사용할 수 있도록 하는 임계값만 포함할 수 있습니다.

임계값에는 다음 표에 설명된 속성이 있습니다.

속성 설명
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
}

고유 작업 ID와 Put 메서드를 사용하여 일정에 대한 새 임계값 작업을 만듭니다.

$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를 사용하면 경고를 범주로 심사하여 더 쉽게 관리하고 심사할 수 있습니다. 경고 심각도 수준은 informational, warningcritical입니다. 이러한 범주는 다음 표에 표시된 것처럼 Azure 경고의 정규화된 심각도 척도에 매핑됩니다.

Log Analytics 심각도 수준 Azure Alerts 심각도 수준
critical Sev 0
warning Sev 1
informational Sev 2

다음 샘플 응답은 ThresholdSeverity만 있는 작업에 대한 것입니다.

"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

고유 작업 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

표시 안 함

Log Analytics 기반 쿼리 경고는 임계값에 도달하거나 임계값이 초과될 때마다 실행됩니다. 쿼리에 포함된 논리에 따라 일련의 간격 동안 경고가 발생할 수 있습니다. 그 결과 알림이 지속적으로 전송됩니다. 이러한 시나리오를 방지하기 위해 Log Analytics가 경고 규칙에 대해 경고가 두 번째로 실행되기 전에 규정된 시간 동안 기다리도록 지시하는 Suppress 옵션을 설정할 수 있습니다.

예를 들어, Suppress가 30분으로 설정된 경우 경고가 처음 실행되고 구성된 경고가 전송됩니다. 30분 동안 기다렸다가 경고 규칙에 대한 알림이 다시 사용됩니다. 임시 기간 동안 경고 규칙은 계속 실행됩니다. 이 기간 동안 경고 규칙이 실행된 횟수에 관계없이 지정된 시간 동안 Log Analytics에서 경고만 억제합니다.

Suppress 로그 검색 경고 규칙의 속성은 값을 사용하여 Throttling 지정됩니다. 제거 기간은 DurationInMinutes 값을 사용하여 지정됩니다.

다음 샘플 응답은 Threshold, SeveritySuppress 속성만 있는 작업에 대한 것입니다.

"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

고유 작업 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에서 모든 경고는 작업을 처리하기 위한 기본 메커니즘으로 작업 그룹을 사용합니다. 작업 그룹을 사용하면 작업을 한 번 지정한 다음 동일한 작업을 반복적으로 선언할 필요 없이 작업 그룹을 Azure 전체의 여러 경고에 연결할 수 있습니다. 작업 그룹은 이메일, 문자 메시지, 음성 통화, ITSM 연결, 자동화 Runbook 및 웹후크 URI와 같은 여러 작업을 지원합니다.

자신의 경고를 Azure로 확장한 사용자의 경우 일정은 이제 경고를 만들 수 있도록 Threshold와 함께 전달된 작업 그룹 세부 정보가 있어야 합니다. 이메일 세부 정보, 웹후크 URL, runbook 자동화 세부 정보 및 기타 작업은 경고를 만들기 전에 먼저 작업 그룹 내에서 정의해야 합니다. Azure Portal의 Azure Monitor에서 작업 그룹을 만들거나 Action Group 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
}

고유한 작업 ID와 Put 메서드를 사용하여 일정에 대한 기존 작업 그룹을 연결합니다. 다음 샘플은 사용법을 보여 줍니다.

$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

고유 작업 ID와 Put 메서드를 사용하여 일정에 대해 연결된 작업 그룹을 수정합니다. 요청 본문에는 작업의 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>에 대한 Alert Notification <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
}

고유한 작업 ID와 Put 메서드를 사용하여 일정에 대한 사용자 지정과 기존 작업 그룹을 연결합니다. 다음 샘플은 사용법을 보여 줍니다.

$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

고유 작업 ID와 Put 메서드를 사용하여 일정에 대해 연결된 작업 그룹을 수정합니다. 요청 본문에는 작업의 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에 대한 작업 그룹을 통해 전송되는 웹후크는 고정된 구조를 갖습니다. 하지만 하나의 항목은 웹후크 엔드포인트의 요구 사항을 충족하기 위해 지원되는 특정 변수를 사용하여 JSON 페이로드를 사용자 지정할 수 있습니다. 자세한 내용은 로그 검색 경고 규칙에 대한 웹후크 작업을 참조하세요.

사용자 지정된 웹후크 세부 정보는 ActionGroup 세부 정보와 함께 전송되어야 합니다. 작업 그룹 내에 지정된 모든 웹후크 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
},

고유한 작업 ID와 Put 메서드를 사용하여 일정에 대한 사용자 지정과 기존 작업 그룹을 연결합니다. 다음 샘플은 사용법을 보여 줍니다.

$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

고유 작업 ID와 Put 메서드를 사용하여 일정에 대해 연결된 작업 그룹을 수정합니다. 요청 본문에는 작업의 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

다음 단계