Skip to main content

DataCollectionSource

Declare one SNMP data-collection source per document: the MIB objects, resource types and system definitions of one datacollection-group, and the collection profiles that include it. Targets /api/v2/datacollectionconf. Requires a Horizon build with the DB-backed data-collection subsystem, which released Horizon 37.0.0 and older lack. See the compatibility table.

onmsctl manages only the sources you write documents for. The stock vendor sources stay untouched.

YAML​

FieldTypeDefaultDescription
apiVersionstringrequireddatacollection.opennms.org/v1
kindstringrequiredDataCollectionSource
metadata.namestringrequiredSource (datacollection-group) name. Must not be empty. Must be unique within one apply. Renaming creates a new source.
spec.enabledbooleantrueWhether the source is active.
spec.resourceTypeslist of resource types[]Custom resource types the source defines.
spec.groupslist of MIB groups[]MIB objects collected together.
spec.systemDefslist of system definitions[]Which groups to collect for devices matching a sysoid.
spec.profileslist of profile names[]Collection profiles that include this source. A new source needs at least one.
spec.profileSpecprofilenoneA profile to create or tune inline.

Declare at least one of resourceTypes, groups or systemDefs. Without profileSpec, every name in profiles must already exist on the server. With profileSpec, profiles can also name the profile it creates.

Fields of a resource type (spec.resourceTypes[]):

FieldTypeDefaultDescription
namestringrequiredResource type name. Must not be empty.
labelstringnoneDisplay label.
resourceLabelstringnoneLabel template for each resource, such as ${acmeSensorName} (index ${index}).
persistenceSelectorstrategynonePersistence-selector strategy.
storageStrategystrategynoneStorage strategy.

Fields of a strategy (persistenceSelector, storageStrategy):

FieldTypeDefaultDescription
classstringrequiredFully qualified Java class name. Must not be empty.
paramslist of {key, value}[]Strategy parameters. Both key and value are required. Order is significant.

Fields of a MIB group (spec.groups[]):

FieldTypeDefaultDescription
namestringrequiredGroup name. Must not be empty.
ifTypestringrequiredInterface filter: all, ignore, or a numeric ifType.
mibObjectslist of MIB objectsrequiredAt least one entry.
includeGroupslist of group names[]Other groups this group includes.

Fields of a MIB object (spec.groups[].mibObjects[]):

FieldTypeDefaultDescription
oidstringrequiredObject identifier. Must not be empty.
instancestringrequiredInstance, such as "0" or a resource type name.
aliasstringrequiredName the value is stored under. Must not be empty.
typestringrequiredSNMP type, case-insensitive: counter, counter32, counter64, gauge, gauge32, integer, integer32, unsigned32, timeticks, octetstring, hexstring, string, ipaddress or opaque.
maxvalstringnoneUpper collection bound.
minvalstringnoneLower collection bound.

Fields of a system definition (spec.systemDefs[]):

FieldTypeDefaultDescription
namestringrequiredSystem definition name. Must not be empty.
sysoidMaskstringnoneOID prefix. Matches every device under this subtree. Cannot be combined with sysoid.
sysoidstringnoneExact sysoid. Cannot be combined with sysoidMask.
includeGroupslist of group names[]Groups to collect for matching devices. Each must be a group in this document's spec.groups.

Fields of the inline profile (spec.profileSpec):

FieldTypeDefaultDescription
namestringrequiredProfile name. Must not be empty.
rrdStepintegerrequiredRRD step in seconds. Must be positive.
rraslist of stringsrequiredRound-robin archive definitions, such as RRA:AVERAGE:0.5:1:2016. At least one.
storageFlagstringrequiredall, select or primary, case-insensitive.

Apply​

onmsctl apply -f examples/datacollection-source.yaml --dry-run --diff
onmsctl apply -f examples/datacollection-source.yaml

Expected output:

$ onmsctl apply -f examples/datacollection-source.yaml --dry-run --diff
acme-router: create source, create profile, attach [acme-collection]
+----------------------+-------------+--------+---------+-----------------------+
| kind | name | action | status | message |
+===============================================================================+
| DataCollectionSource | acme-router | create | Skipped | dry-run: would create |
+----------------------+-------------+--------+---------+-----------------------+

Apply reconciles each source in this order:

  1. Profile. Apply creates the profileSpec profile if it is absent, and updates it if rrdStep, rras or storageFlag differ.
  2. Source tree. Apply uploads a new source attached to every profile in spec.profiles. For an existing source, it re-uploads the whole tree when it changed. The server then removes children the document no longer declares (Horizon behaviour). An unchanged tree sends no upload.
  3. Profile membership. spec.profiles is the full list. Apply attaches the source to profiles it is missing from, and detaches it from profiles no longer listed.
  4. Enabled state. Apply enables or disables the source to match spec.enabled.

The tree comparison ignores the order of groups, MIB objects, resource types and system definitions. Strategy params order counts.

Apply never deletes sources or profiles. Sources no document declares are left alone. A detached profile stays on the server. A profileSpec profile not listed in spec.profiles is reconciled, but the source is not attached to it. Plan prints warning: <name>: spec.profileSpec.name "<profile>" is not listed in spec.profiles to stderr when this happens.

If a write fails partway, the result lists the steps that completed, then FAILED: and the error.

Plan gates: every document is parsed and validated, and names are checked for duplicates, before any HTTP request. Apply then checks once that the server has /api/v2/datacollectionconf. On a server without it, the whole apply aborts before any write. A source that fails its plan checks, such as a missing profile, fails at execute. Later sources are not attempted unless you pass --continue-on-error.

Order: DataCollectionSource (rank 375) applies after Maintenance (350) and before Graph (390). It has no dependency on other kinds. The rank only fixes a deterministic order.

Diff​

--diff prints one line per source.

acme-router: create source, create profile, attach [acme-collection]
cisco-extra: replace tree, detach [old-collection]
juniper-extra: tree unchanged, update profile, disable

A source that fails its plan checks prints its name, ERROR, and the message.

Inspect and delete​

onmsctl datacollection list
onmsctl datacollection list --profiles
onmsctl datacollection export acme-router
onmsctl datacollection export acme-router --format json
onmsctl datacollection delete acme-router

Expected output:

$ onmsctl datacollection list
+----+---------------------------------------+
| ID | NAME |
+============================================+
| 1 | 3Com |
|----+---------------------------------------|
| 2 | Acme Packet |
|----+---------------------------------------|
...
$ onmsctl datacollection list --profiles
+---------+----------+---------+---------+
| NAME | RRD STEP | STORAGE | SOURCES |
+========================================+
| default | 300 | select | 77 |
|---------+----------+---------+---------|
| ejn | 180 | select | 1 |
+---------+----------+---------+---------+
  • dc is an alias for datacollection.
  • list shows each source's id and name. --profiles lists the collection profiles instead, with their RRD step, storage flag and source count.
  • export prints one source's datacollection-group document as xml (the default) or json.
  • delete removes the source with its MIB groups, resource types and system definitions. Profiles stay in place.
  • list, export and delete run the same endpoint check as apply. list --profiles does not.

Errors​

MessageProbable causeRecovery
the data-collection REST endpoint (/api/v2/datacollectionconf) is not available on this serverThe server lacks the DB-backed data-collection subsystem.Use a Horizon build that has it. See the compatibility table.
spec must declare at least one of resourceTypes / groups / systemDefsThe source tree is empty.Add a resource type, group or system definition.
must declare at least one mibObjectA group has no mibObjects.Add a MIB object, or remove the group.
oid and alias must both be non-emptyA MIB object is incomplete.Set both fields.
is not a recognized SNMP typeA typo in a MIB object's type.Use one of the listed SNMP types.
ifType must not be emptyA group has an empty ifType.Set all, ignore, or a numeric ifType.
sets both sysoid and sysoidMaskA system definition sets both match fields.Keep one.
which is not defined in this document's spec.groupsA system definition includes a group this document does not define.Define the group, or remove the entry.
spec.profileSpec.rrdStep must be a positive number of secondsrrdStep is 0.Set a positive step.
spec.profileSpec.rras must declare at least one RRArras is empty.Add an RRA definition.
must be one of all / select / primaryA typo in storageFlag.Use all, select or primary.
duplicate kind: DataCollectionSource metadata.nameTwo documents share a metadata.name.Rename one.
a new source must be attached to at least one profileA new source has an empty spec.profiles.List at least one profile.
spec.profiles references profileA listed profile does not exist on the server, and no profileSpec creates it.Fix the name, or add a profileSpec for it.
server rejected the upload of sourceThe server reported errors for the uploaded tree.Fix the reported fields, then re-apply.
was created but did not appear in names-and-idsThe new source could not be found again to disable it.Re-apply to reconcile the enabled state.
no data-collection source namedexport or delete names a source the server does not have.Check the name with onmsctl datacollection list.

Example​

examples/datacollection-source.yaml
# Copyright 2026 Ronny Trommer <ronny@no42.org>
# SPDX-License-Identifier: Apache-2.0
#
# kind: DataCollectionSource. It declares one SNMP data-collection group
# ("source"), managed declaratively via `onmsctl apply -f`. Targets the v2
# /api/v2/datacollectionconf surface (the DB-backed data-collection subsystem;
# absent from released Horizon <= 37.0.0, so apply preflights the endpoint).
#
# onmsctl owns ONLY the sources you write documents for. The stock vendor
# library is left untouched. A re-apply that changes the group tree replaces the
# whole source (the server prunes children you removed); `profiles` is the full
# source of truth for which collections include this source (attach AND detach).
apiVersion: datacollection.opennms.org/v1
kind: DataCollectionSource
metadata:
# The datacollection-group (source) name. This is the stable key; renaming it
# creates a new source (delete the old one with `onmsctl datacollection delete`).
name: acme-router
spec:
# Whether the source is active. Optional; defaults to true.
enabled: true

# The snmp-collection profiles that SHALL include this source (by name).
# Reconciled as a TRUE set: a name removed here is detached on the next apply.
# A NEW source must list at least one profile (the server requires it). When
# `profileSpec` is absent, every name here must already exist on the server.
profiles:
- acme-collection

# OPTIONAL ("C+"): author/tune the profile inline. If the named profile does
# not exist it is created; if it differs it is updated. Omit this block to
# require the profiles above to pre-exist.
profileSpec:
name: acme-collection
rrdStep: 300
rras:
- "RRA:AVERAGE:0.5:1:2016"
- "RRA:AVERAGE:0.5:12:1488"
- "RRA:AVERAGE:0.5:288:366"
- "RRA:MAX:0.5:288:366"
- "RRA:MIN:0.5:288:366"
storageFlag: select # one of: all / select / primary

# Custom resource types (indexed/tabular resources) defined by this group.
resourceTypes:
- name: acmeSensorIndex
label: Acme Sensors
resourceLabel: "${acmeSensorName} (index ${index})"
persistenceSelector:
class: org.opennms.netmgt.collection.support.PersistAllSelectorStrategy
storageStrategy:
class: org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy
params:
- { key: sibling-column-name, value: acmeSensorName }

# MIB groups: the OIDs collected together, scoped by `ifType`
# (`all` / `ignore` / a numeric ifType).
groups:
- name: acme-system
ifType: ignore
mibObjects:
- { oid: .1.3.6.1.4.1.99999.1.1.1, instance: "0", alias: acmeCpuLoad, type: gauge }
- { oid: .1.3.6.1.4.1.99999.1.1.2, instance: "0", alias: acmeUptime, type: timeticks }
- name: acme-sensors
ifType: all
mibObjects:
- { oid: .1.3.6.1.4.1.99999.2.1.3, instance: acmeSensorIndex, alias: acmeSensorValue, type: gauge }

# System definitions: collect the named groups for devices matching a sysoid.
systemDefs:
- name: Acme Router
sysoidMask: .1.3.6.1.4.1.99999.
includeGroups:
- acme-system
- acme-sensors