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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...