Splunk Search

Create static fields after matching the field value

RSS_STT
Explorer

I want to create one static field by looking status value = Issue

hostm_nnamestatus
AcpuOk
BdiskOk
CmemoryIssue
DnetwokOk
EstorageIssue

 

Issue found in status column few field heath created with Bad value.

Like below.

hostm_nnamestatusHealth
AcpuOkBad
BdiskOkBad
CmemoryIssueBad
DnetwokOkBad
EstorageIssueBad

 

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eventstats values(eval(if(status="Issue","Bad",null()))) as Health
| fillnull value="Ok" Health

View solution in original post

PickleRick
SplunkTrust
SplunkTrust

It's not clear how the health field is calculated. One way is what @ITWhisperer showed but it won't match your mockup results - you have health=bad all acros the board.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Are you saying that you want a health field that has "Bad" in for all the events if any of the events have status="Issue"?

0 Karma

RSS_STT
Explorer

Yes, Your understanding is correct.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eventstats values(eval(if(status="Issue","Bad",null()))) as Health
0 Karma

RSS_STT
Explorer

It's missing the fields value if all Ok. 

I need Health field to be populated with Ok if all status field have all Ok value.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eventstats values(eval(if(status="Issue","Bad",null()))) as Health
| fillnull value="Ok" Health

richgalloway
SplunkTrust
SplunkTrust

Use the eval command to create a field.

| eval Health = if(status="Issue", "Bad", "Ok")

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...