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!

Splunk Enterprise Security 8.0.2 Availability: On cloud and On-premise!

A few months ago, we released Splunk Enterprise Security 8.0 for our cloud customers. Today, we are excited to ...

Logs to Metrics

Logs and Metrics Logs are generally unstructured text or structured events emitted by applications and written ...

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...