logstash配置文件


 僅羅列了一些常用基礎配置,更多配置請到官網查看

https://www.elastic.co/guide/en/logstash/current

 

logstash.yml配置文件

# ------------  Node identity ------------

#節點名稱,默認主機名
node.name: test


# ------------ Data path ------------------

#數據存儲路徑,默認LOGSTASH_HOME/data
path.data:


# ------------ Pipeline Settings --------------

#pipeline ID,默認main
pipeline.id: main


#輸出通道的工作workers數據量,默認cpu核心數
pipeline.workers: 

# How many events to retrieve from inputs before sending to filters+workers
#單個工作線程在嘗試執行其過濾器和輸出之前將從輸入收集的最大事件數量,默認125
pipeline.batch.size: 125


#將較小的批處理分派給管道之前,等待的毫秒數,默認50ms
pipeline.batch.delay: 50


#此值為true時,即使內存中仍然有運行中事件,也會強制Logstash在關機期間退出
#默認flase
pipeline.unsafe_shutdown: false


#管道事件排序
#選項有;auto,true,false,默認auto
pipeline.ordered: auto


# ------------ Pipeline Configuration Settings --------------

#配置文件路徑
path.config:

#主管道的管道配置字符串
config.string:

#該值為true時,檢查配置是否有效,然后退出,默認false
config.test_and_exit: false

#該值為true時,會定期檢查配置是否已更改,並在更改后重新加載配置,默認false
config.reload.automatic: false

#檢查配置文件更改的時間間隔,默認3s
config.reload.interval: 3s 

#該值為true時,將完整編譯的配置顯示為調試日志消息,默認false
config.debug: false

#該值為true時,開啟轉義
config.support_escapes: false


# ------------ HTTP API Settings -------------

#是否開啟http訪問,默認true
http.enabled: true

#綁定主機地址,可以是ip,主機名,默認127.0.0.1
http.host: 127.0.0.1

#服務監聽端口,可以是單個端口,也可以是范圍端口,默認9600-9700
http.port: 9600-9700


# ------------ Module Settings ---------------

#模塊定義,必須為數組
#模塊變量名格式必須為var.PLUGIN_TYPE.PLUGIN_NAME.KEY
modules:
  - name: MODULE_NAME
    var.PLUGINTYPE1.PLUGINNAME1.KEY1: VALUE
    var.PLUGINTYPE1.PLUGINNAME1.KEY2: VALUE
    var.PLUGINTYPE2.PLUGINNAME1.KEY1: VALUE
    var.PLUGINTYPE3.PLUGINNAME3.KEY1: VALUE
    
    
# ------------ Queuing Settings --------------

#事件緩沖的內部排隊模型,可選項:memory,persisted,默認memory
queue.type: memory

#啟用持久隊列(queue.type: persisted)后將在其中存儲數據文件的目錄路徑
#默認path.data/queue
path.queue:

#啟用持久隊列(queue.type: persisted)時使用的頁面數據文件的大小
#默認64mb
queue.page_capacity: 64mb

#啟用持久隊列(queue.type: persisted)后,隊列中未讀事件的最大數量
#默認0
queue.max_events: 0

#啟用持久隊列(queue.type: persisted)后,隊列的總容量,單位字節,默認1024mb
queue.max_bytes: 1024mb

#啟用持久隊列(queue.type: persisted)后,在強制檢查點之前的最大ACKed事件數,默認1024
queue.checkpoint.acks: 1024

#啟用持久隊列(queue.type: persisted)后,在強制檢查點之前的最大書面事件數,默認1024
queue.checkpoint.writes: 1024

# If using queue.type: persisted, the interval in milliseconds when a checkpoint is forced on the head page
# Default is 1000, 0 for no periodic checkpoint.
#啟用持久隊列(queue.type: persisted)后,執行檢查點的時間間隔,單位ms,默認1000ms
queue.checkpoint.interval: 1000


# ------------ Dead-Letter Queue Settings --------------

#是否啟用插件支持的DLQ功能的標志,默認false
dead_letter_queue.enable: false


#dead_letter_queue.enable為true時,每個死信隊列的最大大小
#若死信隊列的大小超出該值,則被刪除,默認1024mb
dead_letter_queue.max_bytes: 1024mb

#死信隊列存儲路徑,默認path.data/dead_letter_queue
path.dead_letter_queue:


# ------------ Debugging Settings --------------

#日志輸出級別,選項:fatal,error,warn,info,debug,trace,默認info
log.level: info

#日志格式,選項:json,plain,默認plain
log.format:

#日志路徑,默認LOGSTASH_HOME/logs
path.logs:


# ------------ Other Settings --------------

#插件存儲路徑
path.plugins: []

#是否啟用每個管道在不同日志文件中的日志分隔
#默認false
pipeline.separate_logs: false

 

logstash.conf文件

該文件定義了logstash從哪里獲取輸入,然后輸出到哪里

#從Beats輸入,以json格式輸出到Elasticsearch
input {
  beats {
    port => 5044
    codec => 'json'
  }
}

output {
  elasticsearch {
    #elasticsearch地址,多個以','隔開
    hosts => ["http://localhost:9200"]
    #創建的elasticsearch索引名,可以自定義也可以使用下面的默認
    index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
  }
}

#從kafka輸入,以json格式輸出到Elasticsearch input { kafka { #kafka地址,多個用逗號','隔開 bootstrap_servers => ["ip1:port2","ip2:port2"] #消費者組 group_id => 'test' # kafka topic 名稱 topics => 'logstash-topic' codec => 'json' } } output { elasticsearch { hosts => ["http://localhost:9200"] index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}" } }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM