Dashboards & Visualizations

How can I use part of a token in a search?

danielbb
Motivator

I have a piece of code as - 

| rex field=$AppNC$ ".*\/(?<ChosenAppCode>.*"
| search job_name=* U_APP_CODE=ChosenAppCode

 From the drop down the AppNC (App Name Code) is chosen and the search should have the app code part.

How can the following be dynamic ?

U_APP_CODE=ChosenAppCode

Meaning, ChosenAppCode, would be the code extracted in the line above? 

Labels (1)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

rex will work on fields not tokens, so eval a field to the token and rex that or create an extra token in the change handler of the dropdown to have the part of the token you want for your search (using a where command as @bowesmana suggested)

View solution in original post

danielbb
Motivator

Thank you both, it's working now.

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@danielbb - Please consider accepting the answer which helped you!!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

rex will work on fields not tokens, so eval a field to the token and rex that or create an extra token in the change handler of the dropdown to have the part of the token you want for your search (using a where command as @bowesmana suggested)

bowesmana
SplunkTrust
SplunkTrust

Instead of using search command, where you can't search for a field value, use where, e.g.

| where match(job_name, ".*") AND U_APP_CODE=ChosenAppCode

Note that if you use where, then you need to use match() command for wildcard matching and that uses regex. Depending on how you are searching for job_name, you could do both search and where.

 

Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...