解决rsyslog发消息给elasticsearch失败的问题(R06)

405 阅读1分钟

解决办法

在CentOS7.4上预装的v8.24有这个问题,这是一个bug,升级到v8.29以上就好了,我升级到最新版Rsyslogv8.2002,配置文件不变,发送成功。

报错主要信息

{"error":"Content-Type header [text/json] is not supported","status":406}

原因定位

>>> I tried the following command and got the same error:
>>> curl -H "Content-Type: text/json" -XPOST 'manager.server:9200/books/es/1' -d '{"title":"Elasticsearch Server", "publicshed":2013}'
>>> ERROR IS:
>>> {"error":"Content-Type header [text/json] is not supported","status":406}
>>> I changed the comand to this:
>>> curl -H "Content-Type: application/json" -XPOST 'manager.server:9200/books/es/1' -d '{"title":"Elasticsearch Server", "publicshed":2013}'
>>> This is right!

从github源码上可以看到相关的代码修改,从text/json改为了application/json,这个源码里写死的,只能用新版本。

此外,测试过程发现使用linux logger无法发送消息的问题,现象是在/var/log/messages中收不到logger发的消息,这个问题经过艰苦的定位也解决了。

欢迎在下方讨论交流问题!