NDM Tags with Regex

NDM Tags with Regex

Datadog Network Device Monitoring (NDM) supports regular expressions to create metric tags in the format <KEY>:<VALUE>.

Setup

Installation

Follow the setup instructions to install Datadog NDM.

Configuration

In the SNMP conf.yaml, you can specify metric_tags from an OID. To create multiple tags for devices, use regular expressions to separate the resulting value into multiple tags, or get a substring using the regular Python engine.

OID

The example below creates two tags using regex matching on the OID’s value. So, if the OID’s value is 41ba948911b9, the tags host_prefix:41 and host:ba948911b9 are added to the corresponding metrics.

    metric_tags:
     - # From an OID:
       symbol:
          OID: 1.3.6.1.2.1.1.5.0
          name: sysName
       match: (\d\d)(.*)
       tags:
           host_prefix: \1
           host: \2

The example below creates tags using regex for a table:

metrics:
  - MIB: IF-MIB
    table:
      OID: 1.3.6.1.2.1.2.2
      name: ifTable
    symbols:
      - OID: 1.3.6.1.2.1.2.2.1.10
        name: ifInOctets
    metric_tags:
      - column':
          OID: 1.3.6.1.2.1.2.2.1.2
          name: ifDescr
        match: '(\w)(\w+)'
        tags:
         - prefix: '\1' 
         - suffix: '\2'

Further Reading