기존 IBM Cloud Logs 알림을 변환하는 데 필요한 테라폼 변경 사항
IBM® Cloud Logs 알림의 구성 및 처리 방식과 알림 우선순위 지정 방식을 변경했습니다. 이러한 변경 사항은 사용자 환경에 맞게 Terraform을 사용하여 구성한 모든 자동화에 영향을 미칠 수 있습니다.
ibm_logs_alert_definition 및 ibm_logs_alert 리소스 제공업체는 IBM® Cloud Logs 알림에 대해 유사한 기능을 제공하지만 서로 다른 API 메서드를 사용하여 액세스합니다. ibm_logs_alert_definition 리소스는 다음과 같은 고급 구성을 지원하여 기존 ibm_logs_alert 리소스의
기능을 확장합니다:
현재 알림 구성과 호환되도록 하려면 Terraform을 ibm_logs_alert 에서 ibm_logs_alert_definition 으로 업데이트해야 합니다.
알림 정의 API는 알림 API와 완벽하게 호환됩니다. 알림 API를 사용하여 만든 모든 알림은 알림 정의 API를 사용하여 액세스하고 관리할 수 있습니다.
기존 알림을 재구성하려면 ibm_logs_alert_definition 리소스를 사용하여 해당 알림을 가져오세요. ibm_logs_alert_definition 리소스를 사용하면 업데이트된 리소스 구조를 사용하여 기존 알림을 계속 관리할 수 있습니다.
ibm_logs_alert 가져오기 및 ibm_logs_alert_definition 리소스 만들기
기존 알림의 알림 ID 가져오기
먼저 기존 알림의 알림 ID를 가져와서 알림 정의를 새 ibm_logs_alert_definition 리소스로 가져와야 합니다.
UI를 사용하여 알림 ID 가져오기
UI를 사용하여 알림 ID를 가져오려면 다음과 같이 하세요:
-
로깅 인스턴스에 대한 IBM Cloud Logs 대시보드를 엽니다.
-
알림 아이콘
클릭합니다.
-
알림 관리를 클릭합니다.
-
가져올 알림을 선택합니다.
-
History섹션에서Alert unique identifier:을 확인하세요.
CLI를 사용하여 알림 ID 가져오기
CLI를 사용하여 알림 ID를 가져오려면 다음과 같이 하세요:
-
CLI에 로그인하고 다음 단계에 따라 구성을 설정합니다
-
ibmcloud logs alert-definitions명령을 실행하여 알림을 나열합니다. -
CLI 명령 응답의 ID 열에서 가져올 알림의 ID를 찾습니다.
테라폼을 사용하여 알림 ID 가져오기
테라폼을 사용하여 알림 ID를 얻으려면:
-
다음 데이터 소스를 사용하여
main.tf파일을 만듭니다. 이 데이터 소스에는 인스턴스의 모든 알림이 나열됩니다.data "ibm_logs_alert_definitions" "alerts" { instance_id = "guid-of-logs-instance" region = "region-of-logs-instance" } locals { alertdefs = data.ibm_logs_alert_definitions.alerts.alert_definitions alertids = [for adf in local.alertdefs : "${data.ibm_logs_alert_definitions.alerts.region}/${data.ibm_logs_alert_definitions.alerts.instance_id}/${adf.id}"] alertnames = [for adf in local.alertdefs : adf.name] } output "alertids" { value = local.alertids } output "alertnames" { value = local.alertnames } -
terraform apply을(를) 실행하십시오.
알림 ID와 이름이 출력으로 반환됩니다. 출력에서 가져오려는 알림의 ID를 식별합니다.
구성된 알림 ID 만들기
ibm_logs_alert_definition 리소스는 구성된 알림 ID를 사용하여 가져올 수 있습니다. 구성된 알림 ID는 IBM Cloud Logs 지역, instance_id, 그리고 검색된 고유한 alert_id 의 조합입니다. 자세한 내용은 ibm_logs_alert_definition 테라폼 문서를 참조하세요.
다음 형식으로 구성된 알림 ID를 만들어야 합니다: <region>/<instance_id><alert_id>. 이렇게 구성된 알림 ID는 가져오기 단계에서 사용됩니다.
로컬 시스템에서 알림을 ibm_logs_alert_definition 리소스로 가져오기 및 변환하기
로컬 시스템, 콘솔 또는 가상 머신에서 다음 단계를 실행하여 기존 알림을 가져오고 변환하려면 다음 단계를 따르세요.
이 예제에서 이름이 alert-managed-by-tf 인 알림은 Terraform에서 관리합니다.
-
main.tf파일을 편집하세요.resource "ibm_logs_alert" "alert_managed_by_tf" { instance_id = "d58f8c45-f781-4aca-b18d-71ad17825867" region = "eu-es" name = "alert-managed-by-tf" is_active = true severity = "info_or_unspecified" description = "alert managed by tf" notification_groups { notifications { retriggering_period_seconds = 3600 notify_on = "triggered_and_resolved" integration_id = "27" } } incident_settings { retriggering_period_seconds = 3600 notify_on = "triggered_and_resolved" use_as_notification_settings = false } condition { less_than { parameters { threshold = 1 timeframe = "timeframe_1_h" relative_timeframe = "hour_or_unspecified" cardinality_fields = [] } } } filters { filter_type = "text_or_unspecified" text = "action:tf" severities = ["info"] } } -
main.tf파일에 리소스 블록을 추가합니다.resource "ibm_logs_alert_definition" "alert_managed_by_tf" { instance_id = "d58f8c45-f781-4aca-b18d-71ad17825867" region = "eu-es" } -
변환할 알림의 <constructed_alert_ID>와 함께 다음 명령을 실행합니다.
terraform import ibm_logs_alert_definition.alert_managed_by_tf <constructed_alert_ID>ibm_logs_alert_definition.alert_managed_by_tf리소스에 대한 상태를 가져옵니다. -
다음 명령을 실행하여 가져온 리소스의 상태를 확인합니다.
terraform state show ibm_logs_alert_definition.alert_managed_by_tf -
terraform state show출력에서 필요한 콘텐츠를ibm_logs_alert_definition리소스 블록에 복사합니다.업데이트된 리소스 블록은 다음 예시와 유사합니다:
resource "ibm_logs_alert_definition" "alert_managed_by_tf" { deleted = false description = "alert managed by tf" enabled = true instance_id = "d58f8c45-f781-4aca-b18d-71ad17825867" name = "alert-managed-by-tf" phantom_mode = false priority = "p5_or_unspecified" region = "eu-es" type = "logs_threshold" incidents_settings { minutes = 60 notify_on = "triggered_and_resolved" } logs_threshold { condition_type = "less_than" evaluation_delay_ms = 0 notification_payload_filter = [] logs_filter { simple_filter { lucene_query = "action:tf" label_filters { severities = [ "info", ] } } } rules { condition { threshold = 1 time_window { logs_time_window_specific_value = "hour_1" } } override { priority = "p5_or_unspecified" } } undetected_values_management { auto_retire_timeframe = "never_or_unspecified" trigger_undetected_values = true } } notification_group { group_by_keys = [] webhooks { minutes = 60 notify_on = "triggered_and_resolved" integration { integration_id = 27 } } } } -
main.tf파일에서ibm_logs_alert.alert_managed_by_tf리소스에 대한 모든 참조를 제거합니다. -
terraform state rm ibm_logs_alert.alert_managed_by_tf을 실행하여 상태에서ibm_logs_alert.alert_managed_by_tf리소스에 대한 모든 참조를 제거합니다. -
terraform plan을 실행하여 테라폼 실행 계획을 생성하여 제안된 작업을 미리 볼 수 있습니다.terraform plan -
terraform apply을 실행하여 플랜에 정의된 리소스를 만듭니다.terraform apply
출력은 No infrastructure changes 입니다. 이제 ibm_logs_alert_definition 리소스를 사용하여 alert-managed-by-tf 알림을 관리할 수 있습니다.
알림을 ibm_logs_alert_definition 리소스로 가져오기 및 변환하기 IBM Cloud Schematics
다음 단계에 따라 Schematics 에서 Terraform이 관리하는 기존 알림을 가져와서 변환합니다.
이 예에서는 alert-managed-by-tf 이라는 이름의 알림이 변환됩니다.
-
main.tf파일을 편집하세요.resource "ibm_logs_alert" "alert_managed_by_tf" { instance_id = "d58f8c45-f781-4aca-b18d-71ad17825867" region = "eu-es" name = "alert-managed-by-tf" is_active = true severity = "info_or_unspecified" description = "alert managed by tf" notification_groups { notifications { retriggering_period_seconds = 3600 notify_on = "triggered_and_resolved" integration_id = "27" } } incident_settings { retriggering_period_seconds = 3600 notify_on = "triggered_and_resolved" use_as_notification_settings = false } condition { less_than { parameters { threshold = 1 timeframe = "timeframe_1_h" relative_timeframe = "hour_or_unspecified" cardinality_fields = [] } } } filters { filter_type = "text_or_unspecified" text = "action:tf" severities = ["info"] } } -
main.tf파일에 새 리소스 블록을 추가하고 GitHub 리포지토리에 파일을 푸시합니다.resource "ibm_logs_alert_definition" "alert_managed_by_tf" { instance_id = "d58f8c45-f781-4aca-b18d-71ad17825867" region = "eu-es" } -
Schematics CLI에 로그인합니다.
-
Schematics
workspace update명령을 실행하여 최신 코드를 워크스페이스로 가져옵니다. -
리소스를 가져오기 위해 <constructed_alert_ID>와 함께 Schematics
workspace import명령을 실행합니다:ibmcloud schematics workspace import --id <schematics workspace id> --address ibm_logs_alert_definition.alert_managed_by_tf --resourceID <constructed_alert_ID> -
Schematics
workspace state show명령을 실행합니다:ibmcloud schematics workspace state show --id <schematics workspace id> --address ibm_logs_alert_definition.alert_managed_by_tf` -
Schematics 워크스페이스
state show command출력에서ibm_logs_alert_definition리소스 블록으로 필요한 콘텐츠를 복사합니다.업데이트된 리소스 블록은 다음 예시와 유사합니다:
resource "ibm_logs_alert_definition" "alert_managed_by_tf" { deleted = false description = "alert managed by tf" enabled = true instance_id = "d58f8c45-f781-4aca-b18d-71ad17825867" name = "alert-managed-by-tf" phantom_mode = false priority = "p5_or_unspecified" region = "eu-es" type = "logs_threshold" incidents_settings { minutes = 60 notify_on = "triggered_and_resolved" } logs_threshold { condition_type = "less_than" evaluation_delay_ms = 0 notification_payload_filter = [] logs_filter { simple_filter { lucene_query = "action:tf" label_filters { severities = [ "info", ] } } } rules { condition { threshold = 1 time_window { logs_time_window_specific_value = "hour_1" } } override { priority = "p5_or_unspecified" } } undetected_values_management { auto_retire_timeframe = "never_or_unspecified" trigger_undetected_values = true } } notification_group { group_by_keys = [] webhooks { minutes = 60 notify_on = "triggered_and_resolved" integration { integration_id = 27 } } } } -
main.tf파일에서ibm_logs_alert.alert_managed_by_tf리소스에 대한 모든 참조를 제거합니다. -
GitHub 리포지토리를 코드 변경 사항으로 업데이트하고 Schematics
workspace update명령을 사용하여 작업 영역을 업데이트합니다. -
Schematics
workspace state rm명령을 사용하여 워크스페이스 상태에서ibm_logs_alert.alert_managed_by_tf리소스에 대한 모든 참조를 제거합니다:ibmcloud schematics workspace state rm --id WORKSPACE_ID --address ibm_logs_alert_definition.alert_managed_by_tf
출력은 No infrastructure changes 입니다. 이제 ibm_logs_alert_definition 리소스를 사용하여 Schematics 워크스페이스를 통해 alert-managed-by-tf 알림을 관리할 수 있습니다.