zoukankan      html  css  js  c++  java
  • logstash输出多个索引样式(顶级字段与二级字段)

    filebeat配置

    #表示的是会把 service作为fields的二级字段
    filebeat.inputs:
    - type: log enabled: true paths: - /var/log/aa.log fields: service: aa - type: log enabled: true paths: - /var/log/messages* fields: service: message

    fields_under_root:如果该选项设置为true,则新增fields成为顶级目录,而不是将其放在fields目录下。自定义的field会覆盖filebeat默认的field。例如添加如下配置:

    #表示的是会把 service作为fields顶级字段
    fields: service: message fields_under_root:
    true

    logstash配置

    #表示的是会把 service作为fields的二级字段logstash配置
    output { stdout { codec
    => json } elasticsearch { hosts => ["https://node01:9200","https://node02:9200","https://node03:9200"] ssl => true cacert => "/home/logstash/logstash-7.5.1/config/certs/ca.crt" index => "logstash-%{[fields][service]}-%{+YYYY.MM.dd}" user => "logstash_writer" password => "logstash" } }
    #表示的是会把 service作为fields的顶级字段logstash配置
    output {
      stdout {
        codec => json
      }
      elasticsearch {
        hosts => ["https://node01:9200","https://node02:9200","https://node03:9200"]
        ssl => true
        cacert => "/home/logstash/logstash-7.5.1/config/certs/ca.crt"
        index => "logstash-%{[service]}-%{+YYYY.MM.dd}"
        user => "logstash_writer"
        password => "logstash"
      }
    }

    也可以这样写

    if [fields][service] == 'aa' {
        elasticsearch {
    hosts => ["https://node01:9200","https://node02:9200","https://node03:9200"]
    index
    => "logstash-aa-%{+YYYY.MM.dd}"
    user
    => "logstash_writer"
    password
    => "logstash"
    }
    }

    if [fields][service] == "messages" {
    elasticsearch {
    hosts
    => ["https://node01:9200","https://node02:9200","https://node03:9200"]
    index
    => "logstash-messages-%{+YYYY.MM.dd}"
    user
    => "logstash_writer"
    password
    => "logstash"
    }
    }
  • 相关阅读:
    javascript之全局函数
    讲真,MySQL索引优化看这篇文章就够了
    aws亚马逊磁盘扩展卷步骤
    google支付回调验证(备用)
    Linux TCP状态TIME_WAIT 过多的处理
    MySQL索引优化分析
    CSS使图片变模糊,亲测非常好用
    linux ss 命令用法说明
    php一行代码获取本周一,本周日,上周一,上周日,本月一日,本月最后一日,上月一日,上月最后一日日期
    有哪些你追了很多女生才明白的道理?
  • 原文地址:https://www.cnblogs.com/fat-girl-spring/p/12931587.html
Copyright © 2011-2022 走看看