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