1、配置Elasticsearch output
當你指定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é)點是用IP:PORT的形式定義的韧拒,那么添加protocol:https伞租。
output.elasticsearch:
hosts: ["localhost"]
protocol: "https"
username: "{beatname_lc}_internal"
password: "{pwd}"
1.1 配置項
enabled
啟用或禁用該輸出贞谓。默認true。
hosts
Elasticsearch節(jié)點列表葵诈。事件以循環(huán)順序發(fā)送到這些節(jié)點裸弦。如果一個節(jié)點變得不可訪問,那么自動發(fā)送到下一個節(jié)點驯击。每個節(jié)點可以是URL形式烁兰,也可以是IP:PORT形式。如果端口沒有指定徊都,用9200沪斟。
output.elasticsearch:
hosts: ["10.45.3.2:9220", "10.45.3.1:9230"]
protocol: https
path: /elasticsearch
username
用于認證的用戶名
password
用戶認證的密碼
protocol
可選值是:http 或者 https。默認是http。
path
HTTP API調(diào)用前的HTTP路徑前綴主之。這對于Elasticsearch監(jiān)聽HTTP反向代理的情況很有用择吊。
headers
將自定義HTTP頭添加到Elasticsearch輸出的每個請求。
index
索引名字槽奕。(PS:意思是要發(fā)到哪個索引中去)几睛。默認是"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
請求超時時間上鞠。默認90秒。
1.2 加載Elasticsearch 索引模板
在filebeat.yml配置文件的setup.template區(qū)域指定索引模板芯丧,用來設(shè)置在Elasticsearch中的映射芍阎。如果模板加載是啟用的(默認的),F(xiàn)ilebeat在成功連接到Elasticsearch后自動加載索引模板注整。
你可以調(diào)整下列設(shè)置或者覆蓋一個已經(jīng)存在的模板能曾。
setup.template.enabled
設(shè)為false表示禁用模板加載
setup.template.name
模板的名字。默認是filebeat肿轨。Filebeat的版本總是跟在名字后面寿冕,所以最終的名字是 filebeat-%{[beat.version]}
setup.template.pattern
模板的模式。默認模式是filebeat-*椒袍。例如:
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
setup.template.fields
描述字段的YAML文件路徑驼唱。默認是 fields.yml。
setup.template.overwrite
是否覆蓋存在的模板驹暑。默認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
鏈接:https://www.imooc.com/article/70007
來源:慕課網(wǎng)