运维

运维

Products

当前位置:首页 > 运维 >

Filebeat配置文件中如何设置以实现日志的实时传输?

96SEO 2025-07-30 10:33 12


啥是Filebeat?

Filebeat是一个轻巧量级的日志收集器, 它能收集系统日志、事件和自定义数据,并将其发送到Elasticsearch、Logstash或直接发送到文件。

CentOS上Filebeat的配置文件详解

Filebeat配置文件概述

Filebeat的配置文件是filebeat.yml,它包含了Filebeat的全部配置信息。

filebeat.inputs:
  - type: log
    enabled: true
    paths:
      - /var/log/*.log
    hosts: 
    username: "elastic"
    password: "your_password"

Filebeat配置详解

inputs

inputs定义了Filebeat要监控的日志文件或目录。

  • type: 定义输入的类型, 如log、system或metric。
  • enabled: 是不是启用该输入。
  • paths: 要监控的日志文件或目录路径。
  • hosts: 要监控的主机地址。

output

output定义了Filebeat要发送数据的目标。

  • logstash: 将数据发送到Logstash。
  • elasticsearch: 将数据发送到Elasticsearch。
  • file: 将数据写入文件。

processors

processors定义了在数据发送到输出之前对数据进行处理的规则。

  • add_tag: 添加标签到事件。
  • drop_field: 删除字段。
  • modify_field: 修改字段。

filebeat.inputs:
  - type: log
    enabled: true
    paths:
      - /var/log/*.log
    hosts: 
    username: "elastic"
    password: "your_password"
output.elasticsearch:
  hosts: 
  username: "elastic"
  password: "your_password"

通过配置filebeat.yml文件, 你能轻巧松地将日志数据收集并发送到Elasticsearch、Logstash或文件。在配置Filebeat时 请确保正确设置inputs、outputs和processors,以便满足你的需求。


标签: CentOS

提交需求或反馈

Demand feedback