我是 apache 水槽的新手。
我正在尝试查看如何获取 json(作为 http 源),对其进行解析并根据内容将其存储到 hdfs 上的动态路径中。
例如:
如果 json 是:
[{
"field1" : "value1",
"field2" : "value2"
}]
那么 hdfs 路径将是:
/some-default-root-path/value1/value2/some-value-name-file
是否有这样的水槽配置可以让我这样做?
这是我当前的配置(通过http接受json,并根据时间戳将其存储在路径中):
#flume.conf: http source, hdfs sink
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = org.apache.flume.source.http.HTTPSource
a1.sources.r1.port = 9000
#a1.sources.r1.handler = org.apache.flume.http.JSONHandler
# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = /user/uri/events/%y-%m-%d/%H%M/%S
a1.sinks.k1.hdfs.filePrefix = events-
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
谢谢!