java.lang.NullPointerException: Expected timestamp in the Flume event headers, but it was null
使用 Flume HDFS Sink 並啟用目錄自動生成功能(如按小時分桶)時拋出。
HDFS Sink 預期 Event Header 包含 `timestamp` 欄位用於生成時間目錄,但來源未提供。
在 Sink 配置中加入 `hdfs.useLocalTimeStamp = true`,改用 Flume 節點本地系統時間生成目錄,避免依賴 Event Header。
a1.sinks.k1.hdfs.path = hdfs://ubuntu:9000/flume/events/%y-%m-%d/%H
a1.sinks.k1.hdfs.filePrefix = events-
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 1
a1.sinks.k1.hdfs.roundUnit = hour
a1.sinks.k1.hdfs.useLocalTimeStamp = true
調整 `hdfs.timeZone` 使其與上傳日誌時間格式一致(未驗證)。
一行配置即可解決時間戳缺失導致的 NPE,建議生產環境直接啟用 `useLocalTimeStamp`。
出處:bianceng.cn