Splunk Search

How to replace a status with a new value?

_gkollias
Builder

I have search I'm running to change the status of a particular error that is a false negative:

index=wertyu sourcetype=audit  "No valid format *"
| eval status = if(other=="No valid format*","SUCCESS",status)
| stats count latest(status) as status, latest(other) as other by FOO

I'm still seeing FAILED as the status rather than success, and am not quite sure what's wrong here.

Any insights would be greatly appreciated.

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

I'm not sure why you're testing to see if "No valid format" is present when you've told Splunk to only return events with that text.
That said, try this.

... | eval status = if(match(other,"No valid format%"),"SUCCESS",status) | ...
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

I'm not sure why you're testing to see if "No valid format" is present when you've told Splunk to only return events with that text.
That said, try this.

... | eval status = if(match(other,"No valid format%"),"SUCCESS",status) | ...
---
If this reply helps you, Karma would be appreciated.

_gkollias
Builder

Yes! This worked:

index=wertyu sourcetype=audit  "No valid format*" earliest=-5d
 | eval status = if(match(other,"No valid format\.*"),"SUCCESS",status)  
 | stats count latest(status) as status, latest(other) as other by FOO

Thank you!

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Glad to hear it. Please accept the answer.

---
If this reply helps you, Karma would be appreciated.

_gkollias
Builder

Sure thing - here is a friendly sample of the log file:

2015-11-04T13:20:34.319 -0500,1,{host=host},{BP|InvoiceAudit|STATUS ,[CODE]::No valid format for FOO.-

We use extractions before parsing the data, so any string in that placement is stored in the other field.

Also, we know it works since I am able to populate the results in the searches above. The weird thing here is that the status isn't changing.

Any thoughts?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I confused the match syntax with the like syntax. One of these should work for you.

... | eval status = if(like(other,"No valid format%"),"SUCCESS",status) | ...

or

... | eval status = if(match(other,"No valid format\.*"),"SUCCESS",status) | ...
---
If this reply helps you, Karma would be appreciated.

_gkollias
Builder

Thanks - I am testing to make sure that the search results are accurate before broadening the scope of the search. Why not test this on data I know should give me what I would expect first?

Unfortunately, I am still seeing FAILED as status rather than SUCCESS:

index=wertyu sourcetype=audit  "No valid format*"
| stats count latest(status) as status, latest(other) as other by FOO
| eval status = if(match(other,"No valid format%"),"SUCCESS",status)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Can we see a sample of your data? Have you verified the other field contains the target text?

---
If this reply helps you, Karma would be appreciated.
0 Karma

clorne
Communicator

Hello
No valid format * is different from No valid format* (there is no blank between the t and *).

Regards

0 Karma

_gkollias
Builder

Thanks - this did not make a difference in the results.

0 Karma

sloshburch
Splunk Employee
Splunk Employee

It will not make a different as long as a non-word character is trailing. Those are caught as punctuations. But remember, you might not notice that its no difference, but the result set could be different.

For example:
"no valid format" will match results that contain the string "no valid format/" but not "no valid format ".

Make sense?

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...