Skip to main content
Sumo Logic

Parse XML Formatted Logs

The XML operator uses a subset of the XPath 1.0 specification to provide a way for you to parse fields from XML documents. Using it, you can specify what to extract from an XML document using an XPath reference.

Ingested XML files must be well-formed and valid in order to be parsed by the XML operator. If the XML is not valid, you will receive an error.


  • | parse XML [field=<field_name>] "<xpath_expression>"[, "<xpath_expression>"] [as <fields>] [nodrop]


  • field=<field_name> 

    The field=fieldname option allows you to specify a field to parse other than the default message. For details, see Parse field

  • nodrop 

    The nodrop option forces results to also include messages that do not match any segment of the parse term. For details, see Parse nodrop


  • If no field is specified, then the entire text of incoming messages is used.
  • If the XPaths are not valid, an error is thrown.
  • If the number of field names don't match the specified XPaths, an error is thrown.
  • If the field is not well-formed XML, null is returned, unless you have specified nodrop.
  • If the XPath doesn't match anything in the document, then null is returned, unless you have specified nodrop.
  • If the XPath matches an element, then its string representation is returned.
  • If the XPath matches multiple elements, then the first one is returned.


Extract a field from an XML document

For example, from this document:

<af type="nursery" id="102" timestamp="Nov 20 04:41:11 2013" intervalms="1089510.533">
<minimum requested_bytes="48" />
<time exclusiveaccessms="0.163" meanexclusiveaccessms="0.163" threads="0" lastthreadtid="0x0000000034520C00" />
<refs soft="40652" weak="35055" phantom="594" dynamicSoftReferenceThreshold="10" maxSoftReferenceThreshold="32" />
<nursery freebytes="0" totalbytes="324978688" percent="0" />
<tenured freebytes="61087704" totalbytes="553484288" percent="11" >
<soa freebytes="33414104" totalbytes="525810688" percent="6" />
<loa freebytes="27673600" totalbytes="27673600" percent="100" />
<refs soft="40619" weak="29867" phantom="586" dynamicSoftReferenceThreshold="10" maxSoftReferenceThreshold="32" />
<time totalms="91.622" />

you can extract information using an XPath reference, such as:

* | parse XML "/af/@type"

This will add the value of the attribute type, of the root af element, in a field called /af/@type, with value nursery.

The results are:

Extract a more complex field

Use a query such as:

* | parse xml "/af/minimum/@requested_bytes"

This will add the value of the attribute requested_bytes, of the root af/minimum element, in a field called /af/minimum@requested_bytes, with the number of requested bytes.

Extract multiple fields

Use a query such as:

| parse xml "/af/@type", "/af/@timestamp"

This will add the value of the attribute type and timestamp, of the root af element, in a field called /af/@type and /af/@timestamp, with value nursery and Nov 20 04:41:11 2013 respectively.

xml multiple fields results.png

XPath subset limitations

The full XPath 1.0 specification is not supported. In order to increase performance, Sumo Logic supports a subset of the specification, including the following caveats:

Forward only

The XML operator only allows XML paths to go deeper into the tree. For example, this expression is not allowed:


Full location paths

You must specify the full path to the elements you want to extract. This means that "self-or-descendant" expressions are not supported. For example, the following paths are not allowed:



No expanded syntax axis specifiers

Expanded syntax is not supported. For example, the following expressions cannot be used: