I'm trying to figure out the best way to get log data into mongodb. Let's I want to create a simple mongo collection that will track all traffic on my site. I have thought of some possible solutions but I'm not sure if its clean:
我正在试图找出将日志数据导入mongodb的最佳方法。我想创建一个简单的mongo集合,它将跟踪我网站上的所有流量。我想过一些可能的解决方案,但我不确定它是否干净:
Option 1: Add a before filter in the application controller and use MongoMapper to create/update a record in mongo when a user hits my site. A possible downside would be if a page is cached and the rails stack is not hit. I also don't like the idea of muddying up the controller and throwing in more work when what I already need is being output to a log.
选项1:在应用程序控制器中添加一个before过滤器,并在用户访问我的站点时使用MongoMapper在mongo中创建/更新记录。一个可能的缺点是如果页面被缓存并且没有命中rails堆栈。当我已经需要输出到日志时,我也不喜欢混淆控制器并投入更多工作的想法。
Option 2: Somehow tail the apache log and as new data comes in, throw it in mongodb. Are there any tools that can observe/tail a log?
选项2:以某种方式关闭apache日志,当新数据进入时,将其抛入mongodb。有没有可以观察/尾随日志的工具?
Any refinements or better options out there?
那里有任何改进或更好的选择吗?
1 个解决方案
#1
0
Don't reinvent the wheel, Github is your friend.
不要重新发明*,Github是你的朋友。
Short search coughed up this: https://github.com/ClarityServices/semantic_logger
短搜索咳出了这个:https://github.com/ClarityServices/semantic_logger
or maybe this:
或者这个:
http://blog.treasure-data.com/post/13766262632/real-time-log-collection-with-fluentd-and-mongodb
http://blog.treasure-data.com/post/13766262632/real-time-log-collection-with-fluentd-and-mongodb
#1
0
Don't reinvent the wheel, Github is your friend.
不要重新发明*,Github是你的朋友。
Short search coughed up this: https://github.com/ClarityServices/semantic_logger
短搜索咳出了这个:https://github.com/ClarityServices/semantic_logger
or maybe this:
或者这个:
http://blog.treasure-data.com/post/13766262632/real-time-log-collection-with-fluentd-and-mongodb
http://blog.treasure-data.com/post/13766262632/real-time-log-collection-with-fluentd-and-mongodb