45

Step 1: 로그 파싱 파이프라인

Day 5: 대용량 로그 분석 파이프라인

학습 목표

정규식으로 로그를 파싱할 수 있다 UDF를 활용해 복잡한 파싱 로직을 구현할 수 있다

로그 파싱 전략

Apache Combined Log Format을 파싱합니다.

정규식 패턴

에디터 로딩 중...

파싱 결과 컬럼

그룹컬럼명예시
1ip192.168.1.1
2ident-
3userfrank
4timestamp10/Oct/2024:13:55:36 +0900
5methodGET
6url/api/users
7protocolHTTP/1.1
8status200
9size1234
10refererhttps://example.com
11user_agentMozilla/5.0 ...

추가 변환

  • timestamp → datetime 타입
  • status → integer 타입
  • size → integer 타입 (- 는 0으로)
에디터 로딩 중...
힌트 보기
  • regexp_extract(col, pattern, group_number)
  • to_timestamp(col, format) 사용
  • when().when().otherwise() 체이닝
  • rlike()로 정규식 매칭
정답 보기
에디터 로딩 중...