通过LogStash从AWS Kinesis到Elasticsearch流式传输日志时编码问题
我有一个称为“ Otelpoc”的AWS运动流数据流。
在logstash中,我正在使用运动式输入插件 - 请参见此处。
我的logStash配置如下:
input {
kinesis {
kinesis_stream_name => "otelpoc"
region => "ap-southeast-2"
codec => json { }
}
}
output {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "otelpoc-logstash-%{+YYYY.MM.dd}"
}
}
我可以使用AWS CLI将事件放在运动式上:如下: aws kinesis put-ecord -stream-name otelpoc -data file://payload.json -partition-key 1
pareload.json
看起来像这样:
{
"message": "this is a test",
"level": "error"
}
.. ..但是,当我这样做时,我会在Logstash中看到一个错误: 收到的事件具有与您配置不同的字符编码。 {:text => \ xae \\ xba+“,:enducent_charset =>“ utf-8”}
有趣的是,该消息仍将其输出到Elastic,我可以在Kibana中查看它,如下所示:
不确定我应该用编码的字符做什么...我在logstash中尝试了几件事,但是没有成功,例如将kinesis输入中的编解码器更改为以下内容
codec => plain {
charset => "UTF-8"
}
...但是没有运气...我试图在一些在线解码器中解码编码的文本,但不确定我想从...有人提供帮助的是什么?
编辑:使用Elk Stack的V6.7.1,这很旧,但我认为这不是问题...
I've got an AWS Kinesis data stream called "otelpoc".
In Logstash, I'm using the Kinesis input plugin - see here.
My Logstash config is as follows:
input {
kinesis {
kinesis_stream_name => "otelpoc"
region => "ap-southeast-2"
codec => json { }
}
}
output {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "otelpoc-logstash-%{+YYYY.MM.dd}"
}
}
I can put events to Kinesis using the AWS CLI as follows:aws kinesis put-record --stream-name otelpoc --data file://payload.json --partition-key 1
payload.json
looks like this:
{
"message": "this is a test",
"level": "error"
}
... but when I do this I see an error in Logstash as follows:Received an event that has a different character encoding than you configured. {:text=>"\\x99\\xEB,j\\a\\xAD\\x86+\\\"\\xB1\\xAB^\\xB2\\xD9^\\xBD\\xE9^\\xAE\\xBA+", :expected_charset=>"UTF-8"}
Interestingly the message still get's outputted to Elastic and I can view it in Kibana as shown below:
Not sure what I should be doing with the character encoding... I've tried several things in Logstash, but no success e.g. changing the codec in the kinesis input to something like the following
codec => plain {
charset => "UTF-8"
}
... but no luck... I tried to decode the encoded text in a few online decoders, but not really sure what I'm trying to decode from... anyone able to help?
EDIT: using v6.7.1 of ELK stack, which is quite old, but I don't think this is the issue...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当使用AWS CLI发布消息时,我从未解决此问题,但是对于我的特定用例,我试图使用
awskinesis
for Open Telemetry(Otel)Collector Agent- 在这里。如果我使用
otlp_json
编码,则可以使用I never resolved this when publishing messages to Kinesis using the AWS CLI, but for my specific use case I was trying to send logs to Kinesis using the
awskinesis
exporter for the Open Telemetry (OTEL) collector agent - see here.If I use
otlp_json
encoding, it worked e.g.