Splunk Search

Multiple expressions in single search

stlimanika
New Member

I'm trying to combine multiple rex expressions in a single search, but I'm having issues with my syntax. More specifically I'm trying to create a table showing the state of Weblogic application deployments after a JVM restart. We have multiple application deployments so I'd like to gather the information showing status of each application after JVM starts up. A clip from my logs might look like this...

[Jan 19, 2018 6:44:17 PM GMT] [Info] [Deployer] [myhost.com] [my-wls-jvm-name01] [[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)'] [[WLS Kernel]] [1516387457459] [BEA-149060] [Module myapp.war of application myapp successfully transitioned from STATE_ADMIN to STATE_ACTIVE on server my-wls-jvm-name01.]

[Jan 19, 2018 6:44:17 PM GMT] [Info] [Deployer] [myhost.com] [my-wls-jvm-name01] [[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)] [[WLS Kernel]] [1516387457442] [BEA-149059] [Module myotherapp.ear of application MyOtherApp Application [Version=11.1.1.1.0] is transitioning from STATE_ADMIN to STATE_ACTIVE on server my-wls-jvm-name01.]

My search looks something likes this...
host=myhost source=/hosting/logs//*.log CASE(Module) *.ear OR *.war | rex "Module (?[^/]+)of*transitioned from (?[^/]+)" | table myapp myappfromto

Tags (2)
0 Karma

gokadroid
Motivator

How about trying this below to have all the relevant things [out of which you can choose what do you want to pick]:

    host=myhost source=/hosting/logs//.log CASE(Module) .ear OR *.war
    | rex "\[Module\s*(?<myWar>[\S]+) of application (?<myApp>[\S]+) (?<action>.+) from (?<prevState>[\S]+) to (?<curState>[\S]+) on server (?<server>[^\]]+)"
| table myWar, myApp, action, prevState, curState, server

See extraction here

A better extraction which will ensure that spaces don't tumble the query can be seen here and using that your query shall look like as follows:

    host=myhost source=/hosting/logs//.log CASE(Module) .ear OR *.war
    | rex "\[Module\s*(?<myWar>[\S]+)\s*of\s*application\s*(?<myApp>[\S]+)\s*(?<action>.+)\s*from\s*(?<prevState>[\S]+)\s*to\s*(?<curState>[\S]+)\s*on\s*server\s*(?<server>[^\]]+)"
| table myWar, myApp, action, prevState, curState, server
0 Karma

horsefez
Motivator

Hi gokadroid,

actually the rex command isn't completed like this.

please do

| rex field=_raw "\[Module\s*(?<myWar>[\S]+)\s*of\s*application\s*(?<myApp>[\S]+)\s*(?<action>.+)\s*from\s*(?<prevState>[\S]+)\s*to\s*(?<curState>[\S]+)\s*on\s*server\s*(?<server>[^\]]+)"
0 Karma

gokadroid
Motivator

@horsefez
Please read the documentation here below:
http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex#Optional_arguments

What you are asking me to do is "optional" and anyways field is always taken _raw as default.

horsefez
Motivator

oh, wow... didn't know that 🙂

0 Karma

gokadroid
Motivator

we always learn something new with Splunk!!

0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...