.NET Core API Serilog-ELK VS logstash/fluentd

.NET Core API Serilog-ELK VS logstash/fluentd

以下是我的理解

  1. .net core api with serilog singk to ELK 可以直接发送日志给ELK
  2. Logstash & Fluentd 仅在我们想要将日志文件(通过处理数据)发送到 ELK 时才需要

我的问题是

  1. 为什么我需要logstash |如果我可以使用我的 api?
  2. 中的 serilog 接收器直接将我的日志发送到 ELK
  3. 如果我使用 serilog sing 直接发送给 ELK,如果与 ELK 的连接断开会发生什么情况?会不会暂时保存重新发送?
  4. 我在文章中读到它说 FluentD 使用持久队列而 Logstash 没有,但为什么需要这个队列?可以说如果我的应用程序有 1 个日志文件并且每秒更新一次。所以 logstash 每秒都会将整个文件发送给 ELK?即使它失败了,它也可以将我的日志文件重新发送到 ELK,对吗?那么为什么这里需要一个持久队列来进行 Fluentd/logstash 比较。

感谢对此的一些明确解释。

  1. why do I need logstash | fluentd if I can directly send my logs to ELK using a serilog sink in my API?
  2. If I send using serilog sing to ELK directly what happens if the connection to ELK is down? will it save temporarily and re send?

问题 2 在这里回答了问题 1。 FluentD 有一个 battle-tested 缓冲机制来处理 ELK 中断。此外,您不想使用应用程序线程来处理与应用程序完全无关的任务——日志传送。这会使您的应用复杂化并降低可移植性。

  1. I read in article it says FluentD uses persistent queue and Logstash doesn't but why exactly this queue needed? lets say If my app have 1 logfile and it gets updated every second. So logstash sends the whole file to ELK every second? even if it fails it can resend my log file to ELK right? so why a persistent queue needed here for Fluentd/ logstash comparasion.

正确。 FluentD 有一个缓冲区 https://docs.fluentd.org/configuration/buffer-section。它将发送您在 match 中设置的时间段内的任何内容(缓冲区用于在此处累积该时间段的日志)。如果日志后端(ELK)宕机了,它会一直把不成功的日志记录保存在缓冲区中。根据缓冲区大小,这可以处理非常严重的日志后端中断。一旦日志后端 (ELK) 再次启动,所有缓冲区都会发送给它,您不会丢失任何东西。

当你使用 kafka input/output 时,Logstash 的 persistent queue is a similar mechanism, but they went further and after the in-memory buffer they added external queues like Kafka. FluentD is also capable to use the queue,你仍然有一个缓冲区,以防 Kafka 宕机。