Splunk Search

How to edit my search to calculate a field?

ttchorz
Path Finder

Hi,

I am trying to calculate a field from a data that I receive from a vulnerability system.

severity field returns "unknown" which screws my dashboards.

I want to eval a field `'category' and if it equals INFO, set field 'severity' to Informational

search ... |  eval severity=if(category,"INFO","Informational")
0 Karma
1 Solution

gokadroid
Motivator

Try to assign it back to itself then if u want it to stay unmodified:

| eval severity=if(category=="INFO","informational", severity)

View solution in original post

0 Karma

adamsaul
Communicator

Try this out:
search ... | eval severity=case(match(category,"INFO"), "Informational", severity)

0 Karma

gokadroid
Motivator

Try to assign it back to itself then if u want it to stay unmodified:

| eval severity=if(category=="INFO","informational", severity)
0 Karma

ttchorz
Path Finder

Thanks all. This is working exactly how I wanted it to work.

0 Karma

ttchorz
Path Finder

Ok I got here....

| eval severity=if(category=="INFO","informational", " ")

What should my last argument be if I want the severity to stay unmodified if it does not equal INFO ?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...