#### 前言
部署的filebeat服务采用supervisor形式管理
#### 下载filebeat
请自行下载filebeat安装包,其版本必须与logstash,elasticsearch,kibana的版本一致
解压并放置到部署目录下,可参考如下所示:
```
tar -zxvf filebeat-7.6.2-linux-x86_64.tar.gz
mv filebeat-7.6.2-linux-x86_64 /opt/filebeat
```
#### 配置filebeat.yml文件
由于我把日志数据推送到logstash里,所以配置文件给出的是关于logstash配置
```
cat > /opt/filebeat/filebeat.yml <<-EOF
filebeat.inputs:
- type: log
enabled: true # 必须为true,否则logstash接收不到
paths:
- /opt/filebeat/my_logstash.log # 日志文件路径
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
setup.template.settings:
index.number_of_shards: 1
setup.kibana:
output.logstash:
hosts: ["url/ip:5044"] # 建议: 云主机上部署,url采用内网的url,同理,ip也是采用内网的ip
processors:
- add_host_metadata: ~
- add_cloud_metadata: ~
- add_docker_metadata: ~
- add_kubernetes_metadata: ~
EOF
```
#### 安装supervisor服务管理
```
yum -y install epel
-
release
yum -
y install supervisor
systemctl enable supervisord.service
systemctl start supervisord.service
sed
-
i
's/\(files = supervisord.d\/*\).*/\1*.conf/g'
/
etc
/
supervisord.conf
systemctl restart supervisord.service
```
#### supervisor服务管理
```
cat > /etc/supervisord.d/filebeat.conf <<-EOF
[program:filebeat]
user=root
priority=10
directory=/opt/filebeat
command=/opt/filebeat/filebeat -e -c /opt/filebeat/filebeat.yml
autostart=true
autorestart=true
stopsignal=KILL
EOF
```
> supervisorctl update
> supervisorctl start filebeat
#### 补充
linux系统安装supervisor管理服务,可自行查找,后续再完善