夜莺浏览日志、filebeat采集日志(四)

文章目录


一、elasticsearch

  • docker启动
bash 复制代码
docker run -d -p 9200:9200 -p 9300:9300 --restart=always -e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-e discovery.type=single-node -e xpack.security.enabled=true -e ELASTIC_PASSWORD=123456 \
-v /home/monitor/elasticsearch/data:/usr/share/elasticsearch/data --name monitor-es elasticsearch:8.12.2
  • 用户名 elastic,密码 123456

二、filebeat

bash 复制代码
[Unit]
Description=Filebeat
After=network.target
 
[Service]
Type=simple
ExecStart=/home/monitor/filebeat/filebeat -e -c /home/monitor/filebeat/filebeat.yml

[Install]
WantedBy=multi-user.target
  • filebeat.yml
    配置需要监控的日志,例如nginx、redis,配置写入的elasticsearch信息
bash 复制代码
filebeat.inputs:
- type: filestream
  paths:
    - /home/nginx/logs/access.log
  prospector.scanner.exclude_files: ['.gz$']
  tags: ["nginx"]

- type: filestream
  paths:
    - /home/logs/example/all.log
  prospector.scanner.exclude_files: ['.gz$']
  tags: ["example"]

output.elasticsearch:
  hosts: ["192.168.6.12:9200"]
  preset: balanced
  protocol: "http"
  username: "elastic"
  password: "123456"
  indices:
    - index: "filebeat-6.13-%{+yyyy.MM}"

setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression

processors:
  - drop_fields:
      fields: ["log","host","input","agent","ecs"]
      ignore_missing: false
  • filebeat服务安装
bash 复制代码
chmod 755 /home/monitor/filebeat/filebeat.yml
chmod 777 /home/monitor/filebeat/filebeat
cp /home/monitor/filebeat/filebeat.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start filebeat && sudo systemctl enable filebeat
  • 检查服务状态
bash 复制代码
sudo systemctl status filebeat

三、日志分析

  • 配置elasticsearch
    系统配置 > 数据源 > elasticsearch
  • 日志分析
    日志分析 > 即时查询
    展示字段:tags、message
    过滤条件例子:tags:example AND message:INFO
相关推荐
lytao1234 天前
分布式日志采集 Loki 配置及部署详细
分布式·loki·日志采集·分布式日志采集
量化交易学徒22 天前
【DevOps】Logstash详解:高效日志管理与分析工具
运维·elk·devops·logstash·日志采集
core5121 个月前
Docker compose 的方式一键部署夜莺
运维·docker·监控·夜莺
优维科技EasyOps2 个月前
优维全新力作:统一采控平台
数据清洗·日志采集·采集能力·agent管理·指标管理
一只超级兵(*•̀ᴗ•́*)و ̑̑4 个月前
Docker上部署LPG(loki+promtail+grafana)踩坑复盘
运维·docker·容器·grafana·日志采集·lpg
云计算-Security6 个月前
Nightingale 夜莺监控系统 - 监控篇(2)
监控·nightingale·夜莺
大数据老司机9 个月前
Filebeat 采集 k8s Pod 和 Events 日志实战操作
kubernetes·filebeat·日志采集
三劫散仙10 个月前
Log4j2 配置日志记录发送到 kafka 中
大数据·log4j·日志采集