1、配置Elasticsearch output
當(dāng)你指定Elasticsearch作為output時粪糙,F(xiàn)ilebeat通過Elasticsearch提供的HTTP API向其發(fā)送數(shù)據(jù)异旧。例如:
output.elasticsearch:
hosts: ["https://localhost:9200"]
index: "filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"
ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
ssl.certificate: "/etc/pki/client/cert.pem"
ssl.key: "/etc/pki/client/cert.key"
為了啟用SSL沉馆,只需要在hosts下的所有URL添加https即可
output.elasticsearch:
hosts: ["https://localhost:9200"]
username: "filebeat_internal"
password: "YOUR_PASSWORD"
如果Elasticsearch節(jié)點(diǎn)是用IP:PORT的形式定義的汰扭,那么添加protocol:https囤躁。
output.elasticsearch:
hosts: ["localhost"]
protocol: "https"
username: "{beatname_lc}_internal"
password: "{pwd}"
1.1 配置項
enabled
啟用或禁用該輸出冀痕。默認(rèn)true。
hosts
Elasticsearch節(jié)點(diǎn)列表狸演。事件以循環(huán)順序發(fā)送到這些節(jié)點(diǎn)言蛇。如果一個節(jié)點(diǎn)變得不可訪問,那么自動發(fā)送到下一個節(jié)點(diǎn)宵距。每個節(jié)點(diǎn)可以是URL形式腊尚,也可以是IP:PORT形式。如果端口沒有指定满哪,用9200婿斥。
output.elasticsearch:
hosts: ["10.45.3.2:9220", "10.45.3.1:9230"]
protocol: https
path: /elasticsearch
username
用于認(rèn)證的用戶名
password
用戶認(rèn)證的密碼
protocol
可選值是:http 或者 https劝篷。默認(rèn)是http。
path
HTTP API調(diào)用前的HTTP路徑前綴民宿。這對于Elasticsearch監(jiān)聽HTTP反向代理的情況很有用娇妓。
headers
將自定義HTTP頭添加到Elasticsearch輸出的每個請求。
index
索引名字活鹰。(PS:意思是要發(fā)到哪個索引中去)哈恰。默認(rèn)是"filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"(例如,"filebeat-6.3.2-2017.04.26")志群。如果你想改變這個設(shè)置着绷,你需要配置 setup.template.name 和 setup.template.pattern 選項。如果你用內(nèi)置的Kibana dashboards锌云,你也需要設(shè)置setup.dashboards.index選項荠医。
indices
索引選擇器規(guī)則數(shù)組,支持條件桑涎、基于格式字符串的字段訪問和名稱映射彬向。如果索引缺失或沒有匹配規(guī)則,將使用index字段石洗。例如:
output.elasticsearch:
hosts: ["http://localhost:9200"]
index: "logs-%{[beat.version]}-%{+yyyy.MM.dd}"
indices:
- index: "critical-%{[beat.version]}-%{+yyyy.MM.dd}"
when.contains:
message: "CRITICAL"
- index: "error-%{[beat.version]}-%{+yyyy.MM.dd}"
when.contains:
message: "ERR"
timeout
請求超時時間幢泼。默認(rèn)90秒紧显。
1.2 加載Elasticsearch 索引模板
在filebeat.yml配置文件的setup.template區(qū)域指定索引模板讲衫,用來設(shè)置在Elasticsearch中的映射。如果模板加載是啟用的(默認(rèn)的)孵班,F(xiàn)ilebeat在成功連接到Elasticsearch后自動加載索引模板涉兽。
你可以調(diào)整下列設(shè)置或者覆蓋一個已經(jīng)存在的模板。
setup.template.enabled
設(shè)為false表示禁用模板加載
setup.template.name
模板的名字篙程。默認(rèn)是filebeat枷畏。Filebeat的版本總是跟在名字后面,所以最終的名字是 filebeat-%{[beat.version]}
setup.template.pattern
模板的模式虱饿。默認(rèn)模式是filebeat-*拥诡。例如:
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
setup.template.fields
描述字段的YAML文件路徑。默認(rèn)是 fields.yml氮发。
setup.template.overwrite
是否覆蓋存在的模板渴肉。默認(rèn)false。
setup.template.settings._source
setup.template.name: "filebeat"
setup.template.fields: "fields.yml"
setup.template.overwrite: false
setup.template.settings:
_source.enabled: false
2爽冕、配置Logstash output
output.logstash:
hosts: ["127.0.0.1:5044"]
上面是配置Filebeat輸出到Logstash仇祭,那么Logstash本身也有配置,例如:
input {
beats {
port => 5044
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
}
}
3颈畸、配置Kafka output
output.kafka:
initial brokers for reading cluster metadata
hosts: ["kafka1:9092", "kafka2:9092", "kafka3:9092"]
message topic selection + partitioning
topic: '%{[fields.log_topic]}'
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzip
max_message_bytes: 1000000