다음을 통해 공유


레거시 로그 애널리틱스 경고 REST API

이 문서에서는 레거시 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를 통해 액세스할 수 있습니다. 이 문서에서는 ARMClient사용하여 PowerShell 명령줄에서 API에 액세스하는 예제를 찾을 수 있습니다. 이 오픈 소스 명령줄 도구는 Azure Resource Manager API 호출을 간소화합니다.

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

필수 조건

현재 경고는 Log Analytics에서 저장된 검색을 통해서만 만들 수 있습니다. 자세한 내용은 Log Search 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

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

일정 만들기

고유한 일정 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

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에 대한 것입니다.

비고

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

알림 작업

일정에는 경고 작업이 하나만 있어야 합니다. 경고 작업에는 다음 표에 설명된 섹션이 하나 이상 있습니다.

섹션 설명 사용법
기준치 작업이 실행되는 경우에 대한 조건입니다. Azure로 확장되기 전이나 후에 모든 경고에 필요합니다.
심각도 트리거될 때 경고를 분류하는 데 사용되는 레이블입니다. Azure로 확장되기 전이나 후에 모든 경고에 필요합니다.
억제하다 경고에서 알림을 중지하는 옵션입니다. Azure로 확장되기 전이나 후에 모든 경고에 대해 선택 사항입니다.
작업 그룹 이메일, SMS, 음성 통화, 웹후크, 자동화 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 Alerts의 정규화된 심각도 규모에 매핑됩니다.

Log Analytics 심각도 수준 Azure 알림 심각도 수준
critical 세브 0
warning 세브 1
informational 세브 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의 여러 경고에 작업 그룹을 연결할 수 있습니다. 작업 그룹은 이메일, SMS, 음성 통화, ITSM 연결, 자동화 Runbook 및 웹후크 URI와 같은 여러 작업을 지원합니다.

경고를 Azure로 확장한 사용자는 이제 알림을 생성하기 위해 일정을 통해 Threshold과 함께 작업 그룹 세부 정보를 전달받아야 합니다. 경고를 만들기 전에 먼저 작업 그룹 내에서 전자 메일 세부 정보, 웹후크 URL, Runbook 자동화 세부 정보 및 기타 작업을 정의해야 합니다. 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
}

고유한 작업 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 사용자 지정

기본적으로 경고의 전자 메일 제목은 <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
}

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

다음 단계