logstash启动时默认连接本机节点elasticsearch问题

背景

今天在排查处理一个logstash读取kafka数据写入到hdfs的问题时候,发现在启动日志中多了个 logstash.outputs.elasticsearch 连接的地址是localhost:9200

部分日志如下:

logstash-elasticsearch-localhost-error

排查过程说明

1、首先确认 logstash 启动的配置文件中的 output 配置,确认只配置了 webhdfs


output {
	webhdfs {
		host => 'xxxx',
		port => 50075,
		standby_host => 'yyy',
		standby_port => 50075,
		path => 'xxxx',
	}
}

2、网上查询给出两种解决方案

第一种说在output配置中添加 stdout

output {
  stdout {
    codec => dots
  }
}

但是实际这边是封装的管理logstash的脚本,里面 标准输出是写入到 /dev/null 中去。

实际使用命令行参数也启动做了尝试,不起作用。

第二是说是加载了默认的 elasticsearch 插件,卸载该插件即可。

这里其实就有个疑问?为什么默认会只加载 elasticsearch输出源的插件,而不是其他呢?

但是实际卸载的时候,会提示依赖于 x-pack 插件

[root@xxxxxx logstash]# bash bin/logstash-plugin remove logstash-output-elasticsearch
Failed to remove "logstash-output-elasticsearch" because the following plugins or libraries depend on it:

* x-pack

3、根据上面提示,联系到观察启动日志的时候,它有两个地方提示到了 x-pack

3.1) /_xpack/monitoring/_bulk

[2023-06-08T16:54:05,541][WARN ][logstash.outputs.elasticsearch] You are using a deprecated config setting 
... ...
:plugin=><LogStash::Outputs::ElasticSearch hosts=>[http://localhost:9200], bulk_path=>"/_xpack/monitoring/_bulk?system_id=logstash&system_api_version=2&interval=1s", .... ...}

3.2)、logstash.modules.scaffold 模块加载时

[2023-06-08T16:54:00,332][INFO ][logstash.modules.scaffold] Initializing module {:module_name=>"arcsight", :directory=>"/opt/app/logstash/vendor/bundle/jruby/2.3.0/gems/x-pack-6.2.2-java/modules/arcsight/configuration"}

通过上面的例子,知道应该是加载 x-pack, 但是x-pack有依赖于 elasticsearch ,所以在未配置 elasticsearch输出源的情况,就默认去找 localhost:9200 了

解决办法

就是在 logstash的配置中禁用 xpack monitor

# logstash.yml
xpack.monitoring.enabled: false

该配置文件如果在 logstsah/config 目录下没有,可以手动新增一个,和启动logstash -f指定的配置文件不冲突

附赠上面提到的 logstash 服务管理脚本


如果觉得文章对你有用,请不吝点赞 和 关注个人公众号(搜索 全栈运维 或者 DailyJobOps

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值