Grouping http requests by path/pattern

367 views
Skip to first unread message

tim.he...@trademark.vision

unread,
May 25, 2016, 7:19:16 PM5/25/16
to javamelody
Hi,

In collecting statistics on http requests, javamelody will collect statistics for each unique url, regardless of request parameters: eg. /search?q=foo and /search?q=bar are both reported against /search

In my app we have some urls where parameters are part of the url: eg. /view/{id} -> /view/1, /view/2, /view/etc.  This is very noisy in the statistics, not to mention expensive to keep, as there's potentially millions of unique urls.

Is there any way to provide a pattern to group all like requests for the purposes of statistics? Eg. "/view/.*" for the above example.

evernat

unread,
May 26, 2016, 6:12:07 AM5/26/16
to javamelody, tim.he...@trademark.vision
Hi Tim,

Yes, it is possible.

To aggregate the id in the URLs, you can add the parameter "http-transform-pattern" for this.
For example, in your web.xml file:

      <filter>

            <filter-name>monitoring</filter-name>

            <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>

            <init-param>

                  <param-name>http-transform-pattern</param-name>

                  <param-value>\d+</param-value>

            </init-param>

      </filter>
      ...

The statistics will be displayed in your case as "
/view/$".
The parameter is a regular expression, so you can add several patterns and separate them with '|'.

Or if your prefer, you could use a positive lookbehind in the regex, for example:

(?<=view)\/\d+
 
For more information on parameters and how to set them:

https://github.com/javamelody/javamelody/wiki/UserGuide#6-optional-parameters

bye,
Emeric

Reply all
Reply to author
Forward
0 new messages