Splunk Search

How to solve Error parsing URL in Splunk?

Badab
New Member

Hello,

I'm trying to parse URLs in Java logs (*.trace), it works for complete URL with this following request :

index=os_win_wks sourcetype="os_win_wks:java:trace"
| rex field=_raw (?<URL>https?:\/\/\S+)

but I want to stop to the first "/" with this one, then I have an error message :

index=os_win_wks  sourcetype="os_win_wks:java:trace"
| rex (?<url>https?:\/\\[^:\/]+)

Error => Error in 'SearchParser': Missing a search command before '^'. Error at position '75' of search query 'search index=* sourcetype="os_win_wks:java:trace" ...{snipped} {errorcontext = tps?:\/\\[^:\/]+)}'.

Could you help me please ?

Labels (1)
0 Karma
1 Solution

javiergn
Super Champion

Hi @Badab , I think there is a typo as you did not escape a forward slash but a backslash.

It should be like:

 

| rex "(?<url>https?:\/\/[^:\/]+)"

 

 

I've tested it and it seems to do what you are asking:

javiergn_0-1682669301798.png

 

Regards,

J

 

View solution in original post

javiergn
Super Champion

Hi @Badab , I think there is a typo as you did not escape a forward slash but a backslash.

It should be like:

 

| rex "(?<url>https?:\/\/[^:\/]+)"

 

 

I've tested it and it seems to do what you are asking:

javiergn_0-1682669301798.png

 

Regards,

J

 

Badab_one
Engager

It works, thank you !

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...