SNMP Data Collection Config REST API (v2)
You can manage SNMP data collection over REST. The same surface is used by the Admin → Manage SNMP Data Collection Config page; the API is useful for automation, bulk imports, and version-controlled tooling.
The base path is /api/v2/datacollectionconf.
Endpoint overview
All paths are relative to the base path.
For the request and response bodies, see the OpenAPI definition at /api/v2/openapi.json.
| Method | Path | Description |
|---|---|---|
Upload |
||
|
|
Upload source XML files and |
Profiles |
||
|
|
List all profiles. |
|
|
Get one profile. |
|
|
Create a profile. |
|
|
Update a profile. |
|
|
Delete profiles. The request body is a JSON array of profile IDs. |
|
|
Enable or disable profiles. The request body is a JSON array of profile IDs. |
|
|
Attach a source to a profile. The request body is the source name. |
|
|
Detach a source from a profile. |
Sources |
||
|
|
List sources, with filter, sort and pagination parameters. |
|
|
List the name and ID of all sources. |
|
|
Get one source. |
|
|
Create a source. |
|
|
Delete sources. Repeat |
|
|
Enable or disable sources. |
|
|
Download a source as a |
|
|
Download the top-level |
MIB groups, resource types and system definitions |
||
|
|
List the definitions of a source, with filter, sort and pagination parameters. |
|
|
Add a definition to a source. |
|
|
Update a MIB group. Resource types and system definitions use the same pattern. |
|
|
Delete definitions from a source. |
|
|
Enable or disable definitions in a source. |
Lookup by name |
||
|
|
List the names of all definitions of this type. The resource type list also contains the instance values |
|
|
Get every definition with this exact name, with the source that defines it. See Find a definition by name. |
Upload XML
Use this endpoint to import legacy datacollection-config.xml and etc/datacollection/*.xml files, or any externally version-controlled SNMP data collection definition.
Each upload part must be an XML file whose root element is either:
-
<datacollection-group>— a source definition (registered as a new source on first upload, updated on subsequent uploads). -
<datacollection-config>— a profile-driver file with<snmp-collection>entries. At most one is allowed per request; its<include-collection>entries drive how new sources are attached.
How profileNames is applied depends on the batch composition:
| Batch composition | profileNames requirement |
|---|---|
All-new sources |
Required. New sources are attached to the named profiles. |
All-update sources (every source already exists in the DB) |
Optional. If non-empty, applied additively to every source. |
Mixed (≥1 new and ≥1 update) |
Required for the new sources; ignored for updates. Use |
|
Ignored — the config’s |
An <include-collection> entry attaches a full source, or copies a part of a source:
-
dataCollectionGroup="X"attaches the sourceXto the profile. Later changes toXapply to the profile. -
dataCollectionGroup="X"with<exclude-filter>entries, andsystemDef="Y", copy the selected system definitions and the MIB groups that they name to the source_inline<profile>. The exclude-filter form also copies the resource types ofX. The sourceX, or the source that containsY, must be a file in the same request. Thus, include the files thatdatacollection-config.xmlrefers to in the same upload.
The copy does not change when you edit X later.
You can edit inline_<profile> in the UI like any other source.
An upload of datacollection-config.xml replaces the content of inline_<profile>, and your edits to it are lost.
If the request does not contain the source of an exclude-filter entry, the upload attaches the full source X and ignores the filter.
If the request does not contain the system definition Y, the upload skips it.
In both cases, the upload continues, and the errors array of the response contains a message.
default profilecurl -u admin:admin \
-X POST "http://localhost:8980/opennms/api/v2/datacollectionconf/upload" \
-F "upload=@/opt/opennms/etc_archive/datacollection/cisco.xml;type=application/xml" \
-F "upload=@/opt/opennms/etc_archive/datacollection/juniper.xml;type=application/xml" \
-F "profileNames=default"
The response body contains per-file success and errors arrays so partial failures are visible without rolling back the whole batch.
| Status | Meaning |
|---|---|
|
Upload processed. Inspect the response body for per-file success/error details. |
|
Invalid XML, missing required |
Find a definition by name
A MIB group, resource type or system definition name can exist in more than one source. Use these endpoints to find every source that defines a name. The Find by Name tab of the admin page uses the same endpoints.
mib2-interfaces MIB groupcurl -u admin:admin -G "http://localhost:8980/opennms/api/v2/datacollectionconf/mibgroups/by-name" \
--data-urlencode "name=mib2-interfaces"
The response is a JSON array with one entry for each source that defines the name.
Each entry contains the definition, its enabled flag, collectionSourceId and collectionSourceName.
The name is a query parameter, so a name that contains a slash, such as Microsoft Windows NT/2000, also works.
| Status | Meaning |
|---|---|
|
At least one source defines the name. |
|
The |
|
No source defines the name. |
|
The server cannot read the definitions. The server log contains the cause. |