Splunk Search

Reg Ex/ REX to match patterns

rczone
Path Finder

Hello All,

THis might be simple question but need some guidance here:

i'm using pattern match like below but not satisfied with using double match conditions

match(ALERT_DESCRIPTION,"(FILE_test_file)") AND match(ALERT_DESCRIPTION,"For transaction Login \. 3 out of 3 transactions failed") ), "Global FIle Issue" 

Here ALERT_DESCRIPTION is a column in a table and Global FIle Issue is where the alert has to be named if the condition satisfied.

The description has the actual description of the error ..but im filtering the errors based on the issue so using match function here ..i want to use rex function inside match(or esle pls guide me how to check 2 strings patterns in single match function instead of multiple match functions

like this

match(ALERT_DESCRIPTION,"(rex <<magic goes here>)",  "Global FIle Issue" 
0 Karma

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval ALERT_DESCRIPTION ="test For transaction Login . 3 out of 3 transactions failed 1234" 
| append 
    [| makeresults 
    | eval ALERT_DESCRIPTION ="test FILE_test_file test" ] 
| append 
    [| makeresults 
    | eval ALERT_DESCRIPTION ="test" ] 
| eval ISSUE_TYPE=case((match(ALERT_DESCRIPTION,"(FILE_test_file) | (For transaction Login \\. 3 out of 3 transactions failed)")),"Global FIle Issue",true(),"-")

mayurr98
Super Champion

try like

case(like(ALERT_DESCRIPTION,"%(FILE_test_file)%") AND like(ALERT_DESCRIPTION,"%For transaction Login \. 3 out of 3 transactions failed%"), "Global FIle Issue")
0 Karma

rczone
Path Finder

@mayurr98 Thankyou for the response...my idea is to shorten the query (cutdown the usage of multiple AND)

im getting what i want with multiple match functions

IS there anyway can i use those strings in a single 'like' or 'match' function?

like below:
case( match(ALERT_DESCRIPTION,"(FILE_test_file)") | ("For transaction Login . 3 out of 3 transactions failed%, ), "Global FIle Issue"

0 Karma

mayurr98
Super Champion

can I see your entire search query?

0 Karma

rczone
Path Finder

index="m_data" sourcetype="uat:tables"
| fillnull value="Unknown"
| search SIG_TEAM_NAME IN ("" , "TESTAPP") ALERT_DESCRIPTION IN ("") ALERT_ID IN ("*") ALERT_SUPPORTGROUP IN ("TESTAPP")
| dedup ALERT_ID
| rex "KB_List\":\"(?[^\"]+)"
| table SIG_ID ALERT_ID SIG_ENVIRONMENT ALERT_HOSTNAME ALERT_INSTANCE KB_List ISSUE_TYPE ALERT_DESCRIPTION SIG_DESCRIPTION ALERT_STATUS ALERT_SUPPORTGROUP ALERT_FIRST_EVENT_TIME ALERT_LAST_EVENT_TIME
| sort ALERT_ID
|eval ISSUE_TYPE=case( match(ALERT_DESCRIPTION,"(FILE_test_file)") | ("For transaction Login . 3 out of 3 transactions failed%, ), "Global FIle Issue"

0 Karma

rczone
Path Finder

| eval ISSUE_TYPE=case( match(ALERT_DESCRIPTION,"(FILE_test_file)") | ("For transaction Login . 3 out of 3 transactions failed%, ), "Global FIle Issue"
@mayurr98

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...