cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to capture the specific numerical value in the value of the method's argument using regex?

rguerrero
Inactive

Hello everyone,

Please your support to solve the problem mentioned below.

We need to capture a particular value (numerical value only) of the method's argument value as mentioned in the attachment by using regular expression.

Measure: Argument Value

Argument: [AcuerdoDaoImp] - [INI] montos: MontoPagar [ideacuerdo=33868611, idpmoneda=SOL, mtopago=74]

Result: 74

To apply the sum and show it in a result of this value through a BT.

Thank you very much for your support.

1.jpg

4 REPLIES 4

gabriel_prioli
Dynatrace Pro
Dynatrace Pro

Hi Roberto,

Please try the following regex: mtopago=([0-9]+)

This depends on the name of the key being 'mtopago'. The value used for the measure will be what matched inside the parenthesis - in this case one or more numbers that are in the range from 0 to 9.

You can use https://regex101.com/ to test it out. Make sure to try more than one example to see if they all work. After that, use the regex on the measure.

rguerrero
Inactive

Hi Gabriel;

thank you very much for your support. I have developed this regex: (\d++(?=]*$))

It works for me in capturing value when I use https://regex101.com/ to test.

I have put the regex in two BT's and I'm having problems in the calculation the amount.

I tell you I'm capturing the message - INFO and that I want to a

dd.
This I want to reflect either in the BT or in a "text and measurement" but it is not showing.

Regards;

2.jpg

3.jpg

4.jpg

gabriel_prioli
Dynatrace Pro
Dynatrace Pro

Did you put a custom sensor on 'forcedLog'? By default I don't think this method shows up in the PurePath, as you showed. The fact is that you're only capturing the first argument (the fqcn) and that is not the log message.

If you can capture what you want from an argument value what you need is make sure you capture the arguments in the sensor and also the measure must specify the correct argument number.

The line that says 'log4j [INFO]' from what I understand is added by the Server and it's not possible to use argument value there - even though the value of the message is on the "Argument" column.

rguerrero
Inactive

Gabriel;

The sensors are already activated.

That's how it worked for me. I had to capture the third parameter (Object)

hank you very much.

Regards;

10.jpg