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
来源:慕课网

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容