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!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...