I am parsing some sysstat (Linux sar commands) files. They sysstat files start with a header of the Linux kernel, hostname, date, and architecture. I was able to parse out what I wanted with this grok filter:
patterns_dir => ["./logstash_patterns"]
match => {
"message" => "%{STAT_KERNEL:stat_kernel}\(%{HOSTNAME:stat_hostname}\) \t%{DATE_US:stat_date}%{GREEDYDATA:remaining_stat_message} "
}
After that I I can collect the time of entry and the stats reported with this grok filter:
match => {
"message" => "%{TIME:stat_time}\s+%{NUMBER:stat_b_tps}\s+%{NUMBER:stat_b_rtps}\s+%{NUMBER:stat_b_wtps}\s+%{NUMBER:stat_b_bread}\s+%{NUMBER:stat_b_bwrtn}%{GREEDYDATA:remaining_stat3_message}"
}
What I can't figure out how to do is build a timestamp for each entry since the date and time are on separate lines and the date is only listed once. Can I store the data in some sort of variable to reference later?
Here is a snippet of the file I am parsing:
####### sa05-b.out ########
Linux 2.6.32.54-0.79.TDC.1.R.0-default (WAITROSE-1-9) 09/04/16 _x86_64_
16:00:02 tps rtps wtps bread/s bwrtn/s
16:05:01 48.31 9.20 39.11 258.27 1229.09
16:10:01 48.21 9.35 38.86 97.71 1012.97
08:40:01 40.93 9.66 31.27 278.61 988.54
08:45:01 45.21 9.54 35.67 185.97 1530.56
08:50:01 41.37 9.36 32.01 124.09 983.74
08:55:01 47.40 9.27 38.13 123.23 1058.12
09:00:02 40.87 9.47 31.40 216.35 897.70
09:05:01 48.37 9.85 38.52 275.62 1205.39
09:10:01 47.12 9.33 37.79 114.50 967.01
09:15:01 47.33 9.88 37.45 334.40 1277.19
09:20:01 42.01 10.09 31.92 278.22 1158.59
Average: 57.66 18.81 38.85 2348.31 2472.59
Thanks!