Splunk Search

need to replace the value of a field only when other values are present from other fields

mjones414
Contributor

I'm trying to add more specific data to a particular field by replacing it with another value when other conditions exist:

I've tried if(match(, case(match( and if(searchmatch( and I've not yet found the right function that accepts these conditions.

... | inputlookup inventory.csv | fields WORKGROUP,ASSETNAME,SERIALNUMBER,ASSETTYPE,CONTACT,CONTACTNAME,HARDWARE,OS,SERIALNUMBER | fields - _raw | search WORKGROUP=MYTEAM | eval ASSETTYPE=if(searchmatch("HARDWARE=*MODEL1* OR HARDWARE=*MODEL2*") AND case(OS,"Windows*") AND case(WORKGROUP="MYTEAM"),"Windows Technical Workstation",ASSETTYPE)

Functionally what I want to accomplish is to replace the value of "Desktop" with "Windows Technical Workstation" in all entries where the HARDWARE matches MODEL1 OR MODEL 2, AND its running a Windows OS managed my MYTEAM.

0 Karma

datasearchninja
Communicator

Try this:

| inputlookup inventory.csv 
| eval ASSETTYPE=if((ASSETTYPE=="Desktop" AND WORKGROUP=="MYTEAM" AND searchmatch("OS=Windows* AND (HARDWARE=MODEL1 OR HARDWARE=MODEL2)")), "Windows Technical Workstation",ASSETTYPE)
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...