代码之家  ›  专栏  ›  技术社区  ›  TheHorizon

ELK:设置logstash ELK堆栈的多个http输入

  •  4
  • TheHorizon  · 技术社区  · 8 年前

    问题:

    我已经拥有的:

    input {
      http {
            host => "0.0.0.0"
            port => "5000"
        }
    }
    
    output {
      elasticsearch {
          hosts => "elasticsearch:9200"
      }
    }
    

    我需要:

    • 多个http输入,因为我有多个组件-类似于(但第二个输入不侦听请求):
    input {
      http {
            host => "0.0.0.0"
            port => "5000"
      }
      http {
          host => "0.0.0.0"
          port => "7070"
      }
    }
    
    2 回复  |  直到 8 年前
        1
  •  9
  •   ichigolas    8 年前

    您可以为每个输入设置一个类型,并使用该类型生成索引名称:

    input {
      http {
        host => "0.0.0.0"
        port => "5000"
        type => "A"
      }
    
      http {
        host => "0.0.0.0"
        port => "5001"
        type => "B"
      }
    }
    

    使用该类型可能就足够了,因为您可以使用它过滤记录。但您可能还需要将每种类型的记录存储在不同的索引中,因为每种类型可能对同一字段使用不同的类型。这会导致映射冲突。

    output {
      elasticsearch {
        hosts => "elasticsearch:9200"
        index => "%{[type]}-%{+YYYY.MM.dd}"
      }
    }
    
        2
  •  3
  •   TheHorizon    8 年前

    我已经 决定

    我需要 添加端口 在我的 docker撰写。yml公司 文件输入 日志存储: 章节如下:

    ports:
      - "5000:5000"
      - "7070:7070"
    

    type => "A"
    

    效果很好。