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!

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, ...