【问题标题】:Reading from simple Logs file with elasticsearch使用 elasticsearch 从简单的日志文件中读取
【发布时间】:2019-10-04 17:56:19
【问题描述】:

我在 Windows 上运行 ElasticSearch.bat (cluster) 和 kibana.bat,据我所知 Elasticsearch index Json 格式...

我有 3 个 SpringBoot 项目,其中包含 log4j 生成的日志文件(例如:dd-mm-yyyy.log) 这是我的问题:

有什么方法可以让我的项目成为节点并从这些日志中读取、索引和搜索

如果没有,是否有任何改变使其成为可能?

我的目标是使用 ElasticSearch 在这些日志中搜索字符串

谢谢

【问题讨论】:

  • 技术上正确的堆栈是 Filebeat -> Logstash -> Elasticsearch -> Kibana 将 Filebeat 代理安装到您的应用程序节点。 elastic.co/guide/en/beats/filebeat/current/… 如果您的日志格式已经可以被索引,您可以跳过 Logstash

标签: java spring-boot elasticsearch elastic-stack


【解决方案1】:

第一个install Filebeat

configure Filebeat 列出你的日志文件的路径

这应该会为您在 Elasticsearch 中的日志编制索引。如果您希望能够仅查询来自单个应用程序的日志,则记录将包含一个“源”字段,该字段是日志文件的完整路径。您可以使用它来指定要查询的日志。

如果您想区分日志源,还可以在 Filebeat 配置中添加自定义字段。调整 example from the docs 假设应用程序正在登录文件夹 c:/app1/logs/ 和 c:/app2/logs/

filebeat.inputs:
- type: log
  paths:
    - 'c:/app1/logs/*.log'
  fields:
    app: 1
  field_under_root: true
- type: log
  paths:
    - 'c:/app2/logs/*.log'
  fields:
    app: 2
  fields_under_root: true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多