Filebeat 是一个轻量级的日志收集器,属于 Elastic Stack(以前称为 ELK Stack)的一部分。它负责从文件系统、日志文件或其他输入源收集日志数据,并将这些数据转发到 Elasticsearch 或 Logstash 进行进一步处理和分析。
Filebeat 主要有以下几种类型:
以下是在 Linux 系统上安装 Filebeat 的步骤:
Debian/Ubuntu:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install filebeat
CentOS/RHEL:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
sudo tee /etc/yum.repos.d/elastic.repo <<EOF
[elastic-7.x]
name=Elastic repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
sudo yum install filebeat
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.x.x-linux-x86_64.tar.gz
tar -zxvf filebeat-7.x.x-linux-x86_64.tar.gz
sudo mv filebeat-7.x.x-linux-x86_64 /usr/local/filebeat
sudo nano /etc/systemd/system/filebeat.service
在文件中添加以下内容:
[Unit]
Description=Filebeat sends log files to Logstash or Elasticsearch.
Documentation=https://www.elastic.co/guide/en/beats/filebeat/current/index.html
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
ExecStart=/usr/local/filebeat/filebeat -e -c /usr/local/filebeat/filebeat.yml
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable filebeat
sudo systemctl start filebeat
原因: 可能是配置文件错误或权限问题。
解决方法:
/usr/local/filebeat/filebeat.yml
是否正确。sudo systemctl status filebeat
原因: 可能是网络问题或配置错误。
解决方法:
output.elasticsearch:
hosts: ["http://localhost:9200"]
没有搜到相关的文章