adx-desc-adtype统计

本文分享了一个用于处理特定格式日志文件的数据分析脚本,该脚本使用Ruby语言编写,能够读取并解析日志文件,提取ADX、描述及请求类型等关键字段,并输出这些信息供进一步分析。

数据分析脚本:

 

 
filepath="request.log.2017-12-01-15"
  File.open("#{filepath}").each do |line|


begin  
  File.open("#{filepath}").each do |line|
    
   if ! line.valid_encoding?
     s = line.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
     line = s.gsub(/dr/i,'med')
   end 


   fields = line.split("\t") 
    if fields.length <10
        next 
    end
   adx = fields[3]
   desc = fields[10]
   ext10 = fields[45]
   reqtype= ext10['reqtype']

   puts "#{adx}\t#{desc}\t#{reqtype}"
 
  end
rescue SystemCallError
  puts "warn:: #{filepath} not  exits!!"
end

 

转载于:https://www.cnblogs.com/lavin/p/7976046.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值