xmlkv
Description
The xmlkv
command automatically extracts key-value pairs from XML-formatted data.
For JSON-formatted data, use the spath
command.
Syntax
The required syntax is in bold.
- xmlkv
- [<field>]
- maxinputs=<int>
Required arguments
None.
Optional arguments
- field
- Syntax: <field>
- Description: The field from which to extract the key and value pairs.
- Default: The
_raw
field.
- maxinputs
- Syntax: maxinputs=<int>
- Description: Sets the maximum number of events or search results that can be passed as inputs into the
xmlkv
command per invocation of the command. Thexmlkv
command is invoked repeatedly in increments according to themaxinputs
argument until the search is complete and all of the results have been displayed. Do not change the value ofmaxinputs
unless you know what you are doing. - Default: 50000
Usage
The xmlkv
command is a distributable streaming command. See Command types.
Keys and values in XML elements
From the following XML, name
is the key and Settlers of Catan
is the value in the first element.
<game> <name>Settlers of Catan</name> <category>competitive</category> </game> <game> <name>Ticket to Ride</name> <category>competitive</category> </game>
Examples
1. Automatically extract key-value pairs
Extract key-value pairs from XML tags in the _raw
field. Processes a maximum of 50000 events.
... | xmlkv
2. Extract key-value pairs in a specific number of increments
Extract the key-value pairs from events or search results in increments of 10,000 per invocation of the xmlkv
command until the search has finished and all of the results are displayed.
... | xmlkv maxinputs=10000
See also
x11 | xmlunescape |
This documentation applies to the following versions of Splunk Cloud Platform™: 8.2.2112, 8.2.2201, 8.2.2202, 8.2.2203, 9.0.2205, 9.0.2208, 9.0.2209, 9.0.2303, 9.0.2305, 9.1.2308, 9.1.2312, 9.2.2403 (latest FedRAMP release), 9.2.2406
Feedback submitted, thanks!