The XmlCollector collects and extracts metrics from XML and JSON documents.

Collector facts

Class Name




Supported on Minion

Yes (see limitations)

Configuration Files


Configuration and use

Table 1. Collector-specific parameters for the XmlCollector
Parameter Description Default



The name of the XML Collection to use.




Class that performs the collection.


The available handlers include:

  • org.opennms.protocols.xml.collector.DefaultXmlCollectionHandler

  • org.opennms.protocols.xml.collector.Sftp3gppXmlCollectionHandler

  • org.opennms.protocols.xml.vtdxml.DefaultVTDXmlCollectionHandler

  • org.opennms.protocols.xml.vtdxml.Sftp3gppVTDXmlCollectionHandler

  • org.opennms.protocols.json.collector.DefaultJsonCollectionHandler

  • org.opennms.protocols.http.collector.HttpCollectionHandler


The org.opennms.protocols.json.collector.DefaultJsonCollectionHandler requires the fetched document to be a single element of type object to make xpath query work. If the root element is an array, it will be wrapped in an object accessible as /elements.

XML collection configuration

Understanding resource types helps when editing collector-specific configuration files.

XML collections are defined in ${OPENNMS_HOME}/etc/xml-datacollection-config.xml and groups are defined in ${OPENNMS_HOME}/etc/xml-datacollection/.

Sample collection definition named xml-opennms-nodes
<xml-collection name="xml-opennms-nodes">
  <rrd step="300">
  <xml-source url="http://admin:admin@{ipaddr}:8980/opennms/rest/nodes">

The url attribute of the <xml-source> supports node and IpInterface field placeholders, though it does not support metadata tokens.

The referenced opennms-nodes.xml file
    <xml-group name="nodes" resource-type="node" resource-xpath="/nodes">
        <xml-object name="totalCount" type="GAUGE" xpath="@totalCount"/>

Customize the source request

If you need to customize the request to pull raw data, you can add a <request> element within the <xml-source> block.

  <xml-source url="http://admin:admin@{ipaddr}:8980/opennms/rest/nodes">
    <request method="GET">
      <parameter name="disable-ssl-verification" value="true"/>
      <parameter name="use-system-proxy" value="true"/>

The request element can have the following optional child <parameter> elements:

Parameter Description Default


The connection and socket timeout in milliseconds.



How often to repeat the request in case of an error.



Do not attempt to verify the name on the SSL certificate against the xml-source URL attribute.



Should the system-wide proxy settings be used? Configure the system proxy settings via system properties.



Full path to XSLT file to transform XML data before processing to collection definitions.


HTTP headers

If the endpoint being collected requires additional headers, you can add them as part of the <request> object.

  <xml-source url="https://{nodelabel}/api/path/to/endpoint">
    <request method="GET">
      <header name="Authorization" value="Bearer static_token_here" />
      <header name="X-Api-Key" value="api-key-here" />

Retrieve data from a POST request

If your XML data needs to be retrieved via a POST instead of a GET, you can specify the body content of the request.

  <xml-source url="http://{ipaddr}/post-example">
    <request method="POST">
      <content type='application/x-www-form-urlencoded'><![CDATA[
          <form-field name='firstName'>John</form-field>
          <form-field name='lastName'>Doe</form-field>
  <xml-source url="http://{ipaddr}/post-example">
    <request method="POST">
      <content type='application/xml'><![CDATA[
  <xml-source url="http://{ipaddr}/post-example">
    <request method="POST">
      <content type='application/json'><![CDATA[
          person: {
            firstName: 'John',
            lastName: 'Doe'

Mapping values

Sometimes data is represented as string values. These values are normally not persisted as time-series data; this means changes are not visible over time. To circumvent this, we allow mappings defined between input values and values to be persisted.

Let’s assume we have the following data input:


The following group configuration allows you to persist the input values as integer values over time:

<xml-group name="xml-mapping" resource-type="input" resource-xpath="/records/record" key-xpath="input">
    <xml-object name="input" type="GAUGE" xpath="input"> (1)
        <xml-mapping from="aaa" to="10" /> (2)
        <xml-mapping from="bbb" to="20" />
        <xml-mapping to="1000" /> (3)
    <xml-object name="read" type="GAUGE" xpath="read" />
1 The data-type is altered in the xml-object element from STRING to GAUGE.
2 In this example we associate aaa to 10 and bbb to 20.
3 Define a default value by omitting the from attribute in a xml-mapping definition. In this example ccc will be associated with the default value of 1000.

Test XML collection via Karaf

With the configuration in place, you can test it using the collect command available in the Karaf Shell:

opennms:collect -n 1 org.opennms.protocols.xml.collector.XmlCollector collection=xml-opennms-nodes