filebeat收集至es

下载安装包解压

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.8.1-linux-x86_64.tar.gz
tar xzvf filebeat-7.8.1-linux-x86_64.tar.gz

编辑配置文件

cat /data/app/filebeat/filebeat-7.8.1-linux-x86_64/filebeat.yml
filebeat.inputs:
- type: container
  enabled: true
  paths: '/var/lib/docker/containers/*/*.log'
#  multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}'
#  multiline.match: after
#  multiline.negate: true
#  multiline.max_lines: 10000
#  json.keys_under_root: true
#  json.add_error_key: true
#  json.message_key: log

filebeat.config:
  modules:
    path: ${path.config}/modules.d/*.yml
    reload.enabled: false


output.elasticsearch:
  hosts: '192.168.101.80:9200'
  username: "elastic"
  password: "qvz6pguDN8FYcZSgslRA"
  index: "sit-carcharging-logs-%{+yyyy.MM.dd}"
setup.template.settings:
  index.number_of_shards: 1
setup.template.enabled: true
setup.template.name: "sit-car-charging-logs"
setup.template.pattern: "sit-car-charging-logs-*"
setup.ilm.enabled: false
setup.kibana:
setup.ilm.enabled: false
setup.ilm.rollover_alias: "sit-car-charging-logs"
setup.ilm.pattern: "{now/d}-000001"
processors:
  - add_host_metadata:
      when.not.contains.tags: forwarded
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~

添加systemd file

cat /usr/lib/systemd/system/filebeat.service
[Unit]
Description=Filebeat
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=/data/app/filebeat/filebeat-7.8.1-linux-x86_64/filebeat -c /data/app/filebeat/filebeat-7.8.1-linux-x86_64/filebeat.yml
Restart=always

[Install]
WantedBy=multi-user.target

重载开机自启

systemctl daemon-reload
systemctl start filebeat
systemctl enable filebeat
posted @   西门运维  阅读(292)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
历史上的今天:
2017-12-20 HTTP请求和MIME介绍
2017-12-20 ATS 分级缓存
点击右上角即可分享
微信分享提示