- Logs should be protected like backups.
- Remote
- Multiple versions
- Logs should be read-only
- Logs should be aggragated dynamically when necessary.
- Logs should be available also after an attack.
- Logs should contain useful data
- A web server logs which has only the request IPs of the firewall before it, is not so useful.
- The log format should be versatile and robust (e.g. JSONL ist better than CSV files)
- The timestamps should be in the same format and the same timezone or contain also the timezone.
Questions, who should be answered easily:
- Find everything what A did.
- Find everything releated to X.
- Find events which are not like the others.
Tips for analyzing log files
Search a log and count the hosts:
cat log | jq -c '.host' | sort | uniq -c | sort -n
To see more about the host “Apache”
cat log | grep "Apache" | jq
Search in gzipped logs:
zgrep log.gz
zcat log.gz | grep "Apache"
Convert timestamps on the fly:
cat log | jq -c '.ts|=strftime("%Y-%m-%d %H:%M:%S %z")' | jq
Leave a Reply
You must be logged in to post a comment.