Splunk Search

rex help ??

rakesh_498115
Motivator

props.conf

EXTRACT-IPUBMESSAGEID = <L:MESSAGEID>(?<IPUBMESSAGEID>[^<]*)</L:MESSAGEID>
EXTRACT-Parse_MESSAGEID = IPUB-(?<Component>[^_]+)_(?<LayerId>[^;_]+)[_;](?<Protocol>[^;_]+)[;_](UNKNOWN;)?(?:(?<TopicIdentifier>[^_]+)_)? in IPUBMESSAGEID

mysampleMESSAGEID

IPUB-OR_P1;JMS;UNKNOWN;OPENREACH-ESB--KCI_ArmStartInbound
IPUB-OR_P2_ArmEndInbound
IPUB-OR_P3;MQ_ArmEndInbound
IPUB-OR_MULT;JMS;UNKNOWN_ArmEndInbound
IPUB-OR_S1;JMS;/GS/T2R/FAULT/PEW_ArmEndInbound
IPUB-OR_S1;HTTP;/OR/T2R/FAULT/ACTION-REQUEST/AR-STATUS/*_ArmStartInbound

My rex was pickin the values for every message id .. expect for IPUB-OR_P2_ArmEndInbound

this is not working ..

Actually i should have the values
Componet= OR
LayerId-P1/P2/P3/MULT/S1
Protocol-MQ/JMS/HTTP

but this is not workin..

Tags (1)
0 Karma
1 Solution

bjoernjensen
Contributor

Hi!

Assuming you want the following extraction of this input:

IPUB-OR_P2_ArmEndInbound

Componet=OR
LayerId=P2
Protocol=
TopicIdentifier=ArmEndInbound

this should work:

EXTRACT-IPUBMESSAGEID = <l:messageid>(?<messageid1>[^<]*)</l:messageid>
EXTRACT-Parse_MESSAGEID = IPUB-(?<Component>[^_]+)_(?<LayerId>[^;_]+)[_;](?(?<=[_])(?<TopicIdentifier>.*$)|(?<Protocol>[^;_]+)[;_](?<TopicIdentifier>.*$)) in messageid1

For the mentioned line it would be helpful to know how you would like it to be extracted.

View solution in original post

bjoernjensen
Contributor

Hi!

Assuming you want the following extraction of this input:

IPUB-OR_P2_ArmEndInbound

Componet=OR
LayerId=P2
Protocol=
TopicIdentifier=ArmEndInbound

this should work:

EXTRACT-IPUBMESSAGEID = <l:messageid>(?<messageid1>[^<]*)</l:messageid>
EXTRACT-Parse_MESSAGEID = IPUB-(?<Component>[^_]+)_(?<LayerId>[^;_]+)[_;](?(?<=[_])(?<TopicIdentifier>.*$)|(?<Protocol>[^;_]+)[;_](?<TopicIdentifier>.*$)) in messageid1

For the mentioned line it would be helpful to know how you would like it to be extracted.

tgow
Splunk Employee
Splunk Employee

There are a couple of reasons why this is not working correctly. First of all I would recommend not using an asterisk because it is very greedy if at all possible. Second of all you cannot have multiple fields with the same name in a field extraction, ie: MESSAGE_ID. It has to be unique.

 EXTRACT-IPUBMESSAGEID = ^I(?<messageid1>[^;]+);(?<ipubmessageid>[^;]+);(?<messageid2>[^;]+);(?<messageid3>[^\n]+)

Thirdly you can only extract a field from a field not an extraction. I am creating the fields Component and LayerId from messageid1

 EXTRACT-Parse_MessageID = PUB-(?<Component>[^_]+)_(?<LayerId>\w+) in messageid1
0 Karma

rakesh_498115
Motivator

Hi tgow..thanks for your reply...based on your comments i changed my props.conf like this..

EXTRACT-IPUBMESSAGEID = (?[^<]*)/L:MESSAGEID
EXTRACT-Parse_MESSAGEID = IPUB-(?[^]+)(?[^;]+)_;;_?(?:(?[^]+)_)? in MESSAGEID1

but even in this case i could see the extraction of Component and LayerId for MESSAGEID1 value

IPUB-OR_P2_ArmEndInbound

can you pls help..am i missing some thing ??

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...