Syslog日志集成搭建

搭建一个完整的 syslog → Filebeat → Elasticsearch → Kibana 测试环境,详细的分步骤配置手册 ,包括 Linux (Filebeat)Windows (Elasticsearch + Kibana) 的安装和配置。

部署架构

  • Filebeat :运行在 Linux 服务器 192.168.0.83,采集 syslog。

  • Elasticsearch + Kibana :运行在 Windows 服务器 192.168.0.100,负责存储日志和可视化。

  • syslog 流程

    syslog 设备/服务 → Filebeat (192.168.0.83) → Elasticsearch (192.168.0.100:9200) → Kibana (192.168.0.100:5601)

1. 安装和配置 Elasticsearch (Windows: 192.168.0.100)

  1. 下载并解压

  2. 配置文件

    编辑:C:\elasticsearch-<version>\config\elasticsearch.yml

    添加或修改以下内容:

    cluster.name: syslog-cluster
    node.name: node-1
    path.data: C:\elasticsearch\data
    path.logs: C:\elasticsearch\logs

    监听所有网卡,供 Filebeat 远程访问

    network.host: 0.0.0.0
    http.port: 9200

    单节点模式(测试环境用)

    discovery.type: single-node

3. 启动 Elasticsearch

在命令行进入 C:\elasticsearch-<version>\bin,执行:

复制代码
elasticsearch.bat
  • 打开浏览器访问 http://192.168.0.100:9200/,如果能看到 JSON 输出,说明成功。

2. 安装和配置 Kibana (Windows: 192.168.0.100)

  1. 下载并解压

  2. 配置文件

    编辑:C:\kibana-<version>\config\kibana.yml

    修改:

    server.port: 5601
    server.host: "0.0.0.0"

    指向本机的 Elasticsearch

    elasticsearch.hosts: ["http://192.168.0.100:9200"]

    设置 Kibana 实例的名称

    server.name: "kibana-win"

3. 启动 Kibana

在命令行进入 C:\kibana-<version>\bin,执行:

复制代码
kibana.bat
  • 打开浏览器访问 http://192.168.0.100:5601/,确认 Kibana 界面能加载。

3. 安装和配置 Filebeat (Linux: 192.168.0.83)

  1. 安装 Filebeat

    curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.14.3-x86_64.rpm
    sudo rpm -ivh filebeat-8.14.3-x86_64.rpm

2. 配置 syslog 输入

编辑:/etc/filebeat/filebeat.yml

修改或添加:

复制代码
filebeat.inputs:
  - type: syslog
    protocol.udp:
      host: "0.0.0.0:514"
    tags: ["syslog"]

output.elasticsearch:
  hosts: ["http://192.168.0.100:9200"]
  # 如果 ES 开启了用户名密码,这里需要:
  # username: "elastic"
  # password: "yourpassword"

setup.kibana:
  host: "192.168.0.100:5601"

默认 514 端口需要 root 权限监听,如果报错,可以改成 1514,然后在 syslog 服务端把日志发到 1514。

3. 启动 Filebeat 并设置开机自启

复制代码
sudo systemctl enable filebeat
sudo systemctl start filebeat
sudo systemctl status filebeat

4. 测试 Filebeat 是否能写入 Elasticsearch

复制代码
curl -X GET "192.168.0.100:9200/_cat/indices?v"
或
curl -X GET "https://192.168.0.100:9200/_cat/indices?v" -u elastic:你的密码 --insecure

4. 验证 Syslog 流程

通过http://localhost:5601/进入登录界面

输入账号和密码进行登录,进行日志集成配置

在登录界面选择 Stack Management

创建数据视图

创建数据视图后,就可以看到Syslog的日志加载到Elasticsearch上的效果了,选择Discover查看日志,以查看sendmail日志为例:

相关推荐
碳基沙盒18 小时前
OpenClaw 多 Agent 配置实战指南
运维
Elasticsearch2 天前
如何使用 Agent Builder 排查 Kubernetes Pod 重启和 OOMKilled 事件
elasticsearch
Elasticsearch3 天前
通用表达式语言 ( CEL ): CEL 输入如何改进 Elastic Agent 集成中的数据收集
elasticsearch
蝎子莱莱爱打怪4 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
DianSan_ERP4 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
呉師傅4 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
不是二师兄的八戒4 天前
Linux服务器挂载OSS存储的完整实践指南
linux·运维·服务器
zhangfeng11334 天前
趋动云 如何ssh登录 服务区 项目server
运维·人工智能·ssh
ZeroNews内网穿透4 天前
谷歌封杀OpenClaw背后:本地部署或是出路
运维·服务器·数据库·安全
失重外太空啦4 天前
nginx
运维·nginx