One 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…
> It really demonstrates that you don't have the usage of the command receiving the output completely memorized. No, it demonstrates that you don't have redirection memorized, and don't know that you can place it anywhere in the command line, including on the left. > So you're wasting a few clock cycles Keystrokes too: cat x | cmd It's also possible that cmd may detect that its standard input is connected to a real f…
Tips for analyzing logs
101–110 of 136 posts
Re: Tips for analyzing logs
#102For instance if an API call is made use the phone emoji, when there is a timeout use a clock, when an order is dispatched used a package...
When you have to go through huge log file it is a life saver.
Re: Tips for analyzing logs
#103It's not super cheap, but it's 10x cheaper than wasting dev time in the terminal. (Sumologic, splunk are the two I can vouch for)
Re: Tips for analyzing logs
#104Earlier quoted context omitted.
And you should produce a single line of output for each request that identifies all of the pertinent information. You can have more than one, for e.g. a thread dump, but there should be one that provides a complete summary. I've lived with apps that logged at each stage of the process as separate lines, and that's just not useful data when grepping for anomalies.
I hypothesize it's not useful because you're using grep. If you use a tool that can show you multiple lines all tied by a request ID, it becomes much more helpful.
Re: Tips for analyzing logs
#105Re: Tips for analyzing logs
#106Some extra tips: Keep access logs, both when a service receives a request and finishes a request. Record request duration. Always rotate logs. Ingest logs into a central store if possible. Ingest exceptions into a central store if possible. Always use UTC everywhere in infra. Make sure all (semantic) lines in a log file contain a timestamp. Include thread ids if it makes sense to. It's useful to log unix timestamp al…
Re: Tips for analyzing logs
#107My 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.
Huh, I almost posted a duplicate recommendation. My only complaint with lnav was that it had to be built from source on Linux and the build was frigging huge. Apparently they have a pre-compiled linux-musl binary now.
Re: Tips for analyzing logs
#108My 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.
Re: Tips for analyzing logs
#109In short, you can add clickhouse-local to a shell pipeline and then run SQL queries on the data. An example from the docs:
$ ps aux | tail -n +2 | awk '{ printf("%s\t%s\n", $1, $4) }' | clickhouse-local --structure "user String, mem Float64" --query "SELECT user, round(sum(mem), 2) as memTotal FROM table GROUP BY user ORDER BY memTotal DESC FORMAT Pretty"