我应该将 elasticsearch 用于审计日志吗?

Should I use elasticsearch for audit logs?

我正在微服务架构中构建应用程序。所以我在不同的微服务上有不同的业务模型 运行。

微服务正在使用图形和文档数据库。

我要做的是,我需要在对象发生更改时保留所有有关对象的审计日志。 有几种方法可以做到这一点,我想到了两种:

  1. Store audit logs in the each databases whenever something changes to object.
  2. Instead of having it localized, make it to a central repository where we can see all the audits for whole application as behind the scenes application is served by micro services but at front this is just one app for the users and also for us. Would elastic search be used for this purpose of long term storage ? or we have other solutions ?

还有哪些其他方式是我必须遵循的最佳做法。我的objective到底是什么时候对象里面被谁改的。

干杯!

一般建议不要使用 ES 作为您的权威数据存储。如果您希望审计数据具有 99.99% 的可靠性,请将其存储在其他地方,并在需要其搜索能力时在 ES 中建立索引。

根据我的经验,ES 非常有弹性,但我仍然记得它的存储与众所周知的关系数据库或 Cassandra/HDFS 相比并不是那么完美,我不会在那里存储重要数据。

还要记住 ES 索引不是很灵活,如果你想大量重新缩放你的集群或更改字段映射,你可能必须重新索引所有内容。较新版本的 ES 提供 "Reindex API",但仍然是弱点。