centos

Filebeat如何监控CentOS网络

小樊
52
2025-09-01 19:03:43
栏目: 智能运维

要使用Filebeat监控CentOS网络,需借助其模块化功能,核心步骤如下:

  1. 安装Filebeat
    通过YUM仓库安装:

    sudo yum install filebeat -y  
    

    (需先安装Elastic Stack的Elasticsearch和Kibana,用于数据存储与可视化)

  2. 启用Packetbeat模块(关键步骤)
    Filebeat通过Packetbeat模块采集网络流量,编辑配置文件/etc/filebeat/filebeat.yml

    filebeat.inputs:  
    - type: packetbeat  
      enabled: true  
      interfaces:  
        - device: "eth0"  # 替换为实际网卡名(如ens33)  
      protocols:  
        - type: http  
          port: 80,443   # 监控HTTP/HTTPS端口  
        - type: tcp  
          port: 22,3306  # 监控SSH/MySQL等TCP端口  
    

    (可添加exclude: ["lo"]排除本地回环接口)

  3. 配置输出
    将数据发送至Elasticsearch(或Logstash):

    output.elasticsearch:  
      hosts: ["localhost:9200"]  # 替换为ES地址  
      index: "network-traffic-%{+yyyy.MM.dd}"  
    
  4. 启动服务并验证

    sudo systemctl start filebeat  
    sudo systemctl enable filebeat  
    

    通过Kibana访问http://localhost:5601,在Discover中选择packetbeat-*索引查看流量数据。

注意

0
看了该问题的人还看了