Centralized Logging Architecture

简介: http://jasonwilder.com/blog/2013/07/16/centralized-logging-architecture/In Centralized Loggi...

http://jasonwilder.com/blog/2013/07/16/centralized-logging-architecture/

In Centralized Logging, I covered a few tools that help with the problem of centralized logging. Many of these tools address only a portion of the problem which means you need to use several of them together to build a robust solution.

The main aspects you will need to address are: collection, transport, storage, and analysis. In some special cases, you may also want to have an alerting capability as well.

Collection

Applications create logs in different ways, some log through syslog, others log directly to files. If you consider a typical web application running on a linux hosts, there will be a dozen or more log files in /var/log as well as a few application specific logs in home directories or other locations.

If you are supporting a web based application and your developers or operations staff need access to log data quickly in order to troubleshoot live issues, you need a solution that is able to monitor changes to log files in near real-time. If you are using a file replication based approach where files are replicated to a central server on a fixed schedule, then you can only inspect logs as frequently as the replication runs. A one minute rsync cron job might not be fast enough when your site is down and you are waiting for the relevant log data to be replicated.

On the other hand, if you need to analyze log data offline for calculating metrics or other batch related work, a file replication strategy might be a good fit.

Transport

Log data can accumulate quickly on multiple hosts. Transporting it reliably and quickly to your centralized location may need additional tooling in order to effectively transmit it and ensure data is not lost.

Frameworks such as Scribe, Flume, Heka, Logstash, Chukwa, fluentd, nsq and Kafka are designed for transporting large volumes of data from one host to another reliably. Although each of these frameworks addresses the transport problem, they do so quite differently.

For example, Scribe, nsq and Kafka, require clients to log data via their API. Typically, application code is written to log directly to these sources which allows them to reduce latency and improve reliability. If you want to centralize typical log file data, you would need something to tail and stream the logs via their respective APIs. If you control the app that is logging the data you want to collect, these can be much more efficient.

Logstash, Heka, fluentd and Flume provide a number of input sources but also support natively tailing files and transporting them reliably. These are a better fit for more general log collection.

While rsyslog and Syslog-ng are typically thought of as the defacto log collector, not all applications use syslog.

Storage

Now that your log data is being transfered, it needs a destination. Your centralized storage system needs to be able to handle the growth in data over time. Each day will add a certain amount of storage that is relative to the number of hosts and processes that are generating log data.

How you store things depends on a few things:

  • How long should it be stored - If the logs are for long-term, archival purposes and do not require immediate analysis, S3, AWS Glacier, or tape backup might be a suitable option since they provide relatively low cost for large volumes of data. If you only need a few days or months worth of logs, storing them on some form distributed storage systems such as HDFS, Cassandara, MongoDB or ElasticSearch also works well. If you only need a few hours worth of retention for real-time analysis, Redis might work as well.

  • Your environments data volume. - A days worth of logs for Google is much different than a days worth of logs for ACME Fishing Supplies. The storage system you chose should allow you to scale-out horizontally if your data volume will be large.

  • How will you need to access the logs - Some storage is not suitable for real-time or even batch analysis. AWS Glacier or tape backup can take hours to load a file. These don’t work if you need log access for production troubleshooting. If you plan to do more interactive data analysis, storing log data in ElasticSearch or HDFS may allow you work with the raw data more effectively. Some log data is so large that it can only be analyzed in more batch oriented frameworks. The defacto standard is this case is Apache Hadoop along with HDFS.

Analysis

Once your logs are stored on a centralized storage platform, you need a way to analyze them. The most common approach is a batch oriented process that runs periodically. If you are storing log data in HDFS, Hive or Pig might help analyzing the data easier than writing native MapReduce jobs.

If you need a UI for analysis, you can store parsed log data in ElasticSearch and use a front-end such as Kibana or Graylog2 to query and inspect the data. The log parsing can be handled by Logstash, Heka or applications logging with JSON directly. This approach allows more real-time, interactive access to the data but is not really suited for a mass batch processing.

Alerting

The last component that is sometimes nice to have is the ability to alert on log patterns or calculated metrics based on log data. Two common uses for this are error reporting and monitoring.

Most log data is not interesting but errors almost always indicate a problem. It’s much more effective to have the logging system email or notify respective parties when errors ocurr instead of having someone repeatedly watch for the events. There are several services that solely provide application error logging such as Sentry or HoneyBadger. These can also aggregate repetitve exceptions which can give you and idea of how frequently an error is occuring.

Another use case is monitoring. For example, you may have hundreds of web servers and want to know if they start returning 500 status codes. If you can parse your web log files and record a metric on the status code, you can then trigger alerts when that metric crosses a certain threshold. Riemann is designed for detecting scenarios just like this.

Hopefully this helps provide a basic model for designing a centralized logging solution for your environment.

目录
相关文章
|
Web App开发 移动开发 安全
Struts2 S2-062 (CVE-2021-31805) 远程代码执行漏洞
Apache 官方发布了 Apache Struts2 的风险通告,漏洞编号为 CVE-2021-31805,可能会导致远程代码执行。
758 1
|
6月前
|
JavaScript 算法 数据库
制造业报价困局:BOM自动解析与智能报价核算破局
JBoltAI推出智能报价系统,以BOM自动解析与智能核算技术破解制造业报价难题:秒级解析复杂物料清单,精准匹配工艺参数,标准化核算加工费及杂项成本,提升报价效率与准确性,助力企业降本增效、赢得订单。(239字)
288 5
|
6月前
|
人工智能 搜索推荐 API
AI编程平民化趋势:从昂贵工具到普惠服务的转变
近年来,AI编程工具加速平民化,价格大幅降低(如阿里云CodingPlan轻量版首月仅7.9元),推动开发门槛下降、生态繁荣。个人开发者、中小企业与教育领域广泛受益,市场呈现多样化、集成化、体验优化趋势。技术普惠正重塑软件开发未来。(238字)
|
10月前
|
微服务 监控
认识Seata
Seata是阿里巴巴开源的分布式事务解决方案,通过事务协调者(TC)、事务管理器(TM)和资源管理器(RM)协同工作,实现全局事务一致性。支持XA、AT、TCC、SAGA四种模式,其中AT为默认模式,具备最终一致性与低侵入性,广泛应用于微服务架构中。
认识Seata
|
监控 安全 API
使用PaliGemma2构建多模态目标检测系统:从架构设计到性能优化的技术实践指南
本文详细介绍了PaliGemma2模型的微调流程及其在目标检测任务中的应用。PaliGemma2通过整合SigLIP-So400m视觉编码器与Gemma 2系列语言模型,实现了多模态数据的高效处理。文章涵盖了开发环境构建、数据集预处理、模型初始化与配置、数据加载系统实现、模型微调、推理与评估系统以及性能分析与优化策略等内容。特别强调了计算资源优化、训练过程监控和自动化优化流程的重要性,为机器学习工程师和研究人员提供了系统化的技术方案。
1627 77
使用PaliGemma2构建多模态目标检测系统:从架构设计到性能优化的技术实践指南
Python-素数
本文介绍了如何使用 Python 判断素数,并通过具体示例展示了求 100 以内及自定义范围内所有素数的方法。内容包括素数的定义、判断素数的底层逻辑和步骤,以及详细的代码演示。适合初学者参考学习。
|
API 调度 C语言
互斥锁,自旋锁,原子操作的原理,区别和实现
v互斥锁,自旋锁,原子操作的原理,区别和实现
661 0
|
机器学习/深度学习 人工智能 算法
【深度学习之美】神经网络不胜语, M-P模型似可寻(入门系列之三)
“那些在个人设备里,谦谦卑卑地为我们哼着歌曲的数字仆人,总有一天会成为我们的霸主!”在“忍无可忍,无需再忍”这句俗语背后,也隐藏中神经网络常用的“激活函数”和“卷积”的概念。知其道,用其妙,THIS IS HOW!
35120 0
【深度学习之美】神经网络不胜语, M-P模型似可寻(入门系列之三)
|
人工智能 自然语言处理 数据挖掘
人工智能claude 3.5官网怎么用?claude中文镜像网站解读!
人工智能的浪潮席卷全球,每一次技术的突破都引发着行业的巨变。近期,Claude 的出现犹如一颗耀眼的明星🌟,迅速成为 AI 领域的焦点,并引发了业界对其与前任王者 GPT-4 的激烈讨论
|
存储 算法 数据处理
模拟数据读取函数有哪些
模拟数据读取函数主要用于测试和开发阶段,常见的有:numpy的random系列函数、pandas的DataFrame.sample()、Python内置的random模块等。这些函数可以生成随机或样本数据,方便快捷地进行数据处理和算法测试。

热门文章

最新文章