flume 日誌匯入elasticsearch

來源:互聯網
上載者:User

標籤:匯入   timestamp   ==   serialize   elastic   cal   啟動   amp   batch   

Flume配置

flume產生的資料結構

<span style="font-size:18px;">"_index" : "logstash-2013.01.07","_type" : "tms_jboss_syslog","_id" : "a_M9X_0YSpmE7A_bEzIFiw","_score" : 1.0, "_source" : {"@source":"file://localhost.localdomain/tmp/logstash_test.log","@tags":[],"@fields":{},"@timestamp":"2013-01-07T10:53:50.941Z","@source_host":"localhost.localdomain","@source_path":"/tmp/logstash_test.log","@message":"[2013-01-05 11:02:19,969] packBoxNumber eq 00004000000044043412 createdOffice eq VIP_BJ:;null","@type":"tms_jboss_syslog"}</span>

flume設定檔

agent.sources = tailagent.channels = memoryChannelagent.channels.memoryChannel.type = memoryagent.sources.tail.channels = memoryChannelagent.sources.tail.type = execagent.sources.tail.command = tail -F /home/hadoop/flume/conf/es_log/es_log.logagent.sources.tail.interceptors=i1 i2 i3agent.sources.tail.interceptors.i1.type=regex_extractoragent.sources.tail.interceptors.i1.regex = (\\w.*):(\\w.*):(\\w.*)\\sagent.sources.tail.interceptors.i1.serializers = s1 s2 s3agent.sources.tail.interceptors.i1.serializers.s1.name = sourceagent.sources.tail.interceptors.i1.serializers.s2.name = typeagent.sources.tail.interceptors.i1.serializers.s3.name = src_pathagent.sources.tail.interceptors.i2.type=org.apache.flume.interceptor.TimestampInterceptor$Builderagent.sources.tail.interceptors.i3.type=org.apache.flume.interceptor.HostInterceptor$Builderagent.sources.tail.interceptors.i3.hostHeader = hostagent.sinks = elasticsearchagent.sinks.elasticsearch.channel = memoryChannelagent.sinks.elasticsearch.type=org.apache.flume.sink.elasticsearch.ElasticsearchSinkagent.sinks.elasticsearch.batchSize=100agent.sinks.elasticsearch.hostNames=127.0.0.1:9300agent.sinks.k1.indexType = bar_typeagent.sinks.elasticsearch.indexName=logstashagent.sinks.elasticsearch.clusterName=elasticsearchagent.sinks.elasticsearch.serializer=org.apache.flume.sink.elasticsearch.ElasticsearchLogStashEventSerializer
啟動:

 ../bin/flume-ng agent -c . -f es_log.conf -n agent  -Dflume.root.logger=INFO,console

測試資料

website:weblog:login_page weblog data1website:weblog:profile_page weblog data2website:weblog:transaction_page weblog data3website:weblog:docs_page weblog data4syslog:syslog:sysloggroup syslog data1syslog:syslog:sysloggroup syslog data2syslog:syslog:sysloggroup syslog data3syslog:syslog:sysloggroup syslog data4syslog:syslog:sysloggroup syslog data5syslog:syslog:sysloggroup syslog data6

之後就能夠在es叢集上看到通過flume匯入的資料了

這時候編輯log檔案時候會被flume讀入es叢集中並即時產生索引  例如以所看到的:


這樣就能夠通過es對日誌的即時檢索了

flume 日誌匯入elasticsearch

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.