FileBeat配置輸出

1、配置Elasticsearch output

當你指定Elasticsearch作為output時,Filebeat通過Elasticsearch提供的HTTP API向其發送數據。例如:

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節點是用IP:PORT的形式定義的,那么添加protocol:https。

output.elasticsearch:
  hosts: ["localhost"]
  protocol: "https"
  username: "{beatname_lc}_internal"
  password: "{pwd}"

1.1 配置項

enabled

啟用或禁用該輸出。默認true。

hosts

Elasticsearch節點列表。事件以循環順序發送到這些節點。如果一個節點變得不可訪問,那么自動發送到下一個節點。每個節點可以是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調用前的HTTP路徑前綴。這對于Elasticsearch監聽HTTP反向代理的情況很有用。

headers

將自定義HTTP頭添加到Elasticsearch輸出的每個請求。

index

索引名字。(PS:意思是要發到哪個索引中去)。默認是"filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"(例如,"filebeat-6.3.2-2017.04.26")。如果你想改變這個設置,你需要配置 setup.template.name 和 setup.template.pattern 選項。如果你用內置的Kibana dashboards,你也需要設置setup.dashboards.index選項。

indices

索引選擇器規則數組,支持條件、基于格式字符串的字段訪問和名稱映射。如果索引缺失或沒有匹配規則,將使用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區域指定索引模板,用來設置在Elasticsearch中的映射。如果模板加載是啟用的(默認的),Filebeat在成功連接到Elasticsearch后自動加載索引模板。

你可以調整下列設置或者覆蓋一個已經存在的模板。

setup.template.enabled
設為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
來源:慕課網

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。