排查CentOS上FileBeat的故障可以按照以下步骤进行:
systemctl
命令检查FileBeat服务的状态:sudo systemctl status filebeat
sudo systemctl start filebeat
sudo systemctl enable filebeat
/etc/filebeat/filebeat.yml
是否正确配置。特别注意以下部分:
filebeat.inputs
:确保日志路径和输出配置正确。output.elasticsearch
:确认Elasticsearch的地址和端口配置正确。/var/log/filebeat/filebeat
目录下。检查这些日志文件可以获取详细的运行状态和错误信息。sudo tail -f /var/log/filebeat/filebeat
curl
命令查询Elasticsearch的健康状态:curl -X GET "localhost:9200/_cluster/health?pretty"
/var/log/elasticsearch/
目录下,查找任何可能的错误信息。import requests
import json
def check_filebeat_status():
response = requests.get('http://localhost:5066')
if response.status_code == 200:
print("Filebeat is running")
else:
print("Filebeat is not running")
def query_elasticsearch():
es_url = 'http://localhost:9200/_search'
query = {
"query": {
"match_all": {}
},
"size": 10
}
response = requests.post(f"{es_url}/_search", json=query)
results = json.loads(response.text)
for hit in results['hits']['hits']:
print(hit['_source'])
check_filebeat_status()
query_elasticsearch()
通过以上步骤,可以系统地排查和解决CentOS上FileBeat的故障。如果问题依然存在,建议参考FileBeat的官方文档或联系技术支持获取进一步帮助。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>