question

Karthik L. avatar image
Karthik L. asked ·

Building Regex to Filter out a Request attribute being captured from a Method Arguement

We need to find all texts which satisfying one of the pattern in a text/sting


1 having two words in order RecordType:5 and ServiceType:SOAP

2 having two words in order RecordType:5 and ServiceType:REST

3 contains Service Fail


Test 1

RecordType:5;Timestamp:2019-05-13 10:52:56;LogPriority:ERROR;Component:pyWorkPage;ServiceType:SOAP;ServiceName:SOAPServiceName;TotalResponseTime:194.0;Function: SOAPServiceName;ErrorCode:ABCD;


Text 2

RecordType:5;Timestamp:2019-05-13 10:52:56;LogPriority:ERROR;Component:pyWorkPage;ServiceType:REST;ServiceName:RestService;TotalResponseTime:194.0;Function: RestService;ErrorCode:ABCD;


Text 3

RecordType:5;Timestamp:2019-05-13 10:52:56;LogPriority:ERROR;Component:pyWorkPage;ServiceType:SOAP;ServiceName:ServiceName;TotalResponseTime:194.0;Function:ServceName;ErrorCode:Service Fail;ABCD;


Following RegEx working in APPMON , but in DT1 is not accepting this as it has some constraints. Please help me create one regex to cover the three scenarios explained above.


.*RecordType:5.*ServiceType:SOAP.*|.*Service Fail.*|.*RecordType:5.*REST.*

Dynatrace Managedjavamigrationrequest attributes
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

1 Answer

Reinhard P. avatar image
Reinhard P. answered ·

Hello Karthik,


There's no straightforward way to replicate this in Dynatrace, but I have a solution for you that comes pretty close. Take a look at this regex:

RecordType:[^@]*Service Fail[^@]*|RecordType:5[^@]*ServiceType:SOAP[^@]*|RecordType:5[^@]*ServiceType:REST[^@]

In order for it to work as expected, two prerequisites must be met:

  • The value MUST start with the "RecordType". Reason for that is, that Dynatrace doesn't allow for leading universal quantifiers. The functionality for post processing Request Attribute Values is primarily meant for extracting substrings - with your use case being the exception. Based on the samples you've provided it at least looks like this prerequisite is being met.
  • "Greedy all matches" are also not allowed - therefore any occurrence of .* will be rejected. My solution uses [^@]* - assuming that the character @ won't occur in any of the strings. You may want to opt for an entirely different, more exotic character here, of course.

We are aware of the fact, that not every regular expression customers were using in AppMon can get translated easily to Dynatrace. Reason for these restrictions is simply the danger of regexes regarding overhead.


Let me know if that helps,

Reinhard

1 comment Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

it worked, thx a lot Reinhard

0 Likes 0 · ·