Splunk Search

Xml path extract field

Annna
Explorer

<Shipment Action>

<ShipmentLines>

<ShipmentLine PrimeLine="2" />

<ShipmentLine PrimeLine="3"/>

<ShipmentLine PrimeLine="4"/>

<ShipmentLine PrimeLine="1"/>

</ShipmentLines>

</Shipment Action>

in the above xml file i have to pick out the ShipmentLine count, some times ShipmentLine increases.

I have tried different rex combination without luck, any suggestions.

output:

ShipmentLine=4 count

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 "(?<ShipmentLine>ShipmentLine)\s"
| eval count=mvcount(ShipmentLine)

Since your elements don't appear to have any data (only attributes) spath/xpath will end up with empty fields which then can't be easily counted

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 "(?<ShipmentLine>ShipmentLine)\s"
| eval count=mvcount(ShipmentLine)

Since your elements don't appear to have any data (only attributes) spath/xpath will end up with empty fields which then can't be easily counted

0 Karma

Annna
Explorer

Thank you so much 

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...