1、配置Elasticsearch output
當(dāng)你指定Elasticsearch作為output時(shí),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 配置項(xiàng)
enabled
啟用或禁用該輸出。默認(rèn)true。
hosts
Elasticsearch節(jié)點(diǎn)列表。事件以循環(huán)順序發(fā)送到這些節(jié)點(diǎn)。如果一個(gè)節(jié)點(diǎn)變得不可訪問,那么自動(dòng)發(fā)送到下一個(gè)節(jié)點(diǎn)。每個(gè)節(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路徑前綴。這對(duì)于Elasticsearch監(jiān)聽HTTP反向代理的情況很有用。
headers
將自定義HTTP頭添加到Elasticsearch輸出的每個(gè)請求。
index
索引名字。(PS:意思是要發(fā)到哪個(gè)索引中去)。默認(rèn)是"filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"(例如,"filebeat-6.3.2-2017.04.26")。如果你想改變這個(gè)設(shè)置,你需要配置 setup.template.name 和 setup.template.pattern 選項(xiàng)。如果你用內(nèi)置的Kibana dashboards,你也需要設(shè)置setup.dashboards.index選項(xiàng)。
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
請求超時(shí)時(shí)間。默認(rèn)90秒。
1.2 加載Elasticsearch 索引模板
在filebeat.yml配置文件的setup.template區(qū)域指定索引模板,用來設(shè)置在Elasticsearch中的映射。如果模板加載是啟用的(默認(rèn)的),F(xiàn)ilebeat在成功連接到Elasticsearch后自動(dòng)加載索引模板。
你可以調(diào)整下列設(shè)置或者覆蓋一個(gè)已經(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