예외 규칙 생성

새 시나리오 예외 규칙을 생성합니다.

HTTP 요청

POST /api/sonar/exception-rules
cURL 예시
curl -H "Authorization: Bearer <API_KEY>" \
     -H "Content-Type: application/json" \
     -d '{
       "type": "STREAM",
       "scenario_guid": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
       "exprs": {
         "operator": "and",
         "operands": [
           {
             "field": "src_ip",
             "type": "ip",
             "operator": "eq",
             "value": "192.0.2.1"
           }
         ]
       },
       "valid_from": "2025-01-01 00:00:00+0900",
       "valid_until": "2025-12-31 23:59:59+0900",
       "description": "테스트 서버 예외 처리"
     }' \
     -X POST \
     https://HOSTNAME/api/sonar/exception-rules
요청 매개변수
필수타입설명비고
typeO문자열유형STREAM 또는 BATCH
scenario_guidO문자열시나리오 GUID36자 GUID
exprsO문자열 키/값조건 트리하단 조건 트리 구조 참조
valid_fromO날짜유효 시작 일자yyyy-MM-dd HH:mm:ssZ 형식
valid_untilO날짜유효 종료 일자yyyy-MM-dd HH:mm:ssZ 형식
descriptionX문자열메모최대 2,000자

exprs는 재귀적 조건 트리 구조이며 두 가지 노드 유형이 있습니다:

노드 표현식 (논리 연산자):

  • operator (문자열, 필수): and, or, not, src_ip, dst_ip, src_ip_dst_ip 중 하나
  • operands (배열, 필수): 하위 조건 목록. 각 항목은 노드 표현식 또는 리프 표현식

리프 표현식 (필드 비교):

  • field (문자열, 필수): 비교 대상 필드 이름 (예: src_ip)
  • type (문자열, 필수): 필드 데이터 유형. string, number, boolean, ip 중 하나
  • operator (문자열, 필수): 비교 연산자. eq, neq, gt, gte, lt, lte, starts_with, ends_with, contains, is_null, is_not_null 중 하나 (필드 유형에 따라 사용 가능한 연산자가 다름)
  • value (문자열): 비교 값. is_null, is_not_null 연산자에서는 불필요

정상 응답

{
  "guid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

오류 응답

필수 매개변수가 누락된 경우

HTTP 상태 코드 400 응답

{
  "error_code": "null-argument",
  "error_msg": "type should be not null"
}
매개변수 값의 길이가 잘못된 경우

HTTP 상태 코드 400 응답

{
  "error_code": "invalid-argument",
  "error_msg": "'description' must be shorter than or equal to 2000 characters."
}
시나리오 GUID가 GUID 형식이 아닌 경우

HTTP 상태 코드 400 응답

{
  "error_code": "invalid-param-type",
  "error_msg": "scenario_guid should be guid type."
}
잘못된 유형 값을 사용한 경우

HTTP 상태 코드 400 응답

{
  "error_code": "invalid-argument",
  "error_msg": "No enum constant com.logpresso.sonar.api.exceptionrule.ExceptionRuleType.INVALID"
}