ubuntu

如何通过filebeat监控ubuntu进程

小樊
36
2025-09-07 06:08:28
栏目: 智能运维

可通过以下方式使用Filebeat监控Ubuntu进程:

  1. 启用系统模块监控进程
    编辑Filebeat配置文件 /etc/filebeat/filebeat.yml,启用system模块并配置process监控:

    filebeat.modules:
      - module: system
        metricsets: ["process"]  # 监控进程指标
        period: 10s              # 采集间隔
    

    重启Filebeat使配置生效:sudo systemctl restart filebeat

  2. 通过HTTP API获取进程数据
    Filebeat 7.x+支持通过HTTP API获取监控数据,需在配置中启用API:

    http.enabled: true
    http.port: 8080
    

    访问 http://<filebeat-host>:8080/api/status 可查看进程相关指标。

  3. 结合第三方工具可视化

    • Prometheus + Grafana:配置Filebeat输出指标到Prometheus,再通过Grafana创建进程监控仪表盘。
    • Elastic Stack(ELK):将Filebeat数据发送至Elasticsearch,用Kibana可视化进程日志和指标。
  4. 直接查看进程日志
    若需监控特定进程日志,可在filebeat.yml中指定进程日志路径:

    filebeat.inputs:
      - type: log
        enabled: true
        paths: ["/var/log/process-name/*.log"]  # 替换为目标进程日志路径
    

    重启后,进程日志会通过Filebeat发送至配置的后端。

说明:Filebeat本身不直接提供进程监控功能,需依赖system模块或集成其他工具(如Metricbeat)实现。若需更专业的进程监控,可考虑使用tophtop等系统工具或专门的进程监控软件。

0
看了该问题的人还看了