2

I'm looking to retroactively parse the logs and count the number of /foo/* requests that have occurred to have a baseline benchmark for a new feature that we're pushing. A simple command line script would be fine -- with an added bonus for being able to specify a date-range.

Some use of grep, perhaps?

chaos
  • 122,029
  • 33
  • 303
  • 309
andrew
  • 1,173
  • 2
  • 18
  • 28

3 Answers3

2
egrep -c '\] "[A-Z]+ /foo/' access_log
chaos
  • 122,029
  • 33
  • 303
  • 309
1

Adding the "able to specify a date range" condition makes it a little harder. Easiest probably to write a Python or Ruby program. Otherwise, using date(1) with -f to set up the parsing format, -j to tell it to leave the damn clock alone, and -r to have it print seconds since epoch would get you there.

Charlie Martin
  • 110,348
  • 25
  • 193
  • 263
0
fgrep " /foo/" access_log | wc -l

to get a roughly formatted accesses per day:

fgrep " /foo/" access_log | cut -d'[' -f2 | cut -d: -f1 | uniq -c 
Michael Cramer
  • 5,080
  • 1
  • 20
  • 16