zoukankan      html  css  js  c++  java
  • ELK Nxlog->Kafka->ElasticSearch

    Windows 系统下,log4日志通过kafka发送到elasticsearch; windows 下nxlog没有找到直接发送数据到kafka的插件,所以采用logstash中转下

       

    Nxlog-->logstash(tcp)-->kafka(producer)-->logstash(consumer)-->elasticsearch

       

       

    nxlog配置

       

    <Input kafkalog4>

    Module im_file

    File "E:\log\webapi\kafka.txt"

    SavePos TRUE                

    </Input>

       

    <Output kafkalog4out>

    Module om_tcp

    Host 127.0.0.1

    Port 6666

    </Output>

       

    <Route jsonruby>

    Path kafkalog4 => kafkalog4out

    </Route>

       

    Logstash配置

    input {

    tcp {

    port=>6666

    codec => multiline {

    charset =>"locale"

    pattern => "^d{4}-d{2}-d{2} d{2}:d{2}:d{2}\,d{3}"

    negate => true

    what => "previous"

    }

    type=>"kafkain"

    }

       

    kafka {

    zk_connect => "127.0.0.1:2181"

    topic_id => "test"

    codec => plain

    reset_beginning => false

    consumer_threads => 5

    decorate_events => true

    }

       

    }

       

    output {

     

    if [type=="kafkain"]

    {

    kafka {

    bootstrap_servers => "localhost:9092"

    topic_id => "test"

    codec => plain {

    format => "%{message}"

    }

    }

    }

    else{

    elasticsearch {

    hosts => ["localhost:9200"]

    index => "test-kafka-%{+YYYY-MM}"

    }

    }

    }

       

       

    Logstash 文件在使用前用

    logstash -f logstash.conf --configtest --verbose

    检测下是否正确

       

    显示OK的话起动logstash如下命令

    Logstash agent -f logstash.conf

       

    kibana显示日志如下

       

       

       

  • 相关阅读:
    二分查找 【数组的二分查找】
    二分答案 [TJOI2007]路标设置
    队测 逆序对 permut
    【线段树】 求和
    状压DP Sgu223 骑士
    状压DP Poj3311 Hie with the Pie
    状压DP入门 传球游戏之最小总代价
    状压DP 小W选书籍
    状压DP [Usaco2008 Nov]mixup2 混乱的奶牛
    __gcd()用法
  • 原文地址:https://www.cnblogs.com/liuyuhua/p/5333114.html
Copyright © 2011-2022 走看看