惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
S
Securelist
P
Proofpoint News Feed
D
DataBreaches.Net
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Project Zero
Project Zero
A
About on SuperTechFans
罗磊的独立博客
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
AI
AI
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security
T
Tor Project blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MyScale Blog
MyScale Blog
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
B
Blog RSS Feed
博客园 - 叶小钗
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Simon Willison's Weblog
Simon Willison's Weblog
C
CERT Recently Published Vulnerability Notes
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic

Logstash

请教下这种情况下如何 logstash 处理时间问题? - V2EX 各位大大,日志监控告警系统,大家有什么好的方案推荐么? - V2EX logstash 如何将时间戳 UNIX_MS 转化为北京时间? - V2EX 使用 ELK(Elasticsearch + Logstash + Kibana) 搭建日志集中分析平台实践 - V2EX logstash+elasticsearch+kibana 问题 - V2EX
使用 logstash 消费 avro 数据出现部分字节被替换为 ef bf bd 导致解析出错。 - V2EX
InDom · 2024-05-06 · via Logstash

这是一个创建于 769 天前的主题,其中的信息可能已经有所发展或是发生改变。

消费渠道 kafka 与 redis 均出现相同问题,直接以 plain => { charset => "BINARY" } 依然出现此问题。

avro 数据原文( 16 进制)

00000000: 00 80 40 00 cc e1 85 98 0e 00 3a 32 30 32 34 2d  ..@.......:2024-
00000010: 30 34 2d 31 38 54 30 36 3a 33 32 3a 30 34 2e 30  04-18T06:32:04.0
00000020: 30 30 2b 30 38 3a 30 30                          00+08:00

logstash 获取到的内容

00000000: 00 ef bf bd 40 00 ef bf bd ef bf bd ef bf bd ef  ....@...........
00000010: bf bd 0e 00 3a 32 30 32 34 2d 30 34 2d 31 38 54  ....:2024-04-18T
00000020: 30 36 3a 33 32 3a 30 34 2e 30 30 30 2b 30 38 3a  06:32:04.000+08:
00000030: 30 30 0a                                         00.

logstash 是通过 docker 起的 8.13.0 ,以下是容器相关配置

docker-compose.yml

  logstash:
    image: logstash:8.13.0
    volumes:
      - /root/kafka-2-es/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
    environment:
      - "XPACK_MONITORING_ENABLED=false"
      - "KAFKA_GROUP_ID"

logstash.conf

input {
  kafka {
    bootstrap_servers => "kafka:9092"
    topics => ["urllog-test-01"]
    codec => plain {
      charset => "BINARY"
    }
    group_id => "${KAFKA_GROUP_ID}"
    auto_offset_reset => "earliest"
  }
  redis {
    host => "192.168.4.101"
    port => 6379
    password => "Fle7YuG22qIh7ZNPkceopo3oZb1UFZrX"
    data_type => "list"
    key => "urllog-test-01"
    codec => plain {
      charset => "BINARY"
    }
  }
}

output {
  stdout {
    codec => rubydebug
  }
  elasticsearch {
    hosts => ["https://192.168.1.4:9200"]
    index => "urllog-test-01"
    user => "elastic"
    password => "123456"
    ssl => true
    ssl_certificate_verification => false
    manage_template => true
  }
}

已经确认的是:

  1. 使用 go 从 kafka 中消费获取到的二进制内容是正确的。
  2. 使用 logstash 从 kafka 与 redis 消费相同的内容,均出现特殊字符被替换为 ef bf bd 的情况
  3. 使用 kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic urllog-test-01 --from-beginning >> /tmp/data-1.txt 直接从 kafka 中得到的内容是正确的

有没有大佬知道是这么回事,给指条路呗?万分感谢。

第 1 条附言  ·  2024 年 5 月 7 日

果真是不发帖就找不到答案,官方文档没找到任何有用的线索,搜索关键词也找不到答案,通过遍历所有的 github 上相关的 issue,被发现了一个早前忽视的东西。

https://github.com/revpoint/logstash-codec-avro_schema_registry?tab=readme-ov-file#basic-usage-with-kafka-input-and-output

在这里看到了一个选项: value_deserializer_class => "org.apache.kafka.common.serialization.ByteArrayDeserializer"

一周前就看到了这个库,但没有时间仔细阅读代码段,不然一周前就应该解决这个问题了。

最后贴一下结果,希望下一个“我”可以看到。

input {
  kafka {
    bootstrap_servers => "kafka:9092"
    topics => ["test-01"]
    codec => avro {
      schema_uri => "/app/test.avsc"
      tag_on_failure => true
      encoding => binary
    }
    value_deserializer_class => "org.apache.kafka.common.serialization.ByteArrayDeserializer"
    group_id => "${KAFKA_GROUP_ID}"
    auto_offset_reset => "earliest"
  }
}
output {
  stdout {
    codec => rubydebug
  }
}

我的一周啊,因为这个破事,甚至险些破坏了我的五一假期。

InDom

1

InDom      2024 年 5 月 7 日

另外,贴一个有意思的东西,相同的问题,解决前和解决后。

对,已经指向这个帖子了。