简体   繁体   English

Logstash 与 Kafka 有何不同

[英]How Logstash is different than Kafka

How Log stash is different than Kafka? Log stash 与 Kafka 有何不同? and if both are same which is better?如果两者相同,哪个更好? and How?以及如何?

I found both are the pipelines where one can push the data for further processing.我发现两者都是可以推送数据以进行进一步处理的管道。

Kafka is much more powerful than Logstash. Kafka 比 Logstash 强大得多。 For syncing data from such as PostgreSQL to ElasticSearch, Kafka connectors could do the similar work with Logstash.为了将数据从 PostgreSQL 同步到 ElasticSearch,Kafka 连接器可以用 Logstash 做类似的工作。

One key difference is: Kafka is a cluster, while Logstash is basically single instance.一个关键的区别是:Kafka 是一个集群,而 Logstash 基本上是单实例。 You could run multiple Logstash instances.您可以运行多个 Logstash 实例。 But these Logstash instances are not aware of each other.但是这些 Logstash 实例并不知道彼此。 For example, if one instance goes down, others will not take over its work.例如,如果一个实例出现故障,其他实例将不会接管其工作。 Kafka handles the node down automatically. Kafka 自动处理节点。 And if you set up Kafka connectors to work in the distributed mode, other connectors could take over the work of the down connector.如果您将 Kafka 连接器设置为在分布式模式下工作,则其他连接器可以接管向下连接器的工作。

Kafka and Logstash could also work together. Kafka 和 Logstash 也可以一起工作。 For example, run a Logstash instance on every node to collect logs, and send the logs to Kafka.例如,在每个节点上运行一个 Logstash 实例来收集日志,并将日志发送到 Kafka。 Then you could write the Kafka consumer code to do any handling you want.然后您可以编写 Kafka 消费者代码来执行您想要的任何处理。

Logstash is a tool that can be used to collect, process and forward events and log messages. Logstash是一个工具,可用于收集、处理和转发事件和日志消息。 Collection is accomplished through a number of input plugins .收集是通过许多input 插件完成的 You can use Kafka as an input plugin, where it will read events from a Kafka topic.您可以使用Kafka作为输入插件,它将从 Kafka 主题读取事件。 Once an input plugin has collected data it can be processed by any number of filters which modify and annotate the event data.一旦输入插件收集了数据,它就可以被任意数量的过滤器处理,这些过滤器修改和注释事件数据。 Finally events are routed to outpu t plugins which can forward the events to a variety of external programs including Elasticsearch.最后,事件被路由到outpu 插件,这些插件可以将事件转发到各种外部程序,包括 Elasticsearch。

Where as Kafka is a messaging software that persists messages, has TTL, and the notion of consumers that pull data out of Kafka. Kafka是一种消息传递软件,可以持久化消息,具有 TTL,以及从 Kafka 中提取数据的消费者概念。 Some of it's usages could be:它的一些用法可能是:

  • Stream Processing流处理
  • Website Activity Tracking网站活动追踪
  • Metrics Collection and Monitoring指标收集和监控
  • Log Aggregation日志聚合

So simply both of them have their own advantages and disadvantages.所以简单地说,它们都有各自的优点和缺点。 But then it depends on your requirements solely.但这完全取决于您的要求。

In addition, I want to add somethings through scenarios:另外,我想通过场景添加一些东西:

Scenario 1: Event Spikes场景 1:事件峰值

The app you deployed has a bad bug where information is logged excessively, flooding your logging infrastructure.您部署的应用程序有一个严重的错误,信息被过度记录,淹没了您的日志记录基础设施。 This spike or a burst of data is fairly common in other multi-tenant use cases as well, for example, in the gaming and e-commerce industries.这种峰值或数据爆发在其他多租户用例中也很常见,例如在游戏和电子商务行业。 A message broker like Kafka is used in this scenario to protect Logstash and Elasticsearch from this surge.在这个场景中使用了像 Kafka 这样的消息代理来保护LogstashElasticsearch免受这种激增的影响。

在此处输入图片说明

Scenario 2: Elasticsearch not reachable场景 2:Elasticsearch 不可达

When eleasticsearch is not reachable, If you have a number of data sources streaming into Elasticsearch, and you can't afford to stop the original data sources, a message broker like Kafka could be of help here!当无法访问 eleasticsearch 时,如果您有大量数据源流入 Elasticsearch,并且您无法停止原始数据源,那么像 Kafka 这样的消息代理可能会有所帮助! If you use the Logstash shipper and indexer architecture with Kafka, you can continue to stream your data from edge nodes and hold them temporarily in Kafka.如果您将 Logstash 托运人和索引器架构与 Kafka 一起使用,您可以继续从边缘节点流式传输数据并将它们暂时保存在 Kafka 中。 As and when Elasticsearch comes back up, Logstash will continue where it left off, and help you catch up to the backlog of data.当 Elasticsearch 恢复时,Logstash 会从它停止的地方继续,并帮助您赶上积压的数据。

The whole blog is here about use cases of the Logtash and Kafka.整个博客是这里关于Logtash和卡夫卡的使用情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM