I'm using regular expressions to match the URL of monitored REST services.
However, even the simplest regular expressions fail to match the URL.
The documentation provides no examples at all.
Can you help me with a regexp that matches the following REST URL:
/myapp/card/{cardnumber}/session
I want a transaction defined where the numeric cardnumber is irrelevant.
I have tried "/myapp/card/\d.*/session$" with no success.
Thanks,
Karl Ivar Dahl
Hi Karl Ivar Dahl,
Thanks for writing in. We understood that your request URI will be as follows for pattern /myapp/card/{cardnumber}/session, let us know if any disconnect:
Ex: /myapp/card/1/session, /myapp/card/44/session
If the above said is right and if the request are invoking is intercepted by servlet request, we confirm that the following your rule should work, as we it is working fine in our local for servlet request URI with regex option:
URI (use option "Matches regular ex") with expression as follows without quotes "/myapp/card/\d.*/session$"
- Can you please confirm whether the request type is Servlet, webserivces, etc,
- what is the type of business transaction auto discovered when you are not defining custom rule on regex, is it servlet type BT under business transaction grid, Can you provide the screenshot from application -> business transaction screen with auto discovered BT selected for which you want to define custom rule with regex
- Can you please provide the screenshot of you custom rule from controller in referrence to attached screenshot and also the zipped version of conf and logs directory under <agent_install_dir>/ from node under tier on which you are expecting custom rule to be discovered,
we requested the above information as we suspect REST URL request might not be resulting as servlet BTs and hence custom rule might not be working.
Please provide the request information and also confirm the type of BT discovered in business transaciton screen in contoller UI for REST URL requests , as we see URI matched option is available only for Servlet BT type in UI.
Thanks,
Arun
Thanks for your response.
I have since my post got it working.
The following expression will match:
/group/\d*/nodsession\/?$
I had trouble getting end-of-line $ to match, but it turns out that some clients appended a slash at the end of the URL.
But I do still need more information in your documentation regarding regular expression matching. Can I for example use matching to define request segments?
Hi Karl Ivar Dahl,
Thanks for posting back. We see that we do not have any doc with examples, but we confirm that any valid regular expression should work for option (use option "Matches regular ex") in any custom rule for the corresponding value.
regarding expression to match with / at the end of url, we confirm that if the url pattern is as follows:
/group/1/nodsession/ , /group/1/nodsession , /group/31/nodsession/, /group/2/nodsession
the reg ex without quotes "/group/\d.*/nodsession\/?$" will match above url, but we see that in the reg expression you have provided seems missing dot(.) in the reg expression, let us know whether it is expected that dot(.) does not existing in reg exp "/group/\d*/nodsession\/?$" or the expression target different pattern of urls?
- can you please eloborate the query "Can I for example use matching to define request segments?"
if you are referring to reg expression to match particular request segement in the url and defining equivalent reg ex
should work, let us know if any disconnect in our understanding
Do write back to us for further assistance.
Thanks,
Arun
I believe the dot was reduntant. I believe "\d*" matches any digit, "\d.*" matches one digit and then any character. Both work with my URL, but \d* is more precise.
By matching segments I mean that it could be possible to use round brackets () to define groups in the regexp, and use these groups as segments for later transaction splitting instead of a simple split on "/". They could also be used for advanced matching.
Regards
Karl Ivar
Hi Karl Ivar,
Thanks for posting back, we understood that \d in regex part, thanks for clarification. Regarding the other query,
currently we see that segments are categorized based on slash "/" part of request URI, we do not see an option to group by symbols ( or ) or () to group as segments. Let us know if that answers your query.
Thanks,
Arun