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

This product reached the end of support date on March 31, 2021.

Help with a regex for user recognition

sandrine-extern
Advisor

Hello there!

I'm in need of your kind help regarding a simple regex that is turning me crazy!

I want to identify a user name placed in this tag "<nsX:referenceFournisseur>...</nsX:referenceFournisseur>"

My problem is that the X is a number between 0 and 9 so I can't just select the Taf because it will return only a few values.

I tried this regex : in the Tag S:Body : \(<ns[0-9]*:referenceFournisseur>.*</ns[0-9]*:referenceFournisseur>\)
but it returns the whole tag + value (e.g. : <ns2:referenceFournisseur>0082960389</ns2:referenceFournisseur> )

I tried to use the following one "\(>[0-9A-Z]\{10,13\}<\)" but it returns a lot of everything...

Do you have any hint so I can have only the value I am looking for?

I must say that I'm a real beginer with regex usage... it doesn't help...

Thanks a lot in advance for your help!

Best regards,

Sandrine

14 REPLIES 14

sandrine-extern
Advisor

OK, found it here :

https://answers.dynatrace.com/questions/123829/reg...

The correct regex is

<ns[0-9]*:referenceFournisseur>\(.*\)</ns[0-9]*:referenceFournisseur>

Now I found out that depending on the operation, it can be "ns[0-9]" or "res"...

So my final idea would be

<[nsres0-9]*:referenceFournisseur>\(.*\)</[nsres0-9]*:referenceFournisseur>

For a better understandign, here is what helped me:


Start with:


(http://)[w\.]{0,4}(example.com/en/Services/)

With
round brackets you point what should be reported, in square specify
unwanted characters and in curly, how many times they can occur.

Thank you @Adam Piotrowicz !

Sandrine

So you are not crazy?
😉

I'll finally stay out of the mental hospital for now 😄

sandrine-extern
Advisor

I think I over reacted, OK I have the value in the Console, but I still have the IP address only in the CAS if I use the "User name" Dimension...

Is it normal???

sandrine-extern
Advisor

Doesn't work @Janusz Dabrowski .

I'll stick with my complicated-but-working regex 🙂

sandrine-extern
Advisor

Not working either without the \ before the round brackets...

Using the regex I proposed, I have the correct results in the Console, so it should appear in the CAS, right?

Please mind I also asked you to add "\" before "/".

To be frank only now I recognized you are referring to XML (or SOAP?) over HTTP, not just HTTP decode. Example you referred to was specific to HTTP decode so I thought you want to use the same one.

If I'm not mistaken for XML/SOAP over HTTP decode you need to point specific tag where username is carried, and Regex can help you to extract a specific string from within the tag. Otherwise you can't extract any other parameter (like operation name) if you hog whole tag like you proposed. New XML decode in 12.4 will address this limitation.

More investigation would require access to Requests / Response pairs and better understanding of what is to be extracted.

Hi Janusz,

Yes, sorrys, I fogrot to say I am using SOAP over HTTPS decode!

I am pointing the "S:Body" tag, witch is the only one that doesn't change from an operation to another.

Otherwise, depending on the type of response, the tag begining changes.

It might be "ns[1-9]:referenceFournisseur" or "mis:referenceFournisseur" or "res:referenceFournisseur"...

So, if I select the correct tag for the first operation, it won't match the second one!

I
tried to copy/paste your regex in the Pattern field using the Wizard to
edit the Software Service, but then, nothing is recognized.

Using the regex that I wrotte returns the correct result in the Console but nothing in the CAS 😞

Thanks a lot for your help!

sandrine-extern
Advisor

Is ADS server mandatory in order to have the user name in my CAS reports?

I'm really on my way to the hospital finally :'(

No, it's not necessary.

OK thanks.

I don't understand why I can't see them in my CAS reports then...

Maybe should I use another Dimension ?

Is it showing up in zdata file?

wojciech_kurek
Inactive

Sandrine,

Since the actual tag name (referenceFournisseur) is constant and the only thing that changes is the XML namespace (nsX:), you can just specify *:referenceFournisseur as the tag name and skip the regex entirely, i.e. configure it the following way:

Tag: *:referenceFournisseur
Pattern: (leave empty)

The *:tagName is a special syntax that accepts all tags named tagName regardless of the XML namespace (i.e. the string before the colon).

Wojtek.

Sandrine, did sulution proposed by Wojtek helped ? If positive I'd remove my other suggestions. Best, J