使用日志生成分析?
我正在使用应用程序引擎java。我有兴趣收集一些分析数据,但这很困难,因为我需要为我有兴趣跟踪的所有信息创建数据存储类 - 这会减少我们的 100 个索引配额,并且只会给我的项目带来额外的复杂性。
我正在浏览开发论坛,一位应用程序引擎项目成员建议仅使用日志来记录数据,然后下载给定日期的所有日志,并在本地解析它以进行分析。我想知道其他人有这方面的经验吗?我有兴趣做这样的事情:
import java.util.logging.Logger;
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
log.info("Serving page '/example/farm'");
Farm farm = null;
try {
farm = datastore.getFarm();
log.info("Got farm ok.");
} catch (Exception ex) {
log.info("No farm found!");
}
}
}
如果我每天下载日志,我可以解析它并计算“正在服务页面...”消息出现的次数,并了解该页面出现的次数服务。从其他消息中找到所请求农场的成功率或失败率相同。这明智吗?我不确定使用日志有多慢,或者我是否最好尝试手动将这些统计信息存储在数据存储中。
另一个问题是,如果该页面每天被点击数千次,日志文件可能会很大且无法下载等?
谢谢
I'm using app engine java. I'm interested in collecting some analytics, but this is difficult since I need to make datastore classes for all the info I'm interested in tracking - it's going to detract from our 100 index quota, and just introduce extra complexity to my project.
I was reading through the dev forum, an app engine project member suggested just using the log to record data, then download all the logs for a given day, and parse it locally to do our analytics. I wonder if anyone else has experience with this? I'd be interested in doing something like:
import java.util.logging.Logger;
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
log.info("Serving page '/example/farm'");
Farm farm = null;
try {
farm = datastore.getFarm();
log.info("Got farm ok.");
} catch (Exception ex) {
log.info("No farm found!");
}
}
}
if I downloaded the logs each day, I could parse it and count the # of times the "Serving page..." message appears, and get an idea for how many times that page is served. Same for the success or fail rate of finding the requested Farm from the other message. Is this sensible? I'm not sure how slow it is to use the log, or if I'm better off trying to store these stats in the datastore manually.
Another concern is if this page gets hit thousands of times a day, the log file may be enormous and impractical to download etc?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我以前做过这种内部分析,并且总是在任务队列上生成事件以将信息记录在数据存储中。它运作良好,因为您可以在应用程序内构建自定义分析工具,并使其可以通过浏览器从任何地方访问。
通过切换到付费帐户,可以轻松克服索引 100 的限制。您可能会发现您将保持在免费配额内并且实际上不需要支付任何费用,但它会给您更多索引。
顺便说一句,谷歌分析策略是一个有趣的策略。您可以简单地使用 urlfetch() 或在各种仅限管理的 URL 上创建任务队列事件。然后使用分析来查看这些页面被触摸的次数。
I've done this sort of internal analytics before and I've always spawned events on the task queue to record the information in the datastore. It works well because you can build the custom analysis tools inside the app and make them accessible from anywhere via the browser.
The 100 limit on the indexes can be overcome easily enough by switching to a paid account. You may find that you'll stay within the free quotas and not actually pay anything, but it will give you more indexes.
BTW, the Google Analytics strategy is an interesting one. You could simply use urlfetch() or create task queue events on various admin-only URLs. Then use analytics to see how many times those pages were touched.
有第三方服务可用于此目的。您可以在您的应用程序中使用它们。我不能建议你自己做。查看 Google Analytics(分析)
There are third party services available for the purpose. You can use them in your application. I can't suggest you to do it as your own. Check out Google Analytics