请教个 ELK 中, logstash 根据不同主机的 `tags` 来指定索引的问题

2022-11-21 11:40:08 +08:00
 proxychains

现在有多台主机, 需要把不同的日志分到不同的 es 索引上. 目前的 logstash 配置是:

 input {
       beats {
         port => 9090
         client_inactivity_timeout => 3600
      }
    }
    output {
      if [tags] in "oa" {
        elasticsearch {
          action => "index"
          hosts => ["http://es:9200"]
          index  => "oa-log-%{+YYYY-MM-dd}"
          user => "user"
          password => "user_pwd"
        }
      }
      if [tags] in "kernel-log" {
        elasticsearch {
          action => "index"
          hosts => ["http://es:9200"]
          index  => "kernel-log-%{+YYYY-MM-dd}"
          user => "user"
          password => "user_pwd"
        }
  }
     } 

其中一台主机的 filebeat 配置:

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/oa/*.log
  tags: ["oa-1-192-ACCESS"]
  fields:
    index: oa-log-%{+YYYY-MM-dd}
filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: true
output.logstash:
  hosts: ["logstash:9090"]
  enabled: true

没有根据 tags 指定索引的时候, 是正常的.

现在添加 if 字段后, 发现 es 上没有自动创建这个索引. es 中也允许自动创建 oa*, kernel* 这俩索引了 ES 新手. 麻烦请教下这个问题

373 次点击
所在节点    问与答
1 条回复
coolloves
2022-11-21 12:55:06 +08:00
加个 oa*和 kernel* 模板

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/896746

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX