Dashboards & Visualizations

Search run to nothing when I passed a variable contain backlash

ToniHuynh
Explorer

Hi everyone,

I am trying to search for a file path (e.g. C:\Finance\Salary) but the result return none. It works if I type directly C:\\Finance\\Salary but it does not work if I passed it to a variable. Although the variable shows correct value.

 

 

index=wineventlog EventCode=4660 OR EventCode=4663 Account_Name!="ANONYMOUS LOGON" host="PTL*" Account_Name!="*$" 
| eval FilePath=urldecode("C%3A%5CFinance%5CSalary") 
| eval FilePath=replace(ObjectName,"\\\\","\\\\\\") 
| search Object_Name=FilePath
| dedup _time host Account_Name Account_Domain Object_Name Accesses EventCodeDescription 
| table _time host Account_Name Account_Domain Object_Name FilePath Accesses EventCodeDescription 
| sort _time desc

 

 

The below search will show result if I replace: 

 

 

|eval Object_Name="C:\\Finance\\Salary"

 

 

 

 

Labels (1)
0 Karma
1 Solution

kmugglet
Communicator

Just noticed.
In your original query

 

| eval FilePath=urldecode("C%3A%5CFinance%5CSalary") 
| eval FilePath=replace(ObjectName,"\\\\","\\\\\\") 
| search Object_Name=FilePath


You're setting FilePath in 1st line
Then setting it again in the next line?

Should second line be ?

| eval Object_Name = replace(ObjectName  etc etc

View solution in original post

0 Karma

kmugglet
Communicator


try where instead of search, it's easier to determine if Splunk is looking for an Object_Name with the value FilePath, or if it's looking an Object_Name field with the same value as the FilePath field you created.


i.e.

where Object_Name==FilePath

Otherwise you could use regex 

where match(Object_Name,"^C\:\\Finance\\Salary")

Tags (1)
0 Karma

ToniHuynh
Explorer

Thanks for your response but both of your suggestions do not work. Actually, I would like to decode the FilePath with sent from the main dashboard to the drilldown dashboard. The urldecode shows correct path and I put       | eval FileName=replace(ObjectName,"\\\\","\\\\\\")   to change it to "C:\\Finance\\Salary" but don't know why there is no matched to that. However, if I put direct |search Object_Name="C:\\Finance\\Salary" then it shows matched results.

0 Karma

kmugglet
Communicator

Just noticed.
In your original query

 

| eval FilePath=urldecode("C%3A%5CFinance%5CSalary") 
| eval FilePath=replace(ObjectName,"\\\\","\\\\\\") 
| search Object_Name=FilePath


You're setting FilePath in 1st line
Then setting it again in the next line?

Should second line be ?

| eval Object_Name = replace(ObjectName  etc etc

0 Karma

to4kawa
Ultra Champion

search can't compare field values. you should use where at the case.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...