天天看點

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

Logstash啊,根據input來監控資料,根據output來使用資料!!!

手把手帶你看官方文檔(Logstash inputs和Logstash outputs)

<a href="https://www.elastic.co/guide/index.html">https://www.elastic.co/guide/index.html</a>

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

<a href="https://www.elastic.co/guide/en/logstash/index.html">https://www.elastic.co/guide/en/logstash/index.html</a>

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

<a href="https://www.elastic.co/guide/en/logstash/2.4/index.html">https://www.elastic.co/guide/en/logstash/2.4/index.html</a>

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

  

  關于 Logstash inputs、Logstash outputs和Filter plugins,很多很多,自行去官網看,我這裡不多贅述。僅僅拿下面來示範:

Logstash 的input

file input

  最常用的input插件是file。

<a href="https://www.elastic.co/guide/en/logstash/2.4/plugins-inputs-file.html">https://www.elastic.co/guide/en/logstash/2.4/plugins-inputs-file.html</a>

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

  這個,是可以自定義的。我這裡是

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

  我這裡是, 監控/home/hadoop/app.log這個檔案的變化。

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

  重新打開,另外一個HadoopMaster界面。

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

  其實,這個檔案,.sincedb_8f3299d0a5bdb7df6154f681fc150341也會記錄。

 注意:

   第一次讀取新檔案,不會有.sincedb等這些,預設根據這個start_position去讀,若start_position是end,則讀最後。若start_position是begin,則讀最開始。

若不是第一次讀取檔案了,重新開機Logstash,則會有.sincedb檔案了,則就轉去根據這個.sincedb檔案讀了。不管start_position是什麼,都不起效了。

  start_position:指定從什麼位置開始讀取檔案資料,預設是結束位置,也可以指定為從頭開始。

注意:start_position僅在該檔案從未被監聽過的時候起作用,因為logstash在讀取檔案的時候會記錄一個.sincedb檔案來跟蹤檔案的讀取位置,當檔案被讀取過一次之後,下次就會從.sincedb中記錄的位置讀取,start_position參數就無效了。檔案預設在使用者目錄下。

  注意一個坑:ignore_older屬性,表示忽略老的資料,值預設為86400,表示忽略24小時以前的資料。如果你新監控一個24小時以上沒有被修改過的老檔案的話,就算把start_position設定為beginning,也無法擷取之前的資料。

redis input

<a href="https://www.elastic.co/guide/en/logstash/2.4/plugins-inputs-redis.html">https://www.elastic.co/guide/en/logstash/2.4/plugins-inputs-redis.html</a>

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

   這裡,用到redis,不會用的博友,請移步

   這裡,等我安裝好了之後,再來。

Logstash 的output

redis output

<a href="https://www.elastic.co/guide/en/logstash/2.4/plugins-outputs-redis.html">https://www.elastic.co/guide/en/logstash/2.4/plugins-outputs-redis.html</a>

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

elasticsearch output

  即把Logstash裡的資料,寫到elasticsearch 叢集(這台192.168.80.10裡)

  1.x中屬性名稱叫host

預設向es中建立的索引庫是logstash-%{+YYYY.MM.dd},可以利用es中的索引模闆特性定義索引庫的一些基礎配置。

Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)
Logstash之Logstash inputs(file和redis插件)、Logstash outputs(elasticsearch 和redis插件)和Filter pluginsredis的安裝(圖文詳解)

繼續

Filter plugins

<b>本文轉自大資料躺過的坑部落格園部落格,原文連結:</b><b>http://www.cnblogs.com/zlslch/p/6624457.html</b><b>,如需轉載請自行聯系原作者</b>

繼續閱讀