Logstash——Logstash将数据推送至Elasticsearch

elasticsearch介绍

在使用云日志管理的时候,logstash的数据最终需要elasticsearch来进行存储和分析。所以logstash提供大量参数来支持和满足相关业务场景。

可配置参数

字段 参数类型 说明
action string 要执行的Elasticsearch动作
api_key password 使用Elasticsearch API密钥进行身份验证,需要启动SSL
bulk_path string 执行_bulk请求的HTTP路径
cacert a valid filesystem path 验证服务器的证书的.cer或.pem文件
cloud_auth password 云认证字符串,需要Elastic Cloud
cloud_id string Cloud ID,需要使用Elastic Cloud
custom_headers hash 自定义的标题头
doc_as_upsert boolean 启用doc_as_upsert更新模式。如果document_idElasticsearch中不存在带有源的新文档
document_id string 需要插入的文档ID
document_type string 在7.X以上版本不建议使用,8.X版本已经移除
failure_type_logging_whitelist array 错误白名单,将忽略列表中的异常
healthcheck_path string 后端标记为HEAD时发送HEAD请求的HTTP路径
hosts uri 设置远程实例的主机
http_compression boolean 对请求启用gzip压缩
ilm_enabled string, one of [“true”, “false”, “auto”] auto如果Elasticsearch为7.0.0以上版本,且启用了ILM功能则默认设置为会自动启用索引生命周期管理功能,否则将其禁用。
ilm_pattern string 模式中指定的值将附加到写别名,并在ILM创建新索
ilm_policy string 修改此设置以使用自定义的索引生命周期管理策略,而不是默认策略。
ilm_rollover_alias string 过渡别名
index string 事件最终要写入的目标索引
keystore a valid filesystem path 证书密钥库,可以是.jks或.p12
keystore_password password 密钥库密码
manage_template boolean 此模板的内容是默认模板
parameters hash 传递一组键值对作为URL查询字符串
parent string 对于子级文档,为关联父级的ID。可以使用%{foo}动态语法
password password Elasticsearch密码
path string Elasticsearch服务器所在的HTTP路径。在host参数配置的情况下,无需配置此参数
pipeline string 希望为事件执行的摄取管道
pool_max number 设置了输出将创建的最大打开连接数,设置得太低可能意味着经常关闭/打开连接
pool_max_per_route number 设置输出将创建的每个端点的最大打开连接数。将此值设置得太低可能意味着经常关闭/打开连接
proxy uri 设置转发HTTP代理的地址
resurrect_delay number 两次resurrection等待的频率(以秒为单位),resurrection用来检测标记为down的后端端点是否恢复
retry_initial_interval number 设置两次重试之间的初始间隔
retry_max_interval number 设置两次重试之间的最大间隔
retry_on_conflict number Elasticsearch内部重试更新/提交的文档的次数
routing string 路由已处理的事件
script string 设置脚本
script_lang string 设置脚本语言
script_type string, one of [“inline”, “indexed”, “file”] 定义“script”变量内联引用的脚本类型
script_var_name string 设置传递给脚本的变量名
scripted_upsert boolean 如果启用,则脚本负责创建不存在的文档
sniffing boolean 此设置要求Elasticsearch提供所有集群节点的列表,并将它们添加到主机列表。
sniffing_delay number 在两次嗅探尝试之间等待多长时间(以秒为单位)
sniffing_path string 用于嗅探请求的HTTP路径默认值
ssl boolean 启用与Elasticsearch集群的SSL / TLS安全通信
ssl_certificate_verification boolean 用于验证服务器证书的选项
template a valid filesystem path 可以在此处将路径设置为自己的模板
template_name string 定义如何在Elasticsearch中命名模板
template_overwrite boolean 选项总是会用Elasticsearch中指定的模板或包含的模板覆盖指定的模板
timeout number 发送到Elasticsearch的请求的超时限制
truststore a valid filesystem path 用于验证服务器证书的信任库
truststore_password password 设置信任库密码
upsert string 将upsert内容设置为更新模式
user string Elasticsearch集群的用户名
validate_after_inactivity number 在使用keepalive执行连接上的请求之前,在检查连接是否过时之前需要等待多长时间。
version string 用于索引的版本
version_type string, one of [“internal”, “external”, “external_gt”, “external_gte”, “force”] 用于索引的版本类型
hosts

hosts支持一个或者多个url路径。当配置多个路径的时候会在指定的主机之间负载均衡请求。

此参数支持的格式:

  • "127.0.0.1"
  • ["127.0.0.1:9200","127.0.0.2:9200"]
  • ["http://127.0.0.1"]
  • ["https://127.0.0.1:9200"]

需要注意,为了避免向主节点推送批量操作的请求,url只需要配置data node 和 client node。关于数据节点可以查看这篇文章
Elasticsearch集群

数据插入的逻辑

当数据被插入elasticsearch的时候,根据logstash不同的参数配置有有不同的结果,logstash对其配置主要使用下面几个参数:

  1. action
  2. doc_as_upsert
  3. upsert
action</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大·风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值