当前位置: 首页 > news >正文

Filebeat学习笔记

Filebeat基本概念

简介

Filebeat是一种轻量级日志采集器,内置有多种模块(auditd、Apache、Nginx、System、MySQL等),针对常见格式的日志大大简化收集、解析和可视化过程,只需一条命令即可。之所以能实现这一点,是因为它将自动默认路径(因操作系统而异)与Elasticsearch采集节点管道的定义和Kibana仪表板组合在一起。不仅如此,数个Filebeat模块还包括预配置的 Machine Learning 任务。另一点需要声明的是:根据采集的数据形式不同,形成了由多个模块组成的Beats。Beats是开源数据传输程序集,可以将其作为代理安装在服务器上,将操作数据发送给Elasticsearch,或者通过Logstash,在Kibana中可视化数据之前,在Logstash中进一步处理和增强数据。

Beats组成模块如下:

日志格式采集所需组件框架备注
Audit dataAuditbeat轻量型审计日志采集器
Log filesFilebeat轻量型日志采集器
AvailabilityHeartbeat轻量型运行时间监控采集器
MetricsMetribeat轻量型指标采集器
Network trafficPacketbeat轻量型网络数据采集器
Windows event logsWinlogbeat轻量型Windows事件日志采集器

在这里插入图片描述

Filebeat特点

  • 轻量型日志采集器,占用资源更少,对机器配置要求极低。
  • 操作简便,可将采集到的日志信息直接发送到ES集群、Logstash、Kafka集群等消息队列中。
  • 异常中断重启后会继续上次停止的位置。(通过${filebeat_home}\data\registry文件来记录日志的偏移量)。
  • 使用压力敏感协议(backpressure-sensitive)来传输数据,在logstash忙的时候,Filebeat会减慢读取-传输速度,一旦logstash恢复,则Filebeat恢复原来的速度。
  • Filebeat带有内部模块(auditd,Apache,Nginx,System和MySQL),可通过一个指定命令来简化通用日志格式的收集、解析和可视化。
bin/logstash -e 'input { stdin{} } output { stdout{} }'

Filebeat与Logstash对比

  • Filebeat是轻量级数据托运者,您可以在服务器上将其作为代理安装,以将特定类型的操作数据发送到Elasticsearch。与Logstash相比,其占用空间小,使用的系统资源更少。
  • Logstash具有更大的占用空间,但提供了大量的输入,过滤和输出插件,用于收集,丰富和转换来自各种来源的数据。
  • Logstash是使用Java编写,插件是使用jruby编写,对机器的资源要求会比较高。在采集日志方面,对CPU、内存上都要比Filebeat高很多。

Filebeat安装

Filebeat本身对机器性能要求不高,采集数据后采用http请求发送数据。

下载链接:https://www.elastic.co/cn/downloads/beats/filebeat

注意下载版本对应一致,避免出现兼容性问题。

将下载的filebeat-8.9.0-linux-x86_64.tar.gz文件上传到/usr/local/software/路径上。

cd /usr/local/software/
tar -xzvf filebeat-8.9.0-linux-x86_64.tar.gz
mv filebeat-8.9.0-linux-x86_64 filebeat-8.9.0
cd filebeat-8.9.0

官方文档:https://www.elastic.co/guide/en/beats/filebeat/current/index.html

通过修改filebeat.yml文件

###################### Filebeat Configuration Example ########################## This file is an example configuration file highlighting only the most common
# options. The filebeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/filebeat/index.html# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.# ============================== Filebeat inputs ===============================filebeat.inputs:# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.# filestream is an input for collecting log messages from files.
- type: filestream# Unique ID among all inputs, an ID is required.id: my-filestream-id# Change to true to enable this input configuration.# 输入默认是关闭状态,需要改成true打开enabled: false# Paths that should be crawled and fetched. Glob based paths.# 改成我们需要监控的日志文件paths:- /var/log/*.log#- c:\programdata\elasticsearch\logs\*# Windows的案例# Exclude lines. A list of regular expressions to match. It drops the lines that are# matching any regular expression from the list.# Line filtering happens after the parsers pipeline. If you would like to filter lines# before parsers, use include_message parser.#exclude_lines: ['^DBG']# Include lines. A list of regular expressions to match. It exports the lines that are# matching any regular expression from the list.# Line filtering happens after the parsers pipeline. If you would like to filter lines# before parsers, use include_message parser.#include_lines: ['^ERR', '^WARN']# Exclude files. A list of regular expressions to match. Filebeat drops the files that# are matching any regular expression from the list. By default, no files are dropped.#prospector.scanner.exclude_files: ['.gz$']# Optional additional fields. These fields can be freely picked# to add additional information to the crawled log files for filtering#fields:#  level: debug#  review: 1# ============================== Filebeat modules ==============================filebeat.config.modules:# Glob pattern for configuration loadingpath: ${path.config}/modules.d/*.yml# Set to true to enable config reloadingreload.enabled: false# Period on which files under path should be checked for changes#reload.period: 10s# ======================= Elasticsearch template setting =======================setup.template.settings:index.number_of_shards: 1#index.codec: best_compression#_source.enabled: false# ================================== General ===================================# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging# ================================= Dashboards =================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here or by using the `setup` command.
#setup.dashboards.enabled: false# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:# =================================== Kibana ===================================# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:# Kibana Host# Scheme and port can be left out and will be set to the default (http and 5601)# In case you specify and additional path, the scheme is required: http://localhost:5601/path# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601#host: "localhost:5601"# Kibana Space ID# ID of the Kibana Space into which the dashboards should be loaded. By default,# the Default Space will be used.#space.id:# =============================== Elastic Cloud ================================# These settings simplify using Filebeat with the Elastic Cloud (https://cloud.elastic.co/).# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:# ================================== Outputs ===================================# Configure what output to use when sending the data collected by the beat.# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch:# Array of hosts to connect to.hosts: ["localhost:9200"]# Protocol - either `http` (default) or `https`.#protocol: "https"# Authentication credentials - either API key or username/password.#api_key: "id:api_key"#username: "elastic"#password: "changeme"# ------------------------------ Logstash Output -------------------------------
#output.logstash:# The Logstash hosts#hosts: ["localhost:5044"]# Optional SSL. By default is off.# List of root certificates for HTTPS server verifications#ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]# Certificate for SSL client authentication#ssl.certificate: "/etc/pki/client/cert.pem"# Client Certificate Key#ssl.key: "/etc/pki/client/cert.key"# ================================= Processors =================================
processors:- add_host_metadata:when.not.contains.tags: forwarded- add_cloud_metadata: ~- add_docker_metadata: ~- add_kubernetes_metadata: ~# ================================== Logging ===================================# Sets log level. The default log level is info.
# Available log levels are: error, warning, info, debug
#logging.level: debug# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publisher", "service".
#logging.selectors: ["*"]# ============================= X-Pack Monitoring ==============================
# Filebeat can export internal metrics to a central Elasticsearch monitoring
# cluster.  This requires xpack monitoring to be enabled in Elasticsearch.  The
# reporting is disabled by default.# Set to true to enable the monitoring reporter.
#monitoring.enabled: false# Sets the UUID of the Elasticsearch cluster under which monitoring data for this
# Filebeat instance will appear in the Stack Monitoring UI. If output.elasticsearch
# is enabled, the UUID is derived from the Elasticsearch cluster referenced by output.elasticsearch.
#monitoring.cluster_uuid:# Uncomment to send the metrics to Elasticsearch. Most settings from the
# Elasticsearch output are accepted here as well.
# Note that the settings should point to your Elasticsearch *monitoring* cluster.
# Any setting that is not set is automatically inherited from the Elasticsearch
# output configuration, so if you have the Elasticsearch output configured such
# that it is pointing to your Elasticsearch monitoring cluster, you can simply
# uncomment the following line.
#monitoring.elasticsearch:# ============================== Instrumentation ===============================# Instrumentation support for the filebeat.
#instrumentation:# Set to true to enable instrumentation of filebeat.#enabled: false# Environment in which filebeat is running on (eg: staging, production, etc.)#environment: ""# APM Server hosts to report instrumentation results to.#hosts:#  - http://localhost:8200# API Key for the APM Server(s).# If api_key is set then secret_token will be ignored.#api_key:# Secret token for the APM Server(s).#secret_token:# ================================= Migration ==================================# This allows to enable 6.7 migration aliases
#migration.6_to_7.enabled: true

相关文章:

Filebeat学习笔记

Filebeat基本概念 简介 Filebeat是一种轻量级日志采集器&#xff0c;内置有多种模块&#xff08;auditd、Apache、Nginx、System、MySQL等&#xff09;&#xff0c;针对常见格式的日志大大简化收集、解析和可视化过程&#xff0c;只需一条命令即可。之所以能实现这一点&#…...

【实战】 九、深入React 状态管理与Redux机制(一) —— React17+React Hook+TS4 最佳实践,仿 Jira 企业级项目(十六)

文章目录 一、项目起航&#xff1a;项目初始化与配置二、React 与 Hook 应用&#xff1a;实现项目列表三、TS 应用&#xff1a;JS神助攻 - 强类型四、JWT、用户认证与异步请求五、CSS 其实很简单 - 用 CSS-in-JS 添加样式六、用户体验优化 - 加载中和错误状态处理七、Hook&…...

第九十五回 如何使用dio的转换器

文章目录 概念介绍使用方法使用默认的转换器自定义转换器 示例代码经验分享 我们在上一章回中介绍了"如何打造一个网络框架"相关的内容&#xff0c;本章回中将介绍 如何使用dio的转换器.闲话休提&#xff0c;让我们一起Talk Flutter吧。 概念介绍 转换器主要用来转…...

Python深度学习“四大名著”之一【赠书活动|第二期《Python机器学习:基于PyTorch和Scikit-Learn》】

近年来&#xff0c;机器学习方法凭借其理解海量数据和自主决策的能力&#xff0c;已在医疗保健、 机器人、生物学、物理学、大众消费和互联网服务等行业得到了广泛的应用。自从AlexNet模型在2012年ImageNet大赛被提出以来&#xff0c;机器学习和深度学习迅猛发展&#xff0c;取…...

RAID相关知识

简介 RAID &#xff08; Redundant Array of Independent Disks &#xff09;即独立磁盘冗余阵列&#xff0c;通常简称为磁盘阵列。RAID技术将多个单独的物理硬盘以不同的方式组合成一个逻辑磁盘&#xff0c;从而提高硬盘的读写性能和数据安全性。 数据组织形式 分块&#x…...

DataStructure--Basic

程序设计数据结构算法 只谈数据结构不谈算法就跟去话剧院看梁山伯与祝英台结果只有梁山伯在演&#xff0c;祝英台生病了没来一样。 本文的所有内容都出自《大话数据结构》这本书中的代码实现部分&#xff0c;建议看书&#xff0c;书中比我本文写的全。 数据结构&#xff0c;直…...

Intellij IDEA 双击启动报错ClassNotFoundException: com.licel.b.z@

项目场景&#xff1a; 新从官网下载了ideaIU-2023.2.win.zip &#xff0c;安装后双击启动报错&#xff0c; 无法运行idea, 提示信息如下 问题描述 Internal error. Please refer to https://jb.gg/ide/critical-startup-errorsjava.lang.ExceptionInInitializerErrorat java…...

使用 Logstash 及 enrich processor 实现数据丰富自动化

在我之前的文章&#xff1a; Elasticsearch&#xff1a;enrich processor &#xff08;7.5发行版新功能&#xff09; Elasticsearch&#xff1a;使用 Elasticsearch ingest pipeline 丰富数据 通过上面的两篇文章的介绍&#xff0c;我们应该充分掌握了如何使用 enrich proce…...

Django模板语法和请求

1、在django关于模板文件加载顺序 创建的django项目下会有一个seeetings.py的文件 如果在seeetings.py 中加了 os.path.join(BASE_DIR,‘templates’)&#xff0c;如果是pycharm创建的django项目会加上&#xff0c;就会默认先去根目录找templates目录下的html文件&#xff0c…...

Android跨进程传大图思考及实现——附上原理分析

1.抛一个问题 这一天&#xff0c;法海想锻炼小青的定力&#xff0c;由于Bitmap也是一个Parcelable类型的数据&#xff0c;法海想通过Intent给小青传个特别大的图片 intent.putExtra("myBitmap",fhBitmap)如果“法海”(Activity)使用Intent去传递一个大的Bitmap给“…...

【动态规划part13】| 300.最长递增子序列、674.最长连续递增序列、718.最长重复数组

目录 &#x1f388;LeetCode 300.最长递增子序列 &#x1f388;LeetCode 674. 最长连续递增序列 &#x1f388;LeetCode 718. 最长重复子数组 &#x1f388;LeetCode 300.最长递增子序列 链接&#xff1a;300.最长递增子序列 给你一个整数数组 nums &#xff0c;找到其…...

QMainWindow

文章目录 QMainWindow基本元素QMainWindow函数介绍简单的示例效果图 QMainWindow QMainWindow是一个为用户提供主窗口程序 的类&#xff0c;包含一个菜单栏(menu bar)、多个工具栏 (tool bars)、多个锚接部件(dock widgets)、―个 状态栏(status bar )及一个中心部件(central …...

PV操作解决经典进程同步问题

一.经典同步问题 在学习《操作系统》时&#xff0c;会接触到进程的概念&#xff0c;其中不可避免的接触到进程同步问题&#xff0c;今天我们用熟悉的PV操作解决一些经典的进程同步问题。 二.生产者-消费者问题 1.问题描述 问题描述&#xff1a;一组生产者进程和一组消费者进…...

一文3000字从0到1使用Selenium进行自动化测试

对于很多刚入门的测试新手来说&#xff0c;大家都将自动化测试作为自己职业发展的一个主要阶段。可是&#xff0c;在成为一名合格的自动化测试工程师之前&#xff0c;我们不仅要掌握相应的理论知识&#xff0c;还要进行大量的实践&#xff0c;积累足够的经验&#xff0c;以便快…...

基于开源IM即时通讯框架MobileIMSDK:RainbowChat v9.0版已发布

关于MobileIMSDK MobileIMSDK 是一套专门为移动端开发的开源IM即时通讯框架&#xff0c;超轻量级、高度提炼&#xff0c;一套API优雅支持UDP 、TCP 、WebSocket 三种协议&#xff0c;支持iOS、Android、H5、标准Java平台&#xff0c;服务端基于Netty编写。 工程开源地址是&am…...

交叉编译----宿主机x86 ubuntu 64位-目标机ARMv8 aarch64

1.交叉编译是什么&#xff0c;为什么要交叉编译 编译&#xff1a;在一个平台上生成在该平台上的可执行代码交叉编译&#xff1a;在一个平台上生成在另一个平台上的可执行代码交叉编译的例子&#xff1a;如51单片机的可执行代码&#xff08;hex文件&#xff09;是在集成环境kei…...

安防监控视频汇聚平台EasyCVR修改录像计划等待时间较长是什么原因?

安防监控视频EasyCVR视频融合汇聚平台基于云边端智能协同&#xff0c;支持海量视频的轻量化接入与汇聚、转码与处理、全网智能分发等。音视频流媒体视频平台EasyCVR拓展性强&#xff0c;视频能力丰富&#xff0c;具体可实现视频监控直播、视频轮播、视频录像、云存储、回放与检…...

深度学习调参指南

1. 选择合适的模型架构 模型的结构(层数和宽度)&#xff0c;参数配置&#xff0c;尽量用已经有效的模型 2. 选择优化器 针对具体的问题&#xff0c;从选择常用的优化器开始&#xff0c;进行比较 3. 选择BatchSize 1). Batch Size决定训练速度&#xff0c;但是不影响验证集…...

MYSQL 优化常用方法

1、选取最适用的字段属性 MySQL可以很好的支持大数据量的存取&#xff0c;但是一般说来&#xff0c;数据库中的表越小&#xff0c;在它上面执行的查询也就会越快。因此&#xff0c;在创建表的时候&#xff0c;为了获得更好的性能&#xff0c;我们可以将表中字段的宽度设得尽可…...

isp调试工具环境搭建及其介绍!

一、isp调试环境搭建&#xff1a; 后期调试isp&#xff0c;是在rv1126提供的RKISP2.x Tuner工具上进行调试&#xff0c;所以我们大前提必须要把这个环境和一些操作先搞熟悉来&#xff0c;后面有一些专用术语&#xff0c;我们遇到了再去看&#xff0c;现在专门看一些专用术语&am…...

终极指南:Graph Nets从入门到精通 - 深度解析图神经网络消息传递机制

终极指南&#xff1a;Graph Nets从入门到精通 - 深度解析图神经网络消息传递机制 【免费下载链接】graph_nets Build Graph Nets in Tensorflow 项目地址: https://gitcode.com/gh_mirrors/gr/graph_nets Graph Nets是DeepMind开发的图神经网络库&#xff0c;专为在Tens…...

红蓝对抗深度解析:从技术体系到落地实践,企业安全真正的实战课

红蓝对抗深度解析&#xff1a;从技术体系到落地实践&#xff0c;企业安全真正的实战课 在数字化攻防进入 “实战对抗” 时代的今天&#xff0c;红蓝对抗已成为企业检验安全防御体系、提升应急响应能力的核心手段。不同于传统的漏洞扫描和合规检查&#xff0c;红蓝对抗以 “高仿…...

图像质量评估三剑客:MSE、PSNR与SSIM的实战对比与优化策略

1. 图像质量评估的基本概念与挑战 在数字图像处理领域&#xff0c;评估图像质量是一个看似简单实则复杂的问题。想象一下&#xff0c;当你用手机拍摄照片后&#xff0c;如何判断这张照片的质量好坏&#xff1f;或者当你在Photoshop中调整图像参数时&#xff0c;如何量化调整前后…...

通信萌新们注意了!今天咱们玩点刺激的——用MATLAB手搓各种QAM调制的性能对比。准备好你的小本本,咱们边写代码边分析,包教包会

基于4QAM&#xff0c;16QAM&#xff0c;64QAM调制方式下经过AWGN信道的性能分析 均包含加噪声前后的星座图、误码率和误符号率性能对比&#xff0c;该程序一共10张仿真图&#xff0c;可学习性非常强先上硬货&#xff0c;看看怎么生成4QAM的星座图。掏出这段代码&#xff1a; M …...

告别公式迁移难题:3步实现LaTeX到Word的无缝转换体验

告别公式迁移难题&#xff1a;3步实现LaTeX到Word的无缝转换体验 【免费下载链接】LaTeX2Word-Equation Copy LaTeX Equations as Word Equations, a Chrome Extension 项目地址: https://gitcode.com/gh_mirrors/la/LaTeX2Word-Equation 问题溯源&#xff1a;学术公式迁…...

BilibiliDown:如何轻松搞定B站视频下载与批量管理的完整指南

BilibiliDown&#xff1a;如何轻松搞定B站视频下载与批量管理的完整指南 【免费下载链接】BilibiliDown (GUI-多平台支持) B站 哔哩哔哩 视频下载器。支持稍后再看、收藏夹、UP主视频批量下载|Bilibili Video Downloader &#x1f633; 项目地址: https://gitcode.com/gh_mir…...

从HAL_Delay到精准定时:STM32 HAL库中微秒与毫秒延时方案的深度解析与实战

1. HAL库延时函数的基本原理与局限性 在STM32开发中&#xff0c;HAL_Delay()可能是我们最早接触的延时函数。这个看似简单的函数背后&#xff0c;其实隐藏着精妙的系统设计。HAL库默认使用SysTick定时器来实现毫秒级延时&#xff0c;每次调用HAL_Delay()时&#xff0c;实际上是…...

VS2015+C++实战:手把手教你用海康MVS里的Demo搞定多相机同步采图与保存

VS2015C实战&#xff1a;海康MVS工业相机多机同步采图全流程解析 工业视觉检测系统中&#xff0c;多相机同步采图是个经典需求。上周帮朋友调试8台海康威视相机组成的检测线时&#xff0c;发现网上完整案例实在太少。今天我就以VS2015开发环境为例&#xff0c;带大家深入MVS安装…...

串口通讯参数设置全解析:从波特率到流控制的完整配置流程

串口通讯参数设置全解析&#xff1a;从波特率到流控制的完整配置流程 在嵌入式系统和硬件调试领域&#xff0c;串口通讯就像设备间的"普通话"&#xff0c;而参数配置则是确保双方能顺畅交流的语法规则。想象一下&#xff0c;当你需要让树莓派与传感器"对话&quo…...

Oracle错误代码实战指南:从ORA-00001到ORA-02899的快速排查手册

Oracle数据库错误代码实战排查指南&#xff1a;从原理到解决方案 1. 理解Oracle错误代码体系 Oracle数据库的错误代码体系采用"ORA-XXXXX"的格式&#xff0c;其中前五位数字代表特定错误类型。这些错误代码并非随机排列&#xff0c;而是按照功能模块进行了系统分类…...