Splunk Search

How to check field values are valid??

chitreshakumar
Communicator

I have field which is having sequence number .I want to check if it is valid and make a new field that will give if sequence number field is valid/invalid . Format is like "EH12839911" 10 digits first two letters alphabet while next 8 are digits.

0 Karma
1 Solution

mayurr98
Super Champion

hey @chitreshkumar

try this run anywhere search

| makeresults | eval sequence="EH12839911" | append [| makeresults | eval sequence="EH12831421"] |  append [| makeresults | eval sequence="3512839911"] |eval status=if(match(sequence,"^[A-Za-z]{2}[0-9]{8}"),"Valid","Invalid")

Ideally in your environment you should write

<your_base_search> | eval status=if(match(sequence,"^[A-Za-z]{2}[0-9]{8}"),"Valid","Invalid")

Let me know if this works!

View solution in original post

mayurr98
Super Champion

hey @chitreshkumar

try this run anywhere search

| makeresults | eval sequence="EH12839911" | append [| makeresults | eval sequence="EH12831421"] |  append [| makeresults | eval sequence="3512839911"] |eval status=if(match(sequence,"^[A-Za-z]{2}[0-9]{8}"),"Valid","Invalid")

Ideally in your environment you should write

<your_base_search> | eval status=if(match(sequence,"^[A-Za-z]{2}[0-9]{8}"),"Valid","Invalid")

Let me know if this works!

Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...