Ask HN: How do you analyze logs?

72 points by hckrt_ ↗ HN
Analyzing logs is huge part of a software problem solver's job. What kind of tools and techniques do you use to be more effective in your job?

75 comments

[ 5.6 ms ] story [ 67.4 ms ] thread
LogEntries.com
We tried logentries, but their agent was a terrible java-application, that was hard to get working right.

The list of files was saved on their service (rather than in a text-file on the server), and the name of our servers was also guessed by their servers which made it hard for us to add and maintain servers.

I think they should build a better agent that embraces UNIX more, and can be configured through a local configuration. Their platform seems nice, but we weren't able to use it, sadly.

There are two agents, the one for Linux/BSD/OSX is Python-based open source [1] (I'm one of the authors) with repositories for Debian/Ubuntu/CentOS/etc. It takes the name of the server from hostname or it can be specified via command line during initialization. Logentries supports syslog for agent-less setups if you don't mind that many syslogs have broken SSL/TLS implementation.

If you have suggestions how to improve it let me know, happy to look at it. Cilent-side configuration an metrics will be available in a week or so.

[1] https://github.com/logentries/le/

I'm sorry your experience left something to be desired. Given that we deploy across far too many hosts to actually monitor, or, frankly, care about monitoring, I use it only at the application level (logentries.log([string, object, etc[)).
Hey - You might want to check the agent docs here which have a local configuration file: https://github.com/logentries/le#configuration

So the logs being followed are actually configured in a text file on the servers. This makes it super simple for deploying via chef/puppet in large scale environments.

Grep, awk, sed for the easy stuff, logastash/elasticsearch/kibana for the harder stuff.
awk, grep, sed, ag, cut, sort,etc for most of the stuff. Elasticsearch, logstash, kibana for more complex queries
We use splunk but there's something to be said for the low-tech approach for ad-hoc queries.

A great little tool is 'since' - a stateful tail. http://welz.org.za/projects/since

  since is a unix utility similar to tail.
  Unlike tail, since only shows the lines
  appended since the last time. It is useful
  to monitor growing log files.
It's in the usual yum/apt repos as well as homebrew for Mac.

It's a bit hard to websearch for because 'since' is a common word.

When I cared about logs on individual servers, I wrote a program to parse them to make it easy to find what I want, and I wrote it as a command line utility so that it could be used in combo with cat, grep, awk, sed, etc. It's on my github: https://github.com/jedberg/quickparse
logstash + elasticsearch + kibana

That's for personal projects, the CloudFlare setup is a little more complex and perhaps one of the data team would be best answering that... if you're interested then I can ping them to see if there's a volunteer for a blog post describing how we do logs at scale.

That would be very helpful indeed...thanks in advance!
An ELK stack is definitely a lot easier and straight forward to setup. Since we need to support a dozen or so teams with varying performance considerations we found that logstash left a lot to be desired. In the end fluentd performed well and gave us a lot of flexibility.
> we found that logstash left a lot to be desired. In the end fluentd performed well and gave us a lot of flexibility.

Would you mind providing more details about why you felt that Logstash was lacking?

I'd like your view from the trenches regarding Logstash vs Fluentd, specifically why it's better for 12+ teams? I'm having to make a similar decision myself and would enjoy your insight! Thanks
A post like that would be awesome
fluentd -> elasticsearch/kibana

Works pretty damn well.

www.sumologic.com
My work recently switched to sumo and I love it. I've you've used splunk, logstash, elastic search + kibana previously and think sumo is the best. It is the right amount of power and simplicity plus great documentation.
I have to second this. Sumologic is very powerful and saves hours of time troubleshooting.
As others have said, the classics awk, grep, cut, sort, uniq, and scripting languages (perl/ruby for on the fly one-liners) are great for log analysis. One additional tool I've found particularly useful (three actually) is zgrep/zcat/zless. You'll often be searching through archived gzipped logs, so it's nice being able to work with the files without needing to pipe everything through tar.
Personally i use Emacs with occur-mode for filtering text also when it finds the pattern it is able to switch from instances quickly. Sometimes i also use regex with occur to find multiple items.

Also Notepad++ has a Analyze plugin which i recommend for complex stuff and if you dont like emacs.

Splunk/ELK. I have used Splunk since its inception (I was one of the first paying customers) and enjoy its many features and integrations (e.g. AWS Cloudtrail, Nagios, and anomaly detection). In the past few years, I've come to know and like ELK, ElasticSerch, Kibana, and Logstash. The open source approach has some nice properties as well. It's on you to get the logs ingested but generally that is remote syslog (rsyslog,syslog-ng, or equiv) and logstash with redis. The docs on this integration are not super strong but with a little hacking you can get it working. The feature set is less in this stack and the UI is not nearly as nice. The savings are huge though especially as log volume goes up. Splunk also has a free service targeted at developers called Spluk Storm. Good for proof of concept and easy to setup without any hardware requirements as it runs on AWS.
Some people find EFK (Elasticsearch Fluentd Kibana) to be another compelling alternative to Splunk (Disclaimer: I am one of the maintainers of Fluentd)

http://docs.fluentd.org/articles/free-alternative-to-splunk-...

What makes Fluentd better than syslog-ng?
It is not "better" but different.

1. Easier to extend that syslog-ng if you have a modest knowledge of Ruby

2. Easy to configure file- and memory- based buffering and failover.

3. Advanced filtering out of the box.

4. Rich plugin ecosystem with 300+ plugins.

At least that's what I've heard from the users who switched from syslog-ng to Fluentd. I am happy to learn more about what makes syslog-ng great since I've never used it seriously myself =)

I have used both splunk and elk. Splunk at a bank and now elk at a startup. My experience is splunk is not worth the money. You can pretty much do everything u wish to with elk or further processing the data and loading it back to elastic search.. Which is what we do at my current place..
Used papertrailapp.com but as the number of servers grew, this became expensive.

Moved to EL + Kibana, but not liking the interface yet and it doesn't seem to have 'tail -f' kindof functionality.

We use paper trail. I suppose expense is relative, but it's absolutely worth it to us. They've really nailed log search, which is what is really important to us.
I regularly search logs across a huge fleet of hosts (thousands). I have a script that will send an arbitrary command in parallel to each host and return the output in a JSON file.

Once I get the logs I'm interested in, it's usually a straightforward combination of jq, grep, sed, awk, cut, sort, uniq, xargs, etc. If I need to do some fancy queries on the data, I have another script that will parse the logs and load them into a SQLite db.

What are you using to execute commands on thousands of hosts in parallel?
I don't know what the GP's answer will be, but I would use pdsh.
Just forking off processes that SSH into the hosts and write to temp files, which are picked up the by the main process. It's gotten pretty elaborate, but the basics are pretty simple.
To the people suggesting ELK i just want to ask if you have actually used it in production? Like for real bughunting and investigating support requests?

As much as we absolutely love ElasticSearch for our other indexing needs, we find it quite hard to get the LK-part of the stack to deliver as promised. Kibana may serve up nice graphs and charts, but when you need to drill down into a large amount of log data, we often feel like loosing both overview _and_ detail.

It might very well be that we are to blame, and that we are just doing it wrong (tm) - but I would love to hear how other people are leveraging the ELK stack in production environments?

We use ElasticSearch and Kibana in production for real bughunting and support requests. Logstash was too frustrating to deal with so we wrote our own simple wrapper around an open source ElasticSearch client library to log ourselves.

We log every request (everything but the body usually) and response. If an error occurs, its logged as part of the request. We can practically replay actions taken by users and easily drill down to the exact requests pertaining to an error.

I've only maintained a small number of servers, but I've found a good solution in what I'll call the GEL (Graylog2 - Elasticsearch - Logstash) stack. It's been some time since I last used Graylog2, and I can recall that it was somewhat lacking in the pretty charts and graphs department, though that may have improved recently, and the search functioned beautifully.
I'm surprised Graylog2 isn't mentioned more here. We've got tens of terabytes of logs in Graylog2, and I couldn't imagine not using its streams, alerts, and search functionality. It's become a core part of our alerting an monitoring infrastructure.
Did monitoring logs with Bayesian filters ever catch on? They are very good and finding things that are "off"
By "monitoring" do you mean anomaly detection?
thats part of how our engine works.. part (full disclosure, co-founder of toplog.io)
How many logs are we talking about, and produced at what rate? These are key questions. If you have tons of logs and you might have to make a full access pass over them, the last thing you want to do is to centralize them on some kind of logs host with lots of disks and few CPUs. But if you have little or moderate amounts of logs you may be able to get away with a single host and some xargs -P grep type of thing.
ELK is easy to setup but when you really need to analyse logs it can be painful, I think the real problem is Kibana which is just not good enough for that task.

- no logs coloration

- a lot of bugs / weird refresh behavior

- no auth

Do you know of a better alternative to Kibana for a EL_ stack?
One thing we've done that's greatly improved the effectiveness of our API logs is creating a unique context identifier string for each api call and passing it back in the response headers of a call. This allows you to copy the string from the browser and grep the logs to immediately find the call in question, and if an error occurred.