If you are using Kubernetes, I highly recommend using https://github.com/stern/stern
Tips for analyzing logs
81–90 of 136 posts
Re: Tips for analyzing logs
#82One thing I've done to identify infrequent log entries within a log file is to remove all numbers from a file and print out a frequency of each. Basically just helps to disregard timestamps (not just at the beginning of the line), line numbers, etc. cat file.log | sed 's/[0-9]//g' | sort | uniq -c | sort -nr This has been incredibly helpful in quickly resolving outages more than once.
Re: Tips for analyzing logs
#83As much as I approve of a skillset to analyze local logs, but after a relatively small scale (10-20 systems), a central decent log aggregation like opensearch or ELK just brings so much value even on 1-3 nodes. It'd be one of the first changes I make to an infrastructure because it's so powerful. And its not just log searching and correlation value. At work, the entire discussion "oh but we need access to all servers…
Re: Tips for analyzing logs
#84One of my pet peeves is "The Useless Use of cat Award". Someone awarded it to me as a teenager in the late 90s and I've been sore ever since. Yup, it's often a waste of resources to run an extra 'cat'. It really demonstrates that you don't have the usage of the command receiving the output completely memorized. You know, the thousand or so commands you might be piping it into. But, if you're doing a 'useless' use of…
Re: Tips for analyzing logs
#85Re: Tips for analyzing logs
#86One thing I've done to identify infrequent log entries within a log file is to remove all numbers from a file and print out a frequency of each. Basically just helps to disregard timestamps (not just at the beginning of the line), line numbers, etc. cat file.log | sed 's/[0-9]//g' | sort | uniq -c | sort -nr This has been incredibly helpful in quickly resolving outages more than once.
Re: Tips for analyzing logs
#87My biggest quality of life improvement for understanding logs has been lnav ( https://lnav.org/ ) -- does everything mentioned in this post in a single tool with interactive filtering and quick logical and time based navigation.
I love lnav and use it constantly, but it crashes a lot. I do wish there was something like lnav that was a little simpler to use, and written in a more resilient way that crashed less. I can cut lnav some slack for the crashes because identifying and parsing arbitrary log formats seems like a messy problem. Still it shouldn't crash 1/3rd of the time I use it.
Re: Tips for analyzing logs
#88This is a great point and probably underrated.
You may also benefit by scrolling sideways really fast.
Re: Tips for analyzing logs
#89My tips: 1) Fuck grep, use ripgrep, especially if you have to scour over an entire directory. 2) Get good with regex, seriously, it will shave hours off your searching. 3) For whatever application you are using, get to know how the logging is created. Find the methods used where said logs are made, and understand why such a log line exists. 4) Get good with piping into awk if needed if you need some nice readable out…
Re: Tips for analyzing logs
#90One of my pet peeves is "The Useless Use of cat Award". Someone awarded it to me as a teenager in the late 90s and I've been sore ever since. Yup, it's often a waste of resources to run an extra 'cat'. It really demonstrates that you don't have the usage of the command receiving the output completely memorized. You know, the thousand or so commands you might be piping it into. But, if you're doing a 'useless' use of…
You're not alone. I disable the warning in shellcheck. I've been uselessly cat'ing since the 90s, like you.