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!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...