Statistics the value of Event.tags in the following field (red content)
{"url": "Http:\/\/icache.sinaimg.cn\/006gpxd2gw1exo8u4i7mkj30f00qotgg.lar", "Size": "10.79", "id": "295785", "action ":" "PUSH", "TOIDC": "BJ", "type": "ACCESS", "Level": "INFO", "FROMIDC": "GZ", "Service": "Replicate", "event.tags": [ "A"], "@timestamp": "2015-11-04t00:18:52,544+0800"}
Simple script:
#!/usr/bin/env pythonimport commandspath = str (raw_input (' Log Path: ')) f1 = open (Path, ' r ') F2 = open (' Tag.txt ', ' rw+ ') for L ine in F1.readlines (): L = eval (line) Try:tag = str (l[' event.tags ')). Split (' \ ') [1]+ ' \ n ' f2.writeline s (tag) except:passprint commands.getoutput (' Cat tag.txt | sort | uniq-c ') f1.close () F2.close ()
return Result:
[[email protected] test]# python event.py path:test-normalize-1103.log 386432 A 32202 B 32204 D1 3 D2
Rsyslog mmnormalize event.tags Field Statistics