通过LogStash从AWS Kinesis到Elasticsearch流式传输日志时编码问题

发布于 2025-02-05 18:52:03 字数 1527 浏览 2 评论 0原文

我有一个称为“ 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:
enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

书间行客 2025-02-12 18:52:04

当使用AWS CLI发布消息时,我从未解决此问题,但是对于我的特定用例,我试图使用awskinesis for Open Telemetry(Otel)Collector Agent- 在这里

如果我使用otlp_json编码,则可以使用

  awskinesis:
    aws:
      stream_name: otelpoc
      region: ap-southeast-2
    encoding:
      name: 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.

  awskinesis:
    aws:
      stream_name: otelpoc
      region: ap-southeast-2
    encoding:
      name: otlp_json
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文