Questions tagged «logfile-analysis»

11
在Node.js中解析巨大的日志文件-逐行阅读
我需要在Javascript / Node.js中解析大型(5-10 Gb)日志文件(我正在使用Cube)。 日志行看起来像: 10:00:43.343423 I'm a friendly log message. There are 5 cats, and 7 dogs. We are in state "SUCCESS". 我们需要阅读每一行,做了一些分析(如带出来5,7和SUCCESS),然后该泵将数据立方体(https://github.com/square/cube使用他们的JS客户端)。 首先,Node中逐行读取文件的规范方式是什么? 在线上似乎是一个相当普遍的问题: http://www.quora.com/What-is-the-best-way-to-read-a-file-line-by-line-in-node-js 在node.js中一次读取一行文件? 许多答案似乎都指向一堆第三方模块: https://github.com/nickewing/line-reader https://github.com/jahewson/node-byline https://github.com/pkrumins/node-lazy https://github.com/Gagle/Node-BufferedReader 但是,这似乎是一项相当基本的任务-当然,stdlib中有一种简单的方法可以逐行读取文本文件? 其次,然后我需要处理每一行(例如,将时间戳转换为Date对象,并提取有用的字段)。 最大化吞吐量的最佳方法是什么?是否有某种方式在读取每一行或将其发送到Cube时不会阻塞? 第三-我猜想使用字符串拆分,而包含(JS)的JS(IndexOf!= -1?)会比正则表达式快很多吗?是否有人在Node.js中解析大量文本数据方面有丰富的经验? 干杯,维克多
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.