Splunk Search

How to add an additional backslash to source?

edwinmae
Path Finder

I have an input that offers me x sources
index="xxxxx" sourcetype=xxxxx | dedup source | table source

The problem is when I open the panel in a search it shows me the source with a single \ and it needs two \ to give me the actual output

It seems I am close when using | rex mode=sed field=source "s/\\{1}/\\\//g" | dedup source | table source

The output is now:
source=D:\/xxxx\/xxxxx\/xxxx\/xxxxx\/xxxx\/xxxx.log

I tried to search and tried different options, but didn't found the correct rex 'line' that also changes the / into \ , in order to get the output:
source=D:\xxxx\xxxxx\xxxx\xxxxx\xxxx\xxxx.log

0 Karma

sdchakraborty
Contributor

Hi,

Can you try the below code,

|  eval source = replace(source,"\\\\","\\\\\\\\")

Sid

edwinmae
Path Finder

Excellent !

0 Karma

sdchakraborty
Contributor

Welcome. Please accept is as answer when you get time. Have a nice day.

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 ...