Splunk Search

Regex Query Help: Need to Write a regex query for my log

mintughosh
Path Finder

Below given is one section of an event. The event has multiple such sections. I want to write a regex search query so that I can fetch the 3 fields from the below given log
1) 'Tableau Server (Service) ' (PD) is (Status).

2018-05-25 02:21:30.270 -0500_EXACT_10.218.108.14:RTEEPK08_:pid=12466_0x4364712fuser=request=_ RTEEPK08:
Status: DEGRADED
'Tableau Server Data Engine' (7653) is running.
'Tableau Server Coordination Service 0' (7633) is running.
'Tableau Server Search and Browse 0' (2542) is running.
'Tableau Server Tabadmin Service 0' (25262) is running.
'Tableau Server Gateway' (252564) is running.
'Tableau Server Cluster Controller' is stopped.
'Tableau Server Repository' status is not available.
'Tableau Server File Store' status is not available.

RTEEPK09:
Status: STOPPED
RTEEPK10:
Status: STOPPED

I already wrote a regex query to extract it in the form of table for host and Status. But I am having problems in writing the regex query for 'Tableau Server (Service)' (PD) is (Status).

Extract - (Service), (PD) and (Status)

Thank you
Note: This is a sample modified log file

0 Karma
1 Solution

FrankVl
Ultra Champion

Following should work:

| rex max_match=0 "Tableau Server (?<Service>[^']+)'\s*\(?(?<PD>\d+)?\)?\s+(?:is|status\s+is)\s+(?<Status>[\w\s]+)\."

https://regex101.com/r/pwEJae/1

Only trouble with this: it gets the data into multi valued fields which means that you loose a reliable connection between the different parts of each line. So you might want to consider splitting this into individual events for each line, before extracting the individual fields.

View solution in original post

0 Karma

FrankVl
Ultra Champion

Following should work:

| rex max_match=0 "Tableau Server (?<Service>[^']+)'\s*\(?(?<PD>\d+)?\)?\s+(?:is|status\s+is)\s+(?<Status>[\w\s]+)\."

https://regex101.com/r/pwEJae/1

Only trouble with this: it gets the data into multi valued fields which means that you loose a reliable connection between the different parts of each line. So you might want to consider splitting this into individual events for each line, before extracting the individual fields.

0 Karma

mintughosh
Path Finder

It gives me the following error.
Error in 'rex' command: The regex 'max_matches=0' does not extract anything. It should specify at least one named group. Format: (?...).

Should I be adding something more to that query ?

0 Karma

493669
Super Champion

try max_match=0 instead of max_matches=0

0 Karma

FrankVl
Ultra Champion

Good catch, updated that in my answer.

0 Karma

mintughosh
Path Finder

Tried but not getting the results as expected. I am not able to fetch the (Service), (PD) and (Status).

0 Karma

mintughosh
Path Finder

Ok. My issue is Resolved. I have added few more parameter and then followed by query Frank Suggested and then i added table to it

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...