如何使用 Flume sink正则 匹配数据存入到hbase列的配置方法

2024-12-14 10:08:22
推荐回答(1个)
回答1:

下面是一个Flume collector收集其他的Flume agent数据并桐州通过sink正则放数据到hbase的配置文件内容,你可以参考一下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

agent.sources = source1
agent.sinks = hbase1
agent.channels = channel1
#agent.sources.source1.type = exec
#agent.sources.source1.command = tail -F /home/hadoop/access.log
#agent.sources.source1.batchSize = 100
agent.sources.source1.type = avro
agent.sources.source1.bind = 10.15.200.47
agent.sources.source1.port = 44444
agent.sources.source1.channels = channel1
agent.sinks.sink1.channel = channel1
# Configure Hbase Sink sink1
#agent.sources.source1.interceptors.hbase1.regex=
agent.sinks.hbase1.type = org.apache.flume.sink.hbase.HBaseSink
agent.sinks.hbase1.channel = channel1
agent.sinks.hbase1.table = test
agent.sinks.hbase1.columnFamily = log
agent.sinks.hbase1.serializer = org.apache.flume.sink.hbase.RegexHbaseEventSerializer
// nginx日志都是分割成: ([xxx] [yyy] [zzz] [nnn] ...) 这种格式的, 所以用下面的正则
agent.sinks.hbase1.serializer.regex = \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\中喊\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]\\ \\[(.*?)\\]
// 指定上面正则匹配到的数据对应卖轮野的hbase列名
agent.sinks.hbase1.serializer.colNames = a,b,c,d,e,f,g,h,i,j,k,l,m,n
#agent.sinks.hbase1.serializer.payloadColumn = test
# Use a channel which buffers events in memory
agent.channels.channel1.type = memory
agent.channels.channel1.capacity = 800
agent.channels.channel1.transactionCapactiy = 100