스크립트 로그 파서
Starlark 구성 언어로 정의된 스크립트로 들어오는 로그를 파싱
마지막 업데이트
도움이 되었나요?
도움이 되었나요?
파서:
스크립트:
함수: |
def parse(log):
event = json.decode(log)
if event['actor']['email'].endswith('@panther.com'):
event['is_panther_employee'] = True
else:
event['is_panther_employee'] = False
return eventdef parse(log):
event = json.decode(log)
if event['actor']['email'].endswith('@panther.com'):
event['is_panther_employee'] = True
else:
event['is_panther_employee'] = False
return event127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326def parse(log):
fields = log.split(" ")
return {
'remote_ip': fields[0],
'identity': fields[1],
'user': fields[2],
'timestamp': ' '.join(fields[3:5]).strip('[]'),
'request_uri': ' '.join(fields[5:8]).strip('"'),
"status": int(fields[8]),
"bytes_sent": int(fields[9])
}fields:
- 이름: remote_ip
type: string
지표:
- ip
- 이름: identity
type: string
- 이름: user
type: string
- name: timestamp
type: timestamp
isEventTime: true
timeFormats:
- '%d/%b/%Y:%H:%M:%S %z'
- 이름: method
type: string
- name: request_uri
type: string
- name: protocol
type: string
- name: status
type: int
- name: bytes_sent
type: bigint{
"bytes_sent":2326,
"identity": "-",
"method":"GET",
"protocol":"HTTP/1.0",
"remote_ip":"127.0.0.1",
"request_uri":"/apache_pb.gif",
"status":200,
"timestamp":"2000-10-10 20:55:36.000000000",
"user":"frank"
}