zoukankan      html  css  js  c++  java
  • Logstash消费Kafka输出至Elasticsearch配置文件示例

     

    复制代码
    input
    {
        kafka
        {
            bootstrap_servers => "192.168.32.36:9092,192.168.32.37:9092,192.168.32.38:9092"
            topics => "msa-log-prod"
            codec => "json"
            group_id => "msa-log-prod-elsearch"
            consumer_threads => 4
            decorate_events => true
        }
        kafka
        {
            bootstrap_servers => "192.168.32.36:9092,192.168.32.37:9092,192.168.32.38:9092"
            topics => "msa-log-test"
            codec => "json"
            group_id => "msa-log-test-elsearch"
            consumer_threads => 2
            decorate_events => true
        }
    }
    
    output
    {
        if [env] == "prod" {
            elasticsearch
            {
                hosts => ["192.168.32.36:9200","192.168.32.37:9200","192.168.32.38:9200"]
                index => "msa-log-prod-%{+YYYY.MM.dd}"
            }
        }
        if [env] == "test" {
            elasticsearch
            {
                hosts => ["192.168.32.36:9200","192.168.32.37:9200","192.168.32.38:9200"]
                index => "msa-log-test-%{+YYYY.MM.dd}"
            }
        }
    }
    复制代码

    说明:需要kafka消息格式是json并且包含一个env字段用于区分环境,如果仅一个input和output可以去掉if判断。

  • 相关阅读:
    闭包问题小总结
    git常用命令总结
    数组对象方法的使用
    JS截取URL参数
    CSS清除浮动&内容居中&文字溢出
    网址大全
    any more
    下载网页视频
    下载无损音乐
    "前端" 宝藏网站
  • 原文地址:https://www.cnblogs.com/zyb2016/p/13652380.html
Copyright © 2011-2022 走看看