我正在写一个pig脚本来处理sophos代理的访问日志。
每一行都像:
2015:01:13-00:00:01 ar-badc-fast-01 httpproxy[27983]:id=“0001”severity=“info”sys=“secureweb”sub=“http”name=“http access”action=“pass”method=“get”srcip=“10.20.7.210”dstip=“10.24.2.7”user=“”ad\u domain=“”statuscode=“302”cached=“0”profile=“ref\u defaulthttpprofile(默认web筛选器配置文件)”filteraction=“ref\u defaulthttpcfribution(默认web筛选器配置文件)”内容筛选器操作)“size=”0“request=”0x9ac68d0“url=”http://www.google.com“exceptions=”av,auth,content,url,ssl,certcheck,certdate,mime,cache,fileextension“error=”authtime=“0”dnstime=“1”cattime=“0”avscantime=“0”fullreqtime=“239428”device=“0”auth=“0”
所以我用mapreduce在java中实现了它,使用了以下正则表达式: \"([^\"]*)\"
获取引号之间的值,然后对其进行处理。现在我想对pig做同样的处理,但是我不能将regex应用到每一行。
我在做:
input = load './http.log' as (line : chararray);
splt = foreach input generate FLATTEN(REGEX_EXTRACT_ALL(line,'(\\"([^\\"]*)\\")'));
dump splt;
转储的结果是:()。
在使用regex\u extract\u all时,我遗漏了一些东西,或者我必须以不同的方式转义regex的某些字符?
谢谢!
1条答案
按热度按时间n3schb8v1#
我设法用另一种方法提取值,因为我只需要行中的一些字段。
为了得到我正在做的价值观:
然后我可以继续剩下的剧本