Filebeat手册-官方文档译(input-log官方不推荐请使用stream)

本来想学习下input log方式的官方文档。

这真的是从开始学习到放弃那。因为官网第一句就说了:不建议使用。

为什么呢:首先官方说不在更新log方式的弊端,目前我们遇到的就是日志文件,切割后,filebeat不收集日志。

 

步骤1:安装filebeat

 deb

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.8.23-amd64.deb
sudo dpkg -i filebeat-6.8.23-amd64.deb

 rpm

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.8.23-x86_64.rpm
sudo rpm -vi filebeat-6.8.23-x86_64.rpm

mac

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

linux

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

win

Download Filebeat • Lightweight Log Analysis | Elastic

PS > cd 'C:\Program Files\Filebeat'
PS C:\Program Files\Filebeat> .\install-service-filebeat.ps1

如果您的系统禁用脚本执行,则需要设置当前会话的执行策略以允许脚本运行。例如

PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-filebeat.ps1.

docker:

See Running on Docker for deploying Docker containers.

部署Docker容器请参见在Docker上运行。

kubernetes:

See Running on Kubernetes for deploying with Kubernetes.

有关使用Kubernetes进行部署的信息,请参见在Kubernetes上运行。

步骤2: 配置

Filebeat modules provide the fastest getting started experience for common log formats. If you want use Filebeat modules, skip this section, including the remaining getting started steps, and go directly to Quick start: modules for common log formats.

Filebeat模块为常见的日志格式提供了最快的入门体验。如果要使用Filebeat模块,请跳过本节,包括其余的入门步骤,直接转到快速入门:用于常见日志格式的模块。

To configure Filebeat, you edit the configuration file. The default configuration file is called filebeat.yml. The location of the file varies by platform. To locate the file, see Directory layout.

There’s also a full example configuration file called filebeat.reference.yml that shows all non-deprecated options.

要配置Filebeat,需要编辑配置文件。默认配置文件名为filebeat.yml。文件的位置因平台而异。要定位文件,请参见目录布局。

还有一个名为filebeat.reference.yml的完整示例配置文件,其中显示了所有未弃用的选项。

 TODO:后续会特意找一篇文章来讲解filebeat.reference.yml。

See the Config File Format section of the Beats Platform Reference for more about the structure of the config file.

有关配置文件结构的更多信息,请参阅Beats平台参考的配置文件格式部分。

地址

Here is a sample of the filebeat section of the filebeat.yml file. Filebeat uses predefined default values for most configuration options.

下面是filebeat的filebeat部分的示例。yml文件。Filebeat对大多数配置选项使用预定义的默认值。

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/*.log
    #- c:\programdata\elasticsearch\logs\*

To configure Filebeat:

1. Define the path (or paths) to your log files.(定义日志文件的路径。)

For the most basic Filebeat configuration, you can define a single input with a single path. For example:(对于最基本的Filebeat配置,您可以用单个路径定义单个输入。例如:)

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/*.log

The input in this example harvests all files in the path /var/log/*.log, which means that Filebeat will harvest all files in the directory /var/log/ that end with .log. All patterns supported by Go Glob are also supported here.

To fetch all files from a predefined level of subdirectories, the following pattern can be used: /var/log/*/*.log. This fetches all .log files from the subfolders of /var/log. It does not fetch log files from the /var/log folder itself. Currently it is not possible to recursively fetch all files in all subdirectories of a directory.

本例中的输入收集路径/var/log/*.log中的所有文件,这意味着Filebeat将收集目录/var/log/中以.log结尾的所有文件。这里也支持Go Glob支持的所有模式。

要从预定义级别的子目录中获取所有文件,可以使用以下模式:/var/log/*/*.log。这将从/var/log的子文件夹中获取所有.log文件。它不从/var/log文件夹本身获取日志文件。目前不可能递归地获取一个目录的所有子目录中的所有文件。

 2. Configure the output. Filebeat supports a variety of outputs, but typically you’ll either send events directly to Elasticsearch, or to Logstash for additional processing.

配置输出:Filebeat支持各种输出,但通常情况下,您可以将事件直接发送到Elasticsearch,或者发送到Logstash进行额外处理。

To send output directly to Elasticsearch (without using Logstash), set the location of the Elasticsearch installation:

要将输出直接发送到Elasticsearch(不使用Logstash),请设置Elasticsearch安装的位置:

If you’re running our hosted Elasticsearch Service on Elastic Cloud, specify your Cloud ID. For example:

如果您在Elastic Cloud上运行我们托管的Elasticsearch服务,请指定您的Cloud ID。例如:

cloud.id: "staging:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRjZWM2ZjI2MWE3NGJmMjRjZTMzYmI4ODExYjg0Mjk0ZiRjNmMyY2E2ZDA0MjI0OWFmMGNjN2Q3YTllOTYyNTc0Mw=="

If you’re running Elasticsearch on your own hardware, set the host and port where Filebeat can find the Elasticsearch installation. For example: 

如果您在自己的硬件上运行Elasticsearch,请设置主机和端口,Filebeat可以在其中找到Elasticsearch安装。例如:

output.elasticsearch:
  hosts: ["myEShost:9200"]

To send output to Logstash, Configure the Logstash output instead. For all other outputs, see Configure the output.

要将输出发送到Logstash,请配置Logstash输出。对于所有其他输出,请参见配置输出。

3. If you plan to use the sample Kibana dashboards provided with Filebeat, configure the Kibana endpoint. You can skip this step if Kibana is running on the same host as Elasticsearch.

如果您计划使用Filebeat提供的样例Kibana仪表板,请配置Kibana端点。如果Kibana与Elasticsearch运行在同一台主机上,则可以跳过此步骤。

setup.kibana:
  host: "mykibanahost:5601" 

The hostname and port of the machine where Kibana is running, for example, mykibanahost:5601. If you specify a path after the port number, include the scheme and port: http://mykibanahost:5601/path.

运行Kibana的机器的主机名和端口,例如mykibanahost:5601。如果在端口号后指定路径,则需要包含方案和端口号:http://mykibanahost:5601/path。

4. If Elasticsearch and Kibana are secured, set credentials in the filebeat.yml config file before you run the commands that set up and start Filebeat.

If you’re running our hosted Elasticsearch Service on Elastic Cloud, specify your cloud auth credentials. For example:


如果Elasticsearch和Kibana是安全的,请在filebeat中设置凭据。在运行设置和启动Filebeat的命令之前,请先运行yml配置文件。

如果您在Elastic Cloud上运行我们托管的Elasticsearch服务,请指定您的云认证凭证。例如:

这里应该用不到:没有云产品

cloud.auth: "elastic:YOUR_PASSWORD"

​If you’re running Elasticsearch on your own hardware, specify your Elasticsearch and Kibana credentials:

如果您在自己的硬件上运行Elasticsearch,请指定您的Elasticsearch和Kibana凭据:

output.elasticsearch:
  hosts: ["myEShost:9200"]
  username: "filebeat_internal"
  password: "YOUR_PASSWORD" 
setup.kibana:
  host: "mykibanahost:5601"
  username: "my_kibana_user"  
  password: "YOUR_PASSWORD"

This examples shows a hard-coded password, but you should store sensitive values in the secrets keystore.


这个示例显示了一个硬编码的密码,但是您应该在秘密密钥存储库中存储敏感值。

The username and password settings for Kibana are optional. If you don’t specify credentials for Kibana, Filebeat uses the username and password specified for the Elasticsearch output.

Kibana的用户名和密码设置是可选的。如果不为Kibana指定凭据,Filebeat将使用为Elasticsearch输出指定的用户名和密码。

To use the pre-built Kibana dashboards, this user must have the kibana_user built-in role or equivalent privileges.


要使用预构建的Kibana仪表板,该用户必须具有kibana_user内置角色或等效特权。

For more information, see Securing Filebeat.

 有关详细信息,请参见保护Filebeat。

To test your configuration file, change to the directory where the Filebeat binary is installed, and run Filebeat in the foreground with the following options specified: ./filebeat test config -e. Make sure your config files are in the path expected by Filebeat (see Directory layout), or use the -c flag to specify the path to the config file.

Before starting Filebeat, you should look at the configuration options in the configuration file. For more information about these options, see Configuring Filebeat.

Starting with Filebeat 6.5, you can define and manage Filebeat configurations in a central location in Kibana. For more information, see Beats central management.

要测试您的配置文件,请更改到Filebeat二进制文件安装的目录,并在前台运行Filebeat,指定以下选项:确保您的配置文件位于Filebeat所期望的路径(请参阅目录布局),或者使用-c标志指定配置文件的路径。

在启动Filebeat之前,您应该查看配置文件中的配置选项。有关这些选项的详细信息,请参见配置Filebeat。

从Filebeat 6.5开始,您可以在Kibana的中心位置定义和管理Filebeat配置。有关更多信息,请参阅Beats中央管理。

Configuring Fillebeat

在修改配置设置之前,请确保已完成从入门中的配置步骤。本节介绍更改配置选项的一些常见用例。

要配置Filebeat,需要编辑配置文件。对于rpm和deb,您可以在/etc/filebeat/filebeat.yml找到配置文件。在/etc/filebeat/filebeat.reference中还有一个完整的配置文件示例。Yml,显示所有未弃用的选项。对于mac和win,请查看您提取的存档。

Filebeat配置文件使用YAML作为语法。有关配置文件结构的更多信息,请参阅Beats平台参考的配置文件格式部分。

从Filebeat 6.5开始,您可以在Kibana的中心位置定义和管理Filebeat配置。有关更多信息,请参阅Beats中央管理。

下面介绍如何配置Filebeat:

指定要运行哪些模块

配置输入

管理多行消息

指定常规设置

加载外部配置文件

配置内部队列

配置输出

建立索引生命周期管理

负载均衡输出主机

指定SSL设置

过滤和增强导出的数据

使用摄取节点解析数据

用geoIP信息丰富事件

设置项目路径

设置Kibana端点

加载Kibana仪表板

加载Elasticsearch索引模板

配置日志记录

在配置中使用环境变量

Autodiscover

YAML提示和陷阱

正则表达式支持

HTTP端点

filebeat.reference.yml

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值