Splunk Search

How can I format field with relative fieldname ?

Chaser
Explorer

My task is format field "app" with relative fieldname

How can I use format command to format as example: (app=*app1* OR  app=*app2* OR *app3* OR ...)

please help me, thanks

Labels (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

What is a "relative fieldname"?  What do the asterisks (*) in your example represent?  What is the data like, or the output of your search like? (Or what do raw data look like and your search look like?)

0 Karma

Chaser
Explorer

the asterisk(*) mean: if search *sharepoint*, it will show all of result have "sharepoint"

0 Karma

yuanliu
SplunkTrust
SplunkTrust

Something like this?

| makeresults
| fields - _time
| eval app = mvappend("*app1*", "*app2*")
| format

 

0 Karma

Chaser
Explorer

Chaser_0-1671691461098.png

the result like picture on above, but I want all double quote (") transfer to asterisk (*), can you help me

0 Karma

yuanliu
SplunkTrust
SplunkTrust

The easiest, and in my opinion semantically the most explicit, method would be to enter asterisks into the lookup table.

If you cannot change the table (I don't see any obstacle to that but), you can just alter it after inputlookup.

| inputlookup app_whitelist.csv
| fields app
| eval app = "*" . app . "*" ``` assuming app is single valued ```
| format

 

0 Karma

Chaser
Explorer

Can I completely replace double quotes with asterisks ?

0 Karma

yuanliu
SplunkTrust
SplunkTrust

The output is just a string, and search is the field name.  Yes you can use string manipulation to change anything, like

| rex mode=sed field=search "s/\"//g" ``` this only works if app values do not include quotation marks ```

But why?  Not only is this unnecessary, it is wrong in terms of code hygiene.  Splunk already gives you the necessary and sufficient syntax so it doesn't matter what is in the fields being formatted the search term will be faithful to the requirement.  Stripping quotes only makes it less stable.

0 Karma

Chaser
Explorer

fieldname is app, I mean, data have an app named Microsoft.sharepoint, but I input "sharepoint" it's still worked and it's understood Microsoft.sharepoint

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security(ES) 7.3 is approaching the end of support. Get ready for ...

Hi friends!    At Splunk, your product success is our top priority. With Enterprise Security (ES), we're here ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...