Splunk Search

How to Nullified a field

azleeshah
Explorer

Im trying to nullified  data in "status" field  for any value match as "InActive" based on accounttype . Appreciate help on appropriate SPL  Thanks

accounttype                status           count
Human_Account       Active            1333
Human_Account       InActive          106
Generic_Account     Active                50
Service_Account      InActive          540

Labels (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@azleeshah 

You can eval the field and define logic as per your requirement. Please check below search.

YOUR_SEARCH
| eval status=if(accounttype=="Human_Account" and status="InActive",null(),status)

 

Here, I have nullified status column if account type is Human_Account and status is InActive.

You can change if condition as per your requirement.

My Sample Search :

 

| makeresults | eval _raw="accounttype,status,count
Human_Account,Active,1333
Human_Account,InActive,106
Generic_Account,Active,50
Service_Account,InActive,540" | multikv forceheader=1
|table accounttype                status           count
| rename comment as "Upto now is for sample data only"
| eval status=if(accounttype=="Human_Account" and status="InActive",null(),status)

 

Screenshot 2022-04-12 at 10.08.37 AM.pngScreenshot 2022-04-12 at 10.08.37 AM.png

 

 

Thanks
KV



If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

View solution in original post

kamlesh_vaghela
SplunkTrust
SplunkTrust

@azleeshah 

You can eval the field and define logic as per your requirement. Please check below search.

YOUR_SEARCH
| eval status=if(accounttype=="Human_Account" and status="InActive",null(),status)

 

Here, I have nullified status column if account type is Human_Account and status is InActive.

You can change if condition as per your requirement.

My Sample Search :

 

| makeresults | eval _raw="accounttype,status,count
Human_Account,Active,1333
Human_Account,InActive,106
Generic_Account,Active,50
Service_Account,InActive,540" | multikv forceheader=1
|table accounttype                status           count
| rename comment as "Upto now is for sample data only"
| eval status=if(accounttype=="Human_Account" and status="InActive",null(),status)

 

Screenshot 2022-04-12 at 10.08.37 AM.pngScreenshot 2022-04-12 at 10.08.37 AM.png

 

 

Thanks
KV



If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

azleeshah
Explorer

@kamlesh_vaghela  thanks so much sir - the SPL works as intended

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!

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...

Defend at Machine Speed: Your Guide to Security Sessions at .conf26

Splunk .conf26   With threats moving at machine speed and attack surfaces expanding across hybrid ...

Where Innovation Takes Flight: The Splunk4Aviation Flight Sim Lands at .conf26

If you hear someone at .conf26 shouting "gear down, GEAR DOWN" across the show floor, you have found us.  The ...