JobLog API

개요

JobLog API는 Fess 의 작업 실행 로그를 참조 및 관리하기 위한 API입니다. 스케줄 작업이나 크롤링 작업의 실행 이력, 실행 결과, 오류 정보 등을 조회하거나 삭제할 수 있습니다.

기본 URL

/api/admin/joblog

엔드포인트 목록

메서드 경로 설명
GET /logs 작업 로그 목록 조회
GET /log/{id} 작업 로그 조회
DELETE /log/{id} 작업 로그 삭제

작업 로그 목록 조회

요청

GET /api/admin/joblog/logs

파라미터

파라미터 타입 필수 설명
size Integer 아니오 페이지당 건수 (기본값: 25. fess_config.properties 의 paging.page.size 로 변경 가능)
page Integer 아니오 페이지 번호 (1부터 시작, 기본값: 1)
id String 아니오 작업 로그 ID로 필터링 (완전 일치)

이 파라미터들은 JSON 요청 본문(예: {"size": 50, "page": 1} )으로 지정합니다. URL 쿼리 문자열(예: ?size=50 )로 지정한 값은 무시되므로, 본문에 지정하지 않으면 항상 처음 25건이 반환됩니다.

응답

{
  "response": {
    "status": 0,
    "logs": [
      {
        "id": "joblog_id_1",
        "job_name": "Default Crawler",
        "job_status": "ok",
        "target": "all",
        "script_type": "javascript",
        "script_data": "return container.getComponent(\"crawlJob\").execute();",
        "script_result": "Job completed successfully",
        "start_time": "1738116000000",
        "end_time": "1738118723000"
      },
      {
        "id": "joblog_id_2",
        "job_name": "Default Crawler",
        "job_status": "fail",
        "target": "all",
        "script_type": "javascript",
        "script_data": "return container.getComponent(\"crawlJob\").execute();",
        "script_result": "Error: Connection timeout",
        "start_time": "1738029600000",
        "end_time": "1738030215000"
      }
    ],
    "total": 100
  }
}

응답 필드

필드 설명
id 작업 로그 ID
job_name 작업 이름
job_status 작업 상태 (ok: 성공, fail: 실패, running: 실행 중)
target 실행 대상 (스케줄러의 타겟 이름. 기본값은 all)
script_type 스크립트 타입 (예: javascript)
script_data 실행 스크립트
script_result 실행 결과
start_time 시작 시각 (에포크 밀리초. 문자열로 반환됨)
end_time 종료 시각 (에포크 밀리초. 문자열로 반환됨). 실행 중인 작업에서는 반환되지 않습니다.

참고

응답의 각 로그 오브젝트에는 내부적으로 사용되는 crud_mode 필드 (CRUD 작업 모드를 나타내는 정수값으로, 읽기 작업 시 항상 0)가 포함됩니다. 클라이언트 측에서는 무시해도 됩니다.

작업 로그 조회

요청

GET /api/admin/joblog/log/{id}

응답

{
  "response": {
    "status": 0,
    "log": {
      "id": "joblog_id_1",
      "job_name": "Default Crawler",
      "job_status": "ok",
      "target": "all",
      "script_type": "javascript",
      "script_data": "return container.getComponent(\"crawlJob\").execute();",
      "script_result": "Crawl completed successfully.\nDocuments indexed: 1234\nDocuments updated: 567\nDocuments deleted: 12\nErrors: 0",
      "start_time": "1738116000000",
      "end_time": "1738118723000"
    }
  }
}

지정한 ID의 작업 로그가 존재하지 않는 경우, status 에 0 이외의 값이 설정된 오류 응답이 반환됩니다.

작업 로그 삭제

요청

DELETE /api/admin/joblog/log/{id}

응답

{
  "response": {
    "status": 0
  }
}

지정한 ID의 작업 로그가 존재하지 않는 경우, status 에 0 이외의 값이 설정된 오류 응답이 반환됩니다.

사용 예

작업 로그 목록 조회

curl -X GET "http://localhost:8080/api/admin/joblog/logs" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"size": 50, "page": 1}'

실패한 작업만 추출

# jq로 실패한 작업을 필터링
curl -X GET "http://localhost:8080/api/admin/joblog/logs" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"size": 1000}' | \
     jq '.response.logs[] | select(.job_status=="fail")'

작업 로그 조회

curl -X GET "http://localhost:8080/api/admin/joblog/log/joblog_id_1" \
     -H "Authorization: Bearer YOUR_TOKEN"

작업 로그 삭제

curl -X DELETE "http://localhost:8080/api/admin/joblog/log/joblog_id_1" \
     -H "Authorization: Bearer YOUR_TOKEN"

작업 성공률 계산

curl -X GET "http://localhost:8080/api/admin/joblog/logs" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"size": 1000}' | \
     jq '.response.logs | {total: length, ok: [.[] | select(.job_status=="ok")] | length, fail: [.[] | select(.job_status=="fail")] | length}'

참고 정보