예약된 쿼리 생성

새 예약된 쿼리를 생성합니다. 이 작업은 관리자 권한을 요구합니다.

HTTP 요청

POST /api/sonar/scheduled-queries
cURL 예시
curl -H "Authorization: Bearer <API_KEY>" \
     -d name="test" \
     -d query="table duration=1m sonar_cpu_logs | search idle <= 10" \
     -d trigger_type="cron" \
     -d cron_schedule="* * * * *" \
     -X POST https://HOSTNAME/api/sonar/scheduled-queries
요청 매개변수
필수타입설명비고
nameO문자열이름최대 255자
descriptionX문자열설명최대 2,000자
enabledX불리언활성화 여부기본값: false
queryO문자열쿼리문
trigger_typeO문자열실행 방식cron(예약 실행)과 workflow(다른 쿼리의 결과에 따라 실행) 중 선택
cron_scheduleO문자열실행 조건trigger_typecron일 때 필수
preceding_guidX문자열선행 예약된 쿼리의 GUIDtrigger_typeworkflow일 때 필수
preceding_actionX문자열선행 예약된 쿼리의 실행 상태trigger_typeworkflow일 때 succeeded, failed, finished 중 하나 지정
node_typesX문자열 목록실행 위치control(분석 노드) 또는 data(수집 노드)를 쉼표로 구분하여 기입
output_parameterX불리언매개변수 출력 제어기본값: false

정상 응답

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

오류 응답

필수 매개변수 값이 없는 경우

HTTP 상태코드 400 응답

{
  "error_code": "null-argument",
  "error_msg": "name should be not null"
}
매개변수 값 길이가 긴 경우

HTTP 상태코드 400 응답

{
  "error_code": "invalid-argument",
  "error_msg": "'name' must be shorter than or equal to 255 characters."
}
같은 이름의 예약된 쿼리가 있는 경우

HTTP 상태코드 500 응답

{
  "error_code": "illegal-state",
  "error_msg": "duplicated name: test"
}
trigger_type이 cron일 때, cron_schedule에 값이 없는 경우

HTTP 상태코드 400 응답

{
  "error_code": "null-argument",
  "error_msg": "cron_schedule should be not null"
}
trigger_type이 workflow일 때, preceding_action에 값이 없는 경우

HTTP 상태코드 400 응답

{
  "error_code": "null-argument",
  "error_msg": "preceding_action should be not null"
}
trigger_type이 workflow일 때, preceding_action에 허용되지 않은 값이 입력된 경우

HTTP 상태코드 400 응답

{
  "error_code": "invalid-argument",
  "error_msg": "preceding_action value must be one of 'finished', 'succeeded', 'failed'."
}
관리자 권한이 아닌 경우

HTTP 상태코드 500 응답

{
  "error_code": "illegal-state",
  "error_msg": "no-permission"
}