Filebeat Configuration Example linux
############### Filebeat #############web
filebeat:正則表達式
# List of prospectors to fetch data.redis
prospectors:數據庫
-json
# paths指定要監控的日誌windows
paths:服務器
- /var/log/*.logapp
#指定被監控的文件的編碼類型使用plain和utf-8都是能夠處理中文日誌的。負載均衡
# Some sample encodings:
# plain, utf-8, utf-16be-bom, utf-16be, utf-16le, big5, gb18030, gbk,
# hz-gb-2312, euc-kr, euc-jp, iso-2022-jp, shift-jis, ...
#encoding: plain
#指定文件的輸入類型log(默認)或者stdin。
input_type: log
# 在輸入中排除符合正則表達式列表的那些行
# exclude_lines: ["^DBG"]
# 包含輸入中符合正則表達式列表的那些行默認包含全部行include_lines執行完畢以後會執行exclude_lines。
# include_lines: ["^ERR", "^WARN"]
# 忽略掉符合正則表達式列表的文件默認爲每個符合paths定義的文件都建立一個harvester。
# exclude_files: [".gz$"]
# 向輸出的每一條日誌添加額外的信息好比「level:debug」方便後續對日誌進行分組統計。默認狀況下會在輸出信息的fields子目錄下以指定的新增fields創建子目錄例如fields.level。
#fields:
# level: debug
# review: 1
# 若是該選項設置爲true則新增fields成爲頂級目錄而不是將其放在fields目錄下。自定義的field會覆蓋filebeat默認的field。
#fields_under_root: false
# 能夠指定Filebeat忽略指定時間段之外修改的日誌內容好比2h兩個小時或者5m(5分鐘)。
#ignore_older: 0
# 若是一個文件在某個時間段內沒有發生過更新則關閉監控的文件handle。默認1h,change只會在下一次scan纔會被發現
#close_older: 1h
# i設定Elasticsearch輸出時的document的type字段也能夠用來給日誌進行分類。Default: log
#document_type: log
# Filebeat以多快的頻率去prospector指定的目錄下面檢測文件更新好比是否有新增文件若是設置爲0s則Filebeat會盡量快地感知更新佔用的CPU會變高。默認是10s。
#scan_frequency: 10s
# 每一個harvester監控文件時使用的buffer的大小。
#harvester_buffer_size: 16384
# 日誌文件中增長一行算一個日誌事件max_bytes限制在一第二天志事件中最多上傳的字節數多出的字節會被丟棄。The default is 10MB.
#max_bytes: 10485760
# 適用於日誌中每一條日誌佔據多行的狀況好比各類語言的報錯信息調用棧。這個配置的下面包含以下配置
#multiline:
# The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
#pattern: ^\[
# Defines if the pattern set under pattern should be negated or not. Default is false.
#negate: false
# Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
# that was (not) matched before or after or as long as a pattern is not matched based on negate.
# Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
#match: after
# The maximum number of lines that are combined to one event.
# In case there are more the max_lines the additional lines are discarded.
# Default is 500
#max_lines: 500
# After the defined timeout, an multiline event is sent even if no new pattern was found to start a new event
# Default is 5s.
#timeout: 5s
# 若是設置爲trueFilebeat從文件尾開始監控文件新增內容把新增的每一行文件做爲一個事件依次發送而不是從文件開始處從新發送全部內容。
#tail_files: false
# Filebeat檢測到某個文件到了EOF以後每次等待多久再去檢測文件是否有更新默認爲1s。
#backoff: 1s
# Filebeat檢測到某個文件到了EOF以後等待檢測文件更新的最大時間默認是10秒。
#max_backoff: 10s
# 定義到達max_backoff的速度默認因子是2到達max_backoff後變成每次等待max_backoff那麼長的時間才backoff一次直到文件有更新纔會重置爲backoff。
#backoff_factor: 2
# 這個選項關閉一個文件,當文件名稱的變化。#該配置選項建議只在windows。
#force_close_files: false
# Additional prospector
#-
# Configuration to use stdin input
#input_type: stdin
# spooler的大小spooler中的事件數量超過這個閾值的時候會清空發送出去不管是否到達超時時間。
#spool_size: 2048
# 是否採用異步發送模式(實驗!)
#publish_async: false
# spooler的超時時間若是到了超時時間spooler也會清空發送出去不管是否到達容量的閾值。
#idle_timeout: 5s
# 記錄filebeat處理日誌文件的位置的文件
registry_file: /var/lib/filebeat/registry
# 若是要在本配置文件中引入其餘位置的配置文件能夠寫在這裏須要寫完整路徑可是隻處理prospector的部分。
#config_dir:
############################# Output ##########################################
# 輸出到數據配置.單個實例數據能夠輸出到elasticsearch或者logstash選擇其中一種註釋掉另一組輸出配置。
output:
### 輸出數據到Elasticsearch
elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]
# 輸出認證.
#protocol: "https"
#username: "admin"
#password: "s3cr3t"
# 啓動進程數.
#worker: 1
# 輸出數據到指定index default is "filebeat" 可使用變量[filebeat-]YYYY.MM.DD keys.
#index: "filebeat"
# 一個模板用於設置在Elasticsearch映射默認模板加載是禁用的,沒有加載模板這些設置能夠調整或者覆蓋現有的加載本身的模板
#template:
# Template name. default is filebeat.
#name: "filebeat"
# Path to template file
#path: "filebeat.template.json"
# Overwrite existing template
#overwrite: false
# Optional HTTP Path
#path: "/elasticsearch"
# Proxy server url
#proxy_url: http://proxy:3128
# 發送重試的次數取決於max_retries的設置默認爲3
#max_retries: 3
# 單個elasticsearch批量API索引請求的最大事件數。默認是50。
#bulk_max_size: 50
# elasticsearch請求超時事件。默認90秒.
#timeout: 90
# 新事件兩個批量API索引請求之間須要等待的秒數。若是bulk_max_size在該值以前到達額外的批量索引請求生效。
#flush_interval: 1
# elasticsearch是否保持拓撲。默認false。該值只支持Packetbeat。
#save_topology: false
# elasticsearch保存拓撲信息的有效時間。默認15秒。
#topology_expire: 15
# 配置TLS參數選項如證書頒發機構等用於基於https的鏈接。若是tls丟失主機的CAs用於https鏈接elasticsearch。
#tls:
# List of root certificates for HTTPS server verifications
#certificate_authorities: ["/etc/pki/root/ca.pem"]
# Certificate for TLS client authentication
#certificate: "/etc/pki/client/cert.pem"
# Client Certificate Key
#certificate_key: "/etc/pki/client/cert.key"
# Controls whether the client verifies server certificates and host name.
# If insecure is set to true, all server host names and certificates will be
# accepted. In this mode TLS based connections are susceptible to
# man-in-the-middle attacks. Use only for testing.
#insecure: true
# Configure cipher suites to be used for TLS connections
#cipher_suites: []
# Configure curve types for ECDHE based cipher suites
#curve_types: []
# Configure minimum TLS version allowed for connection to logstash
#min_version: 1.0
# Configure maximum TLS version allowed for connection to logstash
#max_version: 1.2
### 發送數據到logstash 單個實例數據能夠輸出到elasticsearch或者logstash選擇其中一種註釋掉另一組輸出配置。
#logstash:
# Logstash 主機地址
#hosts: ["localhost:5044"]
# 配置每一個主機發布事件的worker數量。在負載均衡模式下最好啓用。
#worker: 1
# #發送數據壓縮級別
#compression_level: 3
# 若是設置爲TRUE和配置了多臺logstash主機輸出插件將負載均衡的發佈事件到全部logstash主機。
#若是設置爲false輸出插件發送全部事件到隨機的一臺主機上若是選擇的不可達將切換到另外一臺主機。默認是false。
#loadbalance: true
# 輸出數據到指定index default is "filebeat" 可使用變量[filebeat-]YYYY.MM.DD keys.
#index: filebeat
# Optional TLS. By default is off.
#配置TLS參數選項如證書頒發機構等用於基於https的鏈接。若是tls丟失主機的CAs用於https鏈接elasticsearch。
#tls:
# List of root certificates for HTTPS server verifications
#certificate_authorities: ["/etc/pki/root/ca.pem"]
# Certificate for TLS client authentication
#certificate: "/etc/pki/client/cert.pem"
# Client Certificate Key
#certificate_key: "/etc/pki/client/cert.key"
# Controls whether the client verifies server certificates and host name.
# If insecure is set to true, all server host names and certificates will be
# accepted. In this mode TLS based connections are susceptible to
# man-in-the-middle attacks. Use only for testing.
#insecure: true
# Configure cipher suites to be used for TLS connections
#cipher_suites: []
# Configure curve types for ECDHE based cipher suites
#curve_types: []
### 文件輸出將事務轉存到一個文件每一個事務是一個JSON格式。主要用於測試。也能夠用做logstash輸入。
#file:
# 指定文件保存的路徑。
#path: "/tmp/filebeat"
# 文件名。默認是 Beat 名稱。上面配置將生成 packetbeat, packetbeat.1, packetbeat.2 等文件。
#filename: filebeat
# 定義每一個文件最大大小。當大小到達該值文件將輪滾。默認值是1000 KB
#rotate_every_kb: 10000
# 保留文件最大數量。文件數量到達該值將刪除最舊的文件。默認是7一星期。
#number_of_files: 7
### Console output 標準輸出JSON 格式。
# console:
#若是設置爲TRUE事件將很友好的格式化標準輸出。默認false。
#pretty: false
############################# Shipper #########################################
shipper:
# #日誌發送者信息標示
# 若是沒設置以hostname名自居。該名字包含在每一個發佈事務的shipper字段。能夠以該名字對單個beat發送的全部事務分組。
#name:
# beat標籤列表包含在每一個發佈事務的tags字段。標籤可用很容易的按照不一樣的邏輯分組服務器。
#例如一個web集羣服務器能夠對beat添加上webservers標籤而後在kibana的visualisation界面以該標籤過濾和查詢整組服務器。
#tags: ["service-X", "web-tier"]
# 若是啓用了ignore_outgoing選項beat將忽略從運行beat服務器上全部事務。
#ignore_outgoing: true
# 拓撲圖刷新的間隔。也就是設置每一個beat向拓撲圖發佈其IP地址的頻率。默認是10秒。
#refresh_topology_freq: 10
# 拓撲的過時時間。在beat中止發佈其IP地址時很是有用。當過時後IP地址將自動的從拓撲圖中刪除。默認是15秒。
#topology_expire: 15
# Internal queue size for single events in processing pipeline
#queue_size: 1000
# GeoIP數據庫的搜索路徑。beat找到GeoIP數據庫後加載而後對每一個事務輸出client的GeoIP位置目前只有Packetbeat使用該選項。
#geoip:
#paths:
# - "/usr/share/GeoIP/GeoLiteCity.dat"
# - "/usr/local/var/GeoIP/GeoLiteCity.dat"
############################# Logging #########################################
# 配置beats日誌。日誌能夠寫入到syslog也能夠是輪滾日誌文件。默認是syslog。
logging:
# 若是啓用發送全部日誌到系統日誌。
#to_syslog: true
# 日誌發送到輪滾文件。
#to_files: false
#
files:
# 日誌文件目錄。
#path: /var/log/mybeat
# 日誌文件名稱
#name: mybeat
# 日誌文件的最大大小。默認 10485760 (10 MB)。
rotateeverybytes: 10485760 # = 10MB
# 保留日誌週期。 默認 7。值範圍爲2 到 1024。
#keepfiles: 7
# Enable debug output for selected components. To enable all selectors use ["*"]
# Other available selectors are beat, publish, service
# Multiple selectors can be chained.
#selectors: [ ]
# 日誌級別。debug, info, warning, error 或 critical。若是使用debug但沒有配置selectors* selectors將被使用。默認error。
#level: error
filebeat.prospectors:
- input_type: log
paths:
- /log/channelserver.log
#- /home/wang/data/filebeat-5.0.2-linux-x86_64/test.log
encoding: gbk
symlinks: true
include_lines: ['
','
']
document_type: channelserver
fields_under_root: true
fields:
host: 192.168.10.155
processors:
- drop_fields:
#fields: ["beat.hostname", "beat.name", "beat.version", "input_type", "beat"]
fields: ["input_type", "beat", "offset", "source"]
output.redis:
enabled: true
hosts: ["192.168.10.188"]
port: 6379
datatype: list
key: "filebeat"
db: 0
output.file:
enabled: true
path: "/tmp/filebeat"
output.console:
enabled: false