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!

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

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...