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!

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureThursday, March 27, 2025  |  11AM PST / 2PM EST | Register NowStep boldly ...

Splunk AppDynamics with Cisco Secure Application

Web applications unfortunately present a target rich environment for security vulnerabilities and attacks. ...