다음과 같은 로그에서 user id만 뽑아내고 싶었다. 대괄호가 user id를 로그를 감싸고 있어서 출력해보면 [1],
이런 형태였다.
"[a][b][c] [userID] : [$userId], [d] : [e]"
fields @timestamp
| filter @message like "[a][b][c]"
| parse @message "* * * *"
as info, file, class_method, msg
| parse msg "* * * * * * * *" as a,b,c,d,e, f, user_id, g
| filter msg not like /xyx/
| display user_id
| sort @timestamp desc
| limit 10000
import re
s = """[1234],"""
p = re.compile("[\d]+")
found_ids = p.findall(s)
result_ids = set([int(id) for id in found_ids])
print(result_ids)
select *
from users
where id in (1234)