3

My shop is using MVC3/FUBU on IIS 7. I recently put something into production and I wanted to gather metrics from the IIS logs using log parser. I've done this many times before but because the MVC3 routes are of the form /api/person//address/ the log saves /api/person/123/address/456 in the uristem column.

Does anyone have any ideas on how to get data about specific routes from IIS logs?

As an exmaple: Log Like this:

cs-uri-stem
/api/person/123/address/456
/api/person/121/address/33
/api/person/1555/address/5555

Output like: Total Hits = 3

Craig Fisher
  • 1,681
  • 2
  • 19
  • 26
Grummle
  • 1,364
  • 1
  • 12
  • 21

2 Answers2

5

Ok the way that I end up dealing with this is to create a HttpModule that will pull the route pattern from the HttpContext and put into the server variables as URL_PATTERN. Once its in server_variables IIS Advanced Logging can get ahold of it and save it. If the current request doesn't have a route it'll just use the normal local portion of the url (so it'll match cs-uri-stem in the logs).

Now sql/log parser the query: select url_pattern,count(url_pattern) from (yourlogs) where timestamp between (start/end) group by url_pattern order by count(url_pattern) desc will give me back the number of hits for each endpoint in my app.

This could obviously be done in a fubu behaviour, but we've got a bunch of classic asp and MVC3 running around (i know I know...) and this will handle all of them. Also you can apparently 'publish' a field from a module using RaiseTraceEvent that IIS Advanced Logging can then get ahold of, but it was giving me fits trying to figure it out so I just went with what I have.

I've posted this question all over the place referencing fubu and MVC3 and I have gotten little to no interest, which really suprised me. How do people poke about in their logs for info if you can't easily determine the routes being used.

https://gist.github.com/2854760

Grummle
  • 1,364
  • 1
  • 12
  • 21
0

You can use the Regular Expression search feature of Notepad++. This article might help.

user260314
  • 39
  • 1
  • 4
  • We generate about 1.5GB of IIS logs per day for the site in question. Ideally what I'd like to figure out is how to do is is have IIS log what the regex for the route that is choose for a particular url. So in the IIS logs have /api/person/{personid}/address/{addressid} in a column in addition to the cs-uristem – Grummle May 31 '12 at 14:50