SNMP
This article focuses on SNMP data collection.
Terminology¶
SNMP(Simple network management protocol): A network protocol that is used to collect information about bare metal networking gear.OID(Object identifier): A unique ID or address on a device that when polled returns the response code of that value. For example, OIDs are CPU or device fan speed.sysOID(System object identifier): A specific address that defines the device type. All devices have a unique ID that defines it. For example, the Meraki base sysOID is1.3.6.1.4.1.29671.MIB(Managed information base): A database or list of all the possible OIDs and their definitions that are related to the MIB. For example, theIF-MIB(interface MIB) contains all the OIDs for descriptive information about a device’s interface.
About SNMP Protocol¶
The SNMP protocol is divided into three versions: v1/v2c/v3, of which:
- V1 and v2c are compatible. Many SNMP devices only offer v2c and v3 versions. v2c version, the best compatibility, many older devices only support this version.
- If the safety requirements are high, choose v3. Security is also the main difference between v3 version and previous versions.
DataKit supports all of the above versions.
Choosing v1/v2c version¶
When selecting the v1/v2c version, a v2_community_string must be provided for authentication when interacting with SNMP devices. Additionally, some devices further subdivide this into read-only community strings and read-write community strings. As the names suggest:
Read-only community name: The device will only provide internal metrics data to that party, and cannot modify some internal configurations (this is enough for DataKit).Read-write community name: The provider has the permission to query the internal metrics data of the equipment and modify some configurations.
Choosing v3 version¶
If you choose v3 version, you need to provide v3_user/v3_auth_protocol/v3_auth_key/v3_priv_protocol/v3_priv_key, etc. Each device is different and should be configured as same as configuration in SNMP device.
Configuration¶
Input Configuration¶
Go to the conf.d/samples directory under the DataKit installation directory, copy snmp.conf.sample and name it snmp.conf. Examples are as follows:
[[inputs.snmp]]
## Filling in specific device IP address, example ["10.200.10.240", "10.200.10.241"].
## And you can use auto_discovery and specific_devices at the same time.
## If you don't want to specific device, you don't need provide this.
# specific_devices = [""] # SNMP Device IP.
## Filling in autodiscovery CIDR subnet, example ["10.200.10.0/24", "10.200.20.0/24"].
## If you don't want to enable autodiscovery feature, you don't need provide this.
# auto_discovery = [""] # Used in autodiscovery mode only, ignore this in other cases.
## Consul server url for consul discovery
## We can discovery snmp instance from consul services
# consul_discovery_url = "http://127.0.0.1:8500"
## Consul token, optional.
# consul_token = "<consul token>"
## Instance ip key name. ("IP" case sensitive)
# instance_ip_key = "IP"
## Witch task will collect, according to consul service filed "Address"
## [] mean collect all, optional, default to []
# exporter_ips = ["<ip1>", "<ip2>"...]
## Consul TLS connection config, optional.
# ca_certs = ["/opt/tls/ca.crt"]
# cert = "/opt/tls/client.crt"
# cert_key = "/opt/tls/client.key"
# insecure_skip_verify = true
## SNMP protocol version the devices using, fill in 2 or 3.
## If you using the version 1, just fill in 2. Version 2 supported version 1.
## This is must be provided.
snmp_version = 2
## SNMP port in the devices. Default is 161. In most cases, you don't need change this.
## This is optional.
# port = 161
## Password in SNMP v2, enclose with single quote. Only worked in SNMP v2.
## If you are using SNMP v2, this is must be provided.
## If you are using SNMP v3, you don't need provide this.
# v2_community_string = ""
## Authentication for SNMP v3.
## If you are using SNMP v2, you don't need provide this.
## If you are using SNMP v3, this is must be provided.
# v3_user = ""
# v3_auth_protocol = "" # MD5/SHA/SHA224/SHA256/SHA384/SHA512 or empty
# v3_auth_key = ""
# v3_priv_protocol = "" # DES/AES/AES192/AES192C/AES256/AES256C or empty
# v3_priv_key = ""
# v3_context_engine_id = "" # optional
# v3_context_name = "" # optional
## Number of workers used to collect and discovery devices concurrently. Default is 100.
## Modifying it based on device's number and network scale.
## This is optional.
# workers = 100
## Number of max OIDs during walk(default 1000)
# max_oids = 1000
## Number of OIDs retrieved in a single SNMP Get/GetBulk call. Default is 5.
# oid_batch_size = 5
## Max repetitions used in SNMP GetBulk calls. Default is 10.
# bulk_max_repetitions = 10
## Interval between each auto discovery in seconds. Default is "1h".
## Only worked in auto discovery feature.
## This is optional.
# discovery_interval = "1h"
## Collect metric interval, default is 10s. (optional)
# metric_interval = "10s"
## Collect object interval, default is 5m. (optional)
# object_interval = "5m"
## Enable LLDP topology collection. Default is false. (optional)
# enable_lldp = false
## LLDP collection interval, default is 10m. (optional)
# lldp_interval = "10m"
## Filling in excluded device IP address, example ["10.200.10.220", "10.200.10.221"].
## Only worked in auto discovery feature.
## This is optional.
# discovery_ignored_ip = []
## Set true to enable election
# election = true
## Device Namespace. Default is "default".
# device_namespace = "default"
## Picking the metric data only contains the field's names below.
# enable_picking_data = true # Default is "false", which means collecting all data.
# status = ["sysUpTimeInstance", "tcpCurrEstab", "ifAdminStatus", "ifOperStatus", "cswSwitchState"]
# speed = ["ifHCInOctets", "ifHCInOctetsRate", "ifHCOutOctets", "ifHCOutOctetsRate", "ifHighSpeed", "ifSpeed", "ifBandwidthInUsageRate", "ifBandwidthOutUsageRate"]
# cpu = ["cpuUsage"]
# mem = ["memoryUsed", "memoryUsage", "memoryFree"]
# extra = []
## The matched tags would be dropped.
# tags_ignore = ["Key1","key2"]
## The regexp matched tags would be dropped.
# tags_ignore_regexp = ["^key1$","^(a|bc|de)$"]
## Zabbix profiles
# [[inputs.snmp.zabbix_profiles]]
## Can be full path file name or only file name.
## If only file name, the path is "./conf.d/snmp/userprofiles/
## Suffix can be .yaml .yml .xml
# profile_name = "xxx.yaml"
## ip_list is optional
# ip_list = ["ip1", "ip2"]
## Device class, Best to use the following words:
## access_point, firewall, load_balancer, pdu, printer, router, sd_wan, sensor, server, storage, switch, ups, wlc, net_device
# class = "server"
# [[inputs.snmp.zabbix_profiles]]
# profile_name = "yyy.xml"
# ip_list = ["ip3", "ip4"]
# class = "switch"
# ...
## Prometheus snmp_exporter profiles,
## If module mapping different class, can disassemble yml file.
# [[inputs.snmp.prom_profiles]]
# profile_name = "xxx.yml"
## ip_list useful when xxx.yml have 1 module
# ip_list = ["ip1", "ip2"]
# class = "net_device"
# ...
## Prometheus consul discovery module mapping. ("type"/"isp" case sensitive)
# [[inputs.snmp.module_regexps]]
# module = "vpn5"
## There is an and relationship between step regularization
# step_regexps = [["type", "vpn"],["isp", "CT"]]
# [[inputs.snmp.module_regexps]]
# module = "switch"
# step_regexps = [["type", "switch"]]
# ...
## Field key or tag key mapping. Do NOT edit.
[inputs.snmp.key_mapping]
CNTLR_NAME = "unit_name"
DISK_NAME = "unit_name"
ENT_CLASS = "unit_class"
ENT_NAME = "unit_name"
FAN_DESCR = "unit_desc"
IF_OPERS_TATUS = "unit_status"
IFADMINSTATUS = "unit_status"
IFALIAS = "unit_alias"
IFDESCR = "unit_desc"
IFNAME = "unit_name"
IFOPERSTATUS = "unit_status"
IFTYPE = "unit_type"
PSU_DESCR = "unit_desc"
SENSOR_LOCALE = "unit_locale"
SNMPINDEX = "snmp_index"
SNMPVALUE = "snmp_value"
TYPE = "unit_type"
SENSOR_INFO = "unit_desc"
## We can add more mapping below
# dev_fan_speed = "fanSpeed"
# dev_disk_size = "diskTotal
## Reserved oid-key mappings. Do NOT edit.
[inputs.snmp.oid_keys]
"1.3.6.1.2.1.1.3.0" = "netUptime"
"1.3.6.1.2.1.25.1.1.0" = "uptime"
"1.3.6.1.2.1.2.2.1.13" = "ifInDiscards"
"1.3.6.1.2.1.2.2.1.14" = "ifInErrors"
"1.3.6.1.2.1.31.1.1.1.6" = "ifHCInOctets"
"1.3.6.1.2.1.2.2.1.19" = "ifOutDiscards"
"1.3.6.1.2.1.2.2.1.20" = "ifOutErrors"
"1.3.6.1.2.1.31.1.1.1.10" = "ifHCOutOctets"
"1.3.6.1.2.1.31.1.1.1.15" = "ifHighSpeed"
"1.3.6.1.2.1.2.2.1.8" = "ifNetStatus"
## We can add more oid-key mapping below
# [inputs.snmp.tags]
# tag1 = "val1"
# tag2 = "val2"
[inputs.snmp.traps]
enable = true
bind_host = "0.0.0.0"
port = 9162
stop_timeout = 3 # stop timeout in seconds.
Once configured, restart DataKit is sufficient.
Can be turned on by ConfigMap Injection Collector Configuration or Config ENV_DATAKIT_INPUTS .
Tip
Once the above configuration is complete, you can use the datakit debug --input-conf command to test if the configuration is correct, as shown in the following example:
If correct the line protocol information would print out in output, otherwise no line protocol information is seen.
Note
- If the
inputs.snmp.tagsconfigured above duplicates the key in the original fields with the same name, it will be overwritten by the original data. - The IP address (required in specified device mode)/segment (required in auto-discovery mode) of the device, the version number of the SNMP protocol and the corresponding authentication fields are required.
- "Specified device mode" and "auto-discovery mode", the two modes can coexist, but the SNMP protocol version number and the corresponding authentication fields must be the same among devices.
Multiple configuration formats¶
Built-in Profile Format¶
A built-in Profile uses YAML to describe the device sysObjectID, OIDs to collect, metric types, tags, and metadata.
This format is suitable when:
- The built-in Profiles do not cover the device model;
- Vendor-specific MIB metrics need to be added;
- The device returns numeric values as String/OCTET STRING;
- Device metadata needs to be added.
Profile YAML is different from Zabbix Template and Prometheus snmp_exporter formats. Their fields cannot be mixed.
Prepare OID Information¶
Before writing a Profile, obtain the device MIB/OID manual and use snmpget or snmpwalk to verify the actual values returned by the device. At minimum, confirm:
- The
sysObjectID, which is the value of OID1.3.6.1.2.1.1.2.0; - Whether each metric is a scalar or a table column;
- The metric OID, data type, meaning, and unit;
- The complete String/OCTET STRING value format;
- The table index and tag columns that distinguish each row.
Add a Profile¶
DataKit releases built-in Profiles to conf.d/snmp/profiles/ under the installation directory, and this directory may be overwritten during startup or upgrade. To add a site-specific Profile or override a built-in Profile, place the YAML file in conf.d/snmp/extra_profiles/. DataKit merges both directories during the default Profile loading flow, with extra_profiles taking precedence.
Example:
File requirements:
- The extension must be
.yaml; - The file name must not start with
_; files starting with_are inheritance templates only; - If a file has the same name as a built-in Profile, the file in
extra_profilestakes precedence; to keep the built-in content, extend the same file name in the supplemental Profile; - Different file names should not use the same
sysobjectid, otherwise automatic matching treats them as duplicate Profiles.
Restart DataKit after adding the file.
Basic Structure¶
extends:
- generic-router.yaml
sysobjectid: 1.3.6.1.4.1.<enterprise_id>.<product_id>
device:
vendor: vendor_name
static_tags:
- "device_type:router"
metadata:
device:
fields:
model:
symbol:
OID: 1.3.6.1.4.1.<enterprise_id>.1.1.0
name: vendorModel
metric_tags:
- symbol:
OID: 1.3.6.1.2.1.1.5.0
name: sysName
tag: snmp_host
metrics:
- MIB: VENDOR-MIB
symbol:
OID: 1.3.6.1.4.1.<enterprise_id>.2.1.0
name: vendor.system.cpu_usage
metric_type: gauge
Root-level fields:
| Field | Required | Description |
|---|---|---|
extends |
No | Inherits other Profiles to reuse common metrics and metadata |
sysobjectid |
Required for automatic matching | A string or list of strings; supports the * wildcard |
device.vendor |
No | Generates the device_vendor tag and serves as the fallback device vendor metadata |
static_tags |
No | Fixed key:value tags applied to Profile data |
metadata |
No | Device metadata definitions |
metric_tags |
No | Profile-level dynamic tags generated from scalar OIDs |
metrics |
No | Scalar and table metric definitions |
MIB and table improve YAML readability but do not determine which SNMP queries are executed. DataKit queries the OIDs configured in symbol, symbols, metric_tags, and metadata.
Inherit Profiles¶
Use extends to inherit existing Profiles. Metrics, tags, and metadata from inherited Profiles are merged into the current Profile, reducing duplicate standard MIB configuration.
Built-in Profiles are located in conf.d/snmp/profiles/, and site-specific supplemental Profiles are located in conf.d/snmp/extra_profiles/. Before writing YAML, check the files starting with _ in the built-in directory and select reusable templates provided by the current DataKit version. Common templates include:
| Profile | Purpose |
|---|---|
_base.yaml |
Common device tags and basic device metadata |
_generic-if.yaml |
IF-MIB interface metrics and interface metadata |
_generic-ip.yaml |
IP-MIB metrics |
_generic-tcp.yaml |
TCP-MIB metrics |
_generic-udp.yaml |
UDP-MIB metrics |
_generic-ospf.yaml |
OSPF-MIB metrics |
_generic-bgp4.yaml |
BGP4-MIB metrics |
_generic-lldp.yaml |
LLDP metrics and metadata |
_generic-entity-sensor.yaml |
ENTITY-SENSOR-MIB sensor metrics |
_generic-host-resources.yaml |
HOST-RESOURCES-MIB host resource metrics |
_generic-ups.yaml |
Common UPS metrics |
_cisco-generic.yaml |
Common Cisco interface, IP, TCP, UDP, OSPF, BGP, CPU, memory, and metadata definitions |
_huawei.yaml |
Common Huawei interface and vendor metadata definitions |
_juniper.yaml |
Common Juniper base configuration and vendor metadata |
Files starting with _ are inheritance templates and do not independently participate in automatic sysObjectID matching. A complete Profile without the _ prefix can also be inherited. For example:
generic-router.yaml already inherits _base.yaml, _generic-if.yaml, _generic-ip.yaml, _generic-tcp.yaml, _generic-udp.yaml, and _generic-ospf.yaml. Do not inherit these files again after inheriting generic-router.yaml.
For a Cisco device, inherit the common Cisco template and add device-specific metrics:
Notes:
- File names in
extendsare resolved fromconf.d/snmp/extra_profiles/first, then fromconf.d/snmp/profiles/; - A same-name Profile in
extra_profilescan extend its own file name to inherit the built-in Profile with the same name; - Multiple and nested inheritance are supported, but circular inheritance is not allowed;
- Metrics, dynamic tags, and static tags are appended during merging;
- A metadata field defined by the current Profile is not overwritten by inherited content;
- Do not inherit a template that an upper-level Profile already includes, or duplicate metrics and tags may be generated;
- More inherited modules result in more OID queries. Select modules according to the MIBs supported by the device.
sysObjectID Matching¶
Exact match:
Wildcard match:
Match multiple models:
When multiple Profiles match, DataKit selects the more specific rule. Different Profiles must not define the same sysobjectid. Use vendor- or product-specific values whenever possible to prevent a broad rule from matching unrelated devices.
For example, 1.3.6.1.4.1.8072.3.2.10 is a common Net-SNMP Linux sysObjectID, not a value exclusive to a specific device vendor.
Scalar Metrics¶
A scalar has one value and is defined with symbol. Scalar OIDs usually end with .0:
metrics:
- MIB: VENDOR-SYSTEM-MIB
symbol:
OID: 1.3.6.1.4.1.99999.1.2.0
name: vendor.system.cpu_usage
metric_type: gauge
Table Metrics¶
A table contains multiple rows. Use symbols to define the columns to collect and metric_tags to distinguish each row:
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: vendor.interface.in_octets
metric_type: monotonic_count
- OID: 1.3.6.1.2.1.2.2.1.16
name: vendor.interface.out_octets
metric_type: monotonic_count
metric_tags:
- symbol:
OID: 1.3.6.1.2.1.31.1.1.1.1
name: ifName
tag: interface
A table must have at least one tag that distinguishes its rows. Otherwise, multiple rows may have identical tags and only one row will be retained.
Tags can also be generated from the OID row index. index starts at 1:
For a composite row index of 3.24, the following configuration generates slot:3 and port:24:
Convert String Values to Numbers¶
Metric field values must be numeric. A numeric String/OCTET STRING such as "52.20" can be converted directly. If the value contains a unit or other characters, use extract_value to extract the first capture group.
For a device value of STRING: "5331MB":
- OID: 1.3.6.1.4.1.99999.2.1.4
name: vendor.disk.used
extract_value: '^([0-9]+[.]?[0-9]*)MB$'
metric_type: gauge
For a device value of STRING: "52.20%":
- OID: 1.3.6.1.4.1.99999.2.1.6
name: vendor.disk.used_percent
extract_value: '^([0-9]+[.]?[0-9]*)%?$'
metric_type: gauge
Notes:
- The regular expression must contain at least one capture group. DataKit only uses the first group;
- Enclose regular expressions in single quotes and use
^and$to match the complete value; - Go regular expression syntax is used. Lookahead and lookbehind are not supported;
- A value is not reported when the regular expression does not match;
- Plain text String values should be configured as tags or metadata instead of time-series metric values.
Metric Types and Value Scaling¶
The following metric_type values are recommended for custom Profiles:
| Type | Use Case |
|---|---|
gauge |
Current values that can increase or decrease, such as utilization, temperature, capacity, and connection count |
monotonic_count |
Monotonically increasing cumulative values, such as byte, packet, and request counts |
metric_type can be configured on an individual symbol, or at the table metric root to apply to all its symbols. A value configured on an individual symbol takes precedence. When omitted, DataKit infers the type from the SNMP return type and uses gauge when it cannot infer a type.
Use scale_factor for numeric conversion. For example, if the device returns 5234 but the actual value is 52.34%:
scale_factor only affects the final reported metric value. For a String metric, use extract_value first and then apply scale_factor.
Report a Fixed Value of 1¶
When a table represents a set of entities but has no suitable numeric column, use constant_value_one to report a fixed value of 1 for every row:
metrics:
- MIB: VENDOR-DISK-MIB
table:
OID: 1.3.6.1.4.1.99999.3.1
name: vendorDiskTable
symbols:
- name: vendor.disk.present
constant_value_one: true
metric_tags:
- symbol:
OID: 1.3.6.1.4.1.99999.3.1.1
name: diskName
tag: disk_name
- symbol:
OID: 1.3.6.1.4.1.99999.3.1.2
name: diskState
tag: disk_state
mapping:
1: normal
2: warning
3: failed
constant_value_one can only be used in table symbols, not scalar metrics. Do not configure an OID for this symbol, but configure its name and at least one OID-based metric_tags.symbol without index_transform, so DataKit can discover the table rows.
Tags¶
Use root-level static_tags to add fixed tags:
Root-level metric_tags generate dynamic tags from scalar OIDs and apply them to device metrics:
Within a table, metric_tags can use mapping to convert raw values into readable tag values:
metric_tags:
- symbol:
OID: 1.3.6.1.4.1.99999.3.1.2
name: diskState
tag: disk_state
mapping:
1: normal
2: warning
3: failed
Use match and tags to generate multiple tags from one table column value:
metric_tags:
- symbol:
OID: 1.3.6.1.4.1.99999.4.1.2
name: interfaceLabel
match: '^([A-Za-z]+)-([0-9]+)$'
tags:
interface_type: '$1'
interface_number: '$2'
For a raw value of ethernet-12, this generates interface_type:ethernet and interface_number:12. A non-empty tags mapping is required when match is configured. No tag is generated when the regular expression does not match.
When the metric table and tag source table use different index structures, use index_transform to extract and rebuild the index:
metric_tags:
- symbol:
OID: 1.3.6.1.4.1.99999.5.1.2
name: parentName
index_transform:
- start: 1
end: 2
- start: 6
end: 7
tag: parent_name
For a current index of 1.2.3.4.5.6.7.8, the transformed index is 2.3.7.8. Both start and end are zero-based, and the value at end is included. This option is only needed for cross-table association.
Metadata¶
A custom Profile can add device metadata through metadata.device. Supported fields are name, description, sys_object_id, location, serial_number, vendor, version, product_name, model, os_name, os_version, os_hostname, and type. A field can obtain its value from a scalar OID or use a fixed value:
metadata:
device:
fields:
name:
symbol:
OID: 1.3.6.1.2.1.1.5.0
name: sysName
serial_number:
symbol:
OID: 1.3.6.1.4.1.99999.1.1.0
name: vendorSerialNumber
vendor:
value: vendor_name
type:
value: router
A field can define multiple candidate symbols. DataKit uses the first OID that returns a value. Use match_pattern and match_value to extract or replace text:
metadata:
device:
fields:
model:
symbols:
- OID: 1.3.6.1.4.1.99999.1.2.0
name: vendorModel
- OID: 1.3.6.1.2.1.1.1.0
name: sysDescr
match_pattern: 'Model[=: ]+([A-Za-z0-9._-]+)'
match_value: '$1'
When match_value is omitted, the first capture group $1 is used. If the regular expression does not match, DataKit tries the next candidate symbol.
After inheriting _generic-if.yaml or generic-router.yaml, common interface metadata is already included and usually does not need to be configured again.
Metric Naming¶
Metric names are converted before reporting according to these rules:
- If the name contains an underscore
_, all dots.are replaced with underscores_; - If the name contains no underscore
_, dots.are removed and the first letter after each dot is converted to uppercase; - A name without dots
.remains unchanged.
Examples:
Profile name |
Reported Field Name |
|---|---|
sangfor.disk.used |
sangforDiskUsed |
sangfor.disk.used_percent |
sangfor_disk_used_percent |
vendor.interface.in_octets |
vendor_interface_in_octets |
cpu_usage |
cpu_usage |
The same conversion applies to tag keys but not tag values.
Use one naming style consistently within a Profile. A dot-separated name without underscores, such as vendor.disk.used, or an underscore name without dots, such as vendor_disk_used, can be used. Avoid mixing dots and underscores because all dots will then be converted to underscores. Existing built-in Profiles commonly use names such as huawei.hwEntityTemperature, which is reported as huaweiHwEntityTemperature.
Complete Example¶
The following example inherits common router metrics and collects device metadata, a numeric scalar, String disk metrics, and an entity-presence metric:
extends:
- generic-router.yaml
sysobjectid: 1.3.6.1.4.1.99999.1.2
device:
vendor: vendor_name
metadata:
device:
fields:
model:
symbol:
OID: 1.3.6.1.4.1.99999.1.1.0
name: vendorModel
metrics:
- MIB: VENDOR-SYSTEM-MIB
symbol:
OID: 1.3.6.1.4.1.99999.1.2.0
name: vendor.system.cpu_usage
metric_type: gauge
- MIB: VENDOR-DISK-MIB
table:
OID: 1.3.6.1.4.1.99999.2.1
name: vendorDiskTable
symbols:
- OID: 1.3.6.1.4.1.99999.2.1.4
name: vendor.disk.used
extract_value: '^([0-9]+[.]?[0-9]*)MB$'
metric_type: gauge
- OID: 1.3.6.1.4.1.99999.2.1.6
name: vendor.disk.used_percent
extract_value: '^([0-9]+[.]?[0-9]*)%?$'
metric_type: gauge
- name: vendor.disk.present
constant_value_one: true
metric_tags:
- index: 1
tag: disk_index
- symbol:
OID: 1.3.6.1.4.1.99999.2.1.2
name: diskName
tag: disk_name
Validation and Troubleshooting¶
Common issues:
- Profile not matched: Check the device's actual
sysObjectID, wildcard range, and whether a more specific matching rule exists; - YAML not loaded: Check the file extension, file name, indentation, and Profile validation errors in the DataKit logs;
- No OID data: Run
snmpgetorsnmpwalkwith the same SNMP version and authentication settings as DataKit; - String metric not reported: Check that
extract_valuecontains a capture group and matches the complete actual value; - Only one table row reported: Add
metric_tagsthat distinguish every row; - Metric skipped: Confirm that the final value can be converted to a number, and check
metric_typeandscale_factor.
Zabbix format¶
- Config
[[inputs.snmp.zabbix_profiles]]
profile_name = "xxx.yaml"
ip_list = ["ip1", "ip2"]
class = "server"
[[inputs.snmp.zabbix_profiles]]
profile_name = "yyy.xml"
ip_list = ["ip3", "ip4"]
class = "switch"
# ...
profile_name can be full path file name or only file name.
If only file name, the path is ./conf.d/snmp/userprofiles/
profile_name can from Zabbix official, or from community .
You can modify the yaml or xml.
-
AutoDiscovery
-
Automatic discovery matches the collection rules in the imported multiple yaml configurations and performs collection.
-
Please try to configure according to class C. Configuring class B may be slower.
-
If automatic discovery fails to match yaml, it is because these yaml does not contain the manufacturer's signature code of the collected device.
- Add an oid message to the items of yaml to guide the automatic matching process.
zabbix_export: templates: - items: - snmp_oid: 1.3.6.1.4.1.2011.5.2.1.1.1.1.6.114.97.100.105.117.115.0.0.0.0- The oid to be added is obtained by executing the following command. .0.0.0.0 is added at the end to prevent the generation of useless indicators.
-
Prometheus format¶
-
Config
[[inputs.snmp.prom_profiles]] profile_name = "xxx.yml" ip_list = ["ip1", "ip2"] class = "server" [[inputs.snmp.prom_profiles]] profile_name = "yyy.yml" ip_list = ["ip3", "ip4"] class = "firewall" # ...Please refer to the snmp.yml file of Prometheus snmp_exporter for the profile. It is recommended to split module of different classes into different .yml configurations.
Prometheus profile allows you to configure a separate community name for a module. This community name takes precedence over the community name configured for the input.
-
AutoDiscovery
The SNMP collector can discovery instance through Consul service, and the service injection format can be found on prom official website。
Configure SNMP device¶
When SNMP devices are in the default, the general SNMP protocol is closed, you need to enter the management interface to open manually. At the same time, it is necessary to select the protocol version and fill in the corresponding information according to the actual situation.
Tip
Some devices require additional configuration to release SNMP for security, which varies from device to device. For example, Huawei is a firewall, so it is necessary to check SNMP in "Enable Access Management" to release it. You can use the snmpwalk command to test whether the acquisition side and the device side are configured to connect successfully(These commands runs on the host which DataKit running on):
# Applicable v2c version
snmpwalk -O bentU -v 2c -c [community string] [SNMP_DEVICE_IP] 1.3.6
# Applicable v3 version
snmpwalk -v 3 -u user -l authPriv -a sha -A [AUTH_PASSWORD] -x aes -X [ENCRYPT_PASSWORD] [SNMP_DEVICE_IP] 1.3.6
If there is no problem with the configuration, the command will output a large amount of data. snmpwalk is a test tool running on the collection side, which comes with MacOS. Linux installation method:
SNMPv3 Example¶
We take an snmpd service on Linux as an example to demonstrate how to collecting SNMPv3 data.
-
On an Ubuntu machine, install the
snmpdservice: -
Prepare a simple snmpd.conf configuration as follows:
-
Stop the
snmpdservice first, then manually start thesnmpdprocess: -
Use the
snmpwalkcommand to test, which is expected to output extensive OID device information: -
If the
snmpwalkcommand succeeds, enable the collector on DataKit to collect metrics via SNMPv3. The key configuration is as follows:conf.d/snmp/snmp.confspecific_devices = ["127.0.0.1"] # Do not use "localhost" here snmp_version = 3 port = 161 v3_user = "snmpv3user1" v3_auth_protocol = "SHA" # MD5/SHA/SHA224/SHA256/SHA384/SHA512 or empty v3_auth_key = "authPassAgent1" v3_priv_protocol = "AES" # DES/AES/AES192/AES192C/AES256/AES256C or empty v3_priv_key = "privPassAgent1" # v3_context_engine_id = "" # Optional # v3_context_name = "" # Optional
LLDP Network Topology Collection¶
DataKit supports collecting LLDP (Link Layer Discovery Protocol) neighbor information from network devices via SNMP protocol for automatic network topology construction.
What is LLDP¶
LLDP is a standardized link-layer protocol that allows network devices (such as switches and routers) to broadcast their identity and capability information to directly connected neighbor devices. By collecting LLDP data, you can:
- Automatically discover network topology relationships
- Understand physical connection status between devices
- Obtain neighbor device port, hostname, system description, and other information
- Build visualized network topology diagrams
Enable LLDP Collection¶
Enable LLDP collection in DataKit's SNMP configuration:
[[inputs.snmp]]
## Enable LLDP topology collection
enable_lldp = true
## LLDP collection interval (optional, default 10 minutes)
lldp_interval = "10m"
Device Configuration Requirements¶
Network devices need to:
-
Enable LLDP
-
Configure SNMP access to LLDP MIB
Verify Configuration¶
Verify LLDP neighbors on device:
Verify SNMP can query LLDP data from DataKit host:
# SNMPv2c verification
snmpwalk -v2c -c [COMMUNITY_STRING] [DEVICE_IP] 1.0.8802.1.1.2.1.4.1
# SNMPv3 verification
snmpwalk -v3 -u [USERNAME] -l authPriv \
-a SHA -A [AUTH_PASSWORD] \
-x AES -X [PRIV_PASSWORD] \
[DEVICE_IP] 1.0.8802.1.1.2.1.4.1
Metric¶
For all of the following data collections, the global election tags will added automatically, we can add extra tags in [inputs.snmp.tags] if needed:
Note
All the following measurements and their metrics contain only some common fields, some device-specific fields, and some additional fields will be added according to different configurations and device models.
snmp_metric¶
SNMP device metric data.
| Tags & Fields | Description |
|---|---|
| cpu ( tag) |
CPU index. Optional. |
| device_namespace ( tag) |
Device namespace. |
| device_type ( tag) |
Device vendor. |
| device_vendor ( tag) |
Device vendor. |
| entity_name ( tag) |
Device entity name. Optional. |
| host ( tag) |
Device host, replace with IP. |
| interface ( tag) |
Device interface. Optional. |
| interface_alias ( tag) |
Device interface alias. Optional. |
| ip ( tag) |
Device IP. |
| mac_addr ( tag) |
Device MAC address. Optional. |
| mem ( tag) |
Memory index. Optional. |
| mem_pool_name ( tag) |
Memory pool name. Optional. |
| name ( tag) |
Device name and IP. |
| oid ( tag) |
OID. |
| power_source ( tag) |
Power source. Optional. |
| power_status_descr ( tag) |
Power status description. Optional. |
| sensor_id ( tag) |
Sensor ID. Optional. |
| sensor_type ( tag) |
Sensor type. Optional. |
| snmp_host ( tag) |
Device host. |
| snmp_index ( tag) |
Macro value. Optional. |
| snmp_profile ( tag) |
Device SNMP profile file. |
| snmp_value ( tag) |
Macro value. Optional. |
| sys_name ( tag) |
System name. |
| sys_object_id ( tag) |
System object id. |
| temp_index ( tag) |
Temperature index. Optional. |
| temp_state ( tag) |
Temperature state. Optional. |
| unit_alias ( tag) |
Macro value. Optional. |
| unit_class ( tag) |
Macro value. Optional. |
| unit_desc ( tag) |
Macro value. Optional. |
| unit_locale ( tag) |
Macro value. Optional. |
| unit_name ( tag) |
Macro value. Optional. |
| unit_status ( tag) |
Macro value. Optional. |
| unit_type ( tag) |
Macro value. Optional. |
| cieIfInputQueueDrops | [Cisco only] (Shown as packet) The number of input packets dropped. Type: float | (gauge) Unit: count |
| cieIfLastInTime | [Cisco only] (Shown as millisecond) The elapsed time in milliseconds since the last protocol input packet was received. Type: float | (gauge) Unit: time,ms |
| cieIfLastOutTime | [Cisco only] (Shown as millisecond) The elapsed time in milliseconds since the last protocol output packet was transmitted. Type: float | (gauge) Unit: time,ms |
| cieIfOutputQueueDrops | [Cisco only] (Shown as packet) The number of output packets dropped by the interface even though no error was detected to prevent them being transmitted. Type: float | (gauge) Unit: count |
| cieIfResetCount | [Cisco only] The number of times the interface was internally reset and brought up. Type: float | (count) Unit: count |
| ciscoEnvMonFanState | [Cisco only] The current state of the fan being instrumented. Type: float | (gauge) Unit: count |
| ciscoEnvMonSupplyState | [Cisco only] The current state of the power supply being instrumented. Type: float | (gauge) Unit: count |
| ciscoEnvMonTemperatureStatusValue | [Cisco only] The current value of the test point being instrumented. Type: float | (gauge) Unit: count |
| ciscoMemoryPoolFree | [Cisco only] Indicates the number of bytes from the memory pool that are currently unused on the managed device. Type: float | (gauge) Unit: count |
| ciscoMemoryPoolLargestFree | [Cisco only] Indicates the largest number of contiguous bytes from the memory pool that are currently unused on the managed device. Type: float | (gauge) Unit: count |
| ciscoMemoryPoolUsed | [Cisco only] Indicates the number of bytes from the memory pool that are currently in use by applications on the managed device. Type: float | (gauge) Unit: count |
| cpmCPUTotal1minRev | [Cisco only] [Shown as percent] The overall CPU busy percentage in the last 1 minute period. Type: float | (gauge) Unit: percent,percent |
| cpmCPUTotalMonIntervalValue | [Cisco only] (Shown as percent) The overall CPU busy percentage in the last cpmCPUMonInterval period. Type: float | (gauge) Unit: percent,percent |
| cpuStatus | CPU status. Type: float | (gauge) Unit: bool |
| cpuTemperature | The Temperature of cpu. Type: float | (gauge) Unit: temperature,C |
| cpuUsage | (Shown as percent) Percentage of CPU currently being used. Type: float | (gauge) Unit: percent,percent |
| cswStackPortOperStatus | [Cisco only] The state of the stack port. Type: float | (gauge) Unit: count |
| cswSwitchState | [Cisco only] The current state of a switch. Type: float | (gauge) Unit: count |
| current | The current of item. Type: float | (gauge) Unit: unknown |
| diskAvailable | Number of disk available. Type: float | (gauge) Unit: digital,B |
| diskFree | (Shown as percent) The percentage of disk not being used. Type: float | (gauge) Unit: percent,percent |
| diskTotal | Total of disk size. Type: float | (gauge) Unit: digital,B |
| diskUsage | (Shown as percent) The percentage of disk currently being used. Type: float | (gauge) Unit: percent,percent |
| diskUsed | Number of disk currently being used. Type: float | (gauge) Unit: digital,B |
| entSensorValue | [Cisco only] The most recent measurement seen by the sensor. Type: float | (gauge) Unit: count |
| fanSpeed | The fan speed. Type: float | (gauge) Unit: RPM |
| fanStatus | The fan status. Type: float | (gauge) Unit: bool |
| ifAdminStatus | The desired state of the interface. Type: float | (gauge) Unit: N/A |
| ifBandwidthInUsageDiff | Inbound bandwidth usage scaled-value increment in the collection interval. Type: float | (gauge) Unit: N/A |
| ifBandwidthInUsageRate | (Shown as percent) The percent rate of used received bandwidth. Type: float | (gauge) Unit: percent,percent |
| ifBandwidthOutUsageDiff | Outbound bandwidth usage scaled-value increment in the collection interval. Type: float | (gauge) Unit: N/A |
| ifBandwidthOutUsageRate | (Shown as percent) The percent rate of used sent bandwidth. Type: float | (gauge) Unit: percent,percent |
| ifHCInBroadcastPkts | (Shown as packet) The number of packets delivered by this sub-layer to a higher (sub-)layer that were addressed to a broadcast address at this sub-layer. Type: float | (count) Unit: count |
| ifHCInMulticastPkts | (Shown as packet) The number of packets delivered by this sub-layer to a higher (sub-)layer which were addressed to a multicast address at this sub-layer. Type: float | (count) Unit: count |
| ifHCInOctets | (Shown as byte) The total number of octets received on the interface including framing characters. Type: float | (count) Unit: count |
| ifHCInOctetsDiff | Inbound octet increment in the collection interval. Type: float | (gauge) Unit: digital,B |
| ifHCInOctetsRate | (Shown as byte) The total number of octets received on the interface including framing characters. Type: float | (gauge) Unit: digital,B |
| ifHCInPkts | (Shown as packet) The number of packets delivered by this sub-layer to a higher (sub-)layer that were not addressed to a multicast or broadcast address at this sub-layer. Type: float | (count) Unit: count |
| ifHCInUcastPkts | (Shown as packet) The number of packets delivered by this sub-layer to a higher (sub-)layer that were not addressed to a multicast or broadcast address at this sub-layer. Type: float | (count) Unit: count |
| ifHCOutBroadcastPkts | (Shown as packet) The total number of packets that higher-level protocols requested be transmitted that were addressed to a broadcast address at this sub-layer, including those that were discarded or not sent. Type: float | (count) Unit: count |
| ifHCOutMulticastPkts | (Shown as packet) The total number of packets that higher-level protocols requested be transmitted that were addressed to a multicast address at this sub-layer including those that were discarded or not sent. Type: float | (count) Unit: count |
| ifHCOutOctets | (Shown as byte) The total number of octets transmitted out of the interface including framing characters. Type: float | (count) Unit: count |
| ifHCOutOctetsDiff | Outbound octet increment in the collection interval. Type: float | (gauge) Unit: digital,B |
| ifHCOutOctetsRate | (Shown as byte) The total number of octets transmitted out of the interface including framing characters. Type: float | (gauge) Unit: count |
| ifHCOutPkts | (Shown as packet) The total number of packets higher-level protocols requested be transmitted that were not addressed to a multicast or broadcast address at this sub-layer including those that were discarded or not sent. Type: float | (count) Unit: count |
| ifHCOutUcastPkts | (Shown as packet) The total number of packets higher-level protocols requested be transmitted that were not addressed to a multicast or broadcast address at this sub-layer including those that were discarded or not sent. Type: float | (count) Unit: count |
| ifHighSpeed | An estimate of the interface's current bandwidth in units of 1,000,000 bits per second, or the nominal bandwidth. Type: float | (gauge) Unit: count |
| ifInDiscards | (Shown as packet) The number of inbound packets chosen to be discarded even though no errors had been detected to prevent them being deliverable to a higher-layer protocol. Type: float | (count) Unit: count |
| ifInDiscardsDiff | Inbound discard packet increment in the collection interval. Type: float | (gauge) Unit: count |
| ifInDiscardsRate | (Shown as packet) The number of inbound packets chosen to be discarded even though no errors had been detected to prevent them being deliverable to a higher-layer protocol. Type: float | (gauge) Unit: count |
| ifInErrors | (Shown as packet) The number of inbound packets that contained errors preventing them from being deliverable to a higher-layer protocol. Type: float | (count) Unit: count |
| ifInErrorsDiff | Inbound error packet increment in the collection interval. Type: float | (gauge) Unit: count |
| ifInErrorsRate | (Shown as packet) The number of inbound packets that contained errors preventing them from being deliverable to a higher-layer protocol. Type: float | (gauge) Unit: count |
| ifNetConnStatus | The net connection status. Type: float | (gauge) Unit: bool |
| ifNetStatus | The net status. Type: float | (gauge) Unit: bool |
| ifNumber | Number of interface. Type: float | (gauge) Unit: count |
| ifOperStatus | (Shown as packet) The current operational state of the interface. Type: float | (gauge) Unit: count |
| ifOutDiscards | (Shown as packet) The number of outbound packets chosen to be discarded even though no errors had been detected to prevent them being transmitted. Type: float | (count) Unit: count |
| ifOutDiscardsDiff | Outbound discard packet increment in the collection interval. Type: float | (gauge) Unit: count |
| ifOutDiscardsRate | (Shown as packet) The number of outbound packets chosen to be discarded even though no errors had been detected to prevent them being transmitted. Type: float | (gauge) Unit: count |
| ifOutErrors | (Shown as packet) The number of outbound packets that could not be transmitted because of errors. Type: float | (count) Unit: count |
| ifOutErrorsDiff | Outbound error packet increment in the collection interval. Type: float | (gauge) Unit: count |
| ifOutErrorsRate | (Shown as packet) The number of outbound packets that could not be transmitted because of errors. Type: float | (gauge) Unit: count |
| ifSpeed | An estimate of the interface's current bandwidth in bits per second, or the nominal bandwidth. Type: float | (gauge) Unit: count |
| ifStatus | The interface status. Type: float | (gauge) Unit: bool |
| itemAvailable | Item available. Type: float | (gauge) Unit: unknown |
| itemFree | (Shown as percent) Item not being used. Type: float | (gauge) Unit: percent,percent |
| itemTotal | Item total. Type: float | (gauge) Unit: unknown |
| itemUsage | (Shown as percent) Item being used. Type: float | (gauge) Unit: percent,percent |
| itemUsed | Item being used. Type: float | (gauge) Unit: unknown |
| memoryAvailable | (Shown as byte) Number of memory available. Type: float | (gauge) Unit: digital,B |
| memoryFree | (Shown as percent) The percentage of memory not being used. Type: float | (gauge) Unit: percent,percent |
| memoryTotal | (Shown as byte) Number of bytes of memory. Type: float | (gauge) Unit: digital,B |
| memoryUsage | (Shown as percent) The percentage of memory currently being used. Type: float | (gauge) Unit: percent,percent |
| memoryUsed | (Shown as byte) Number of bytes of memory currently being used. Type: float | (gauge) Unit: digital,B |
| netUptime | (in hundredths of a second, sysUpTime raw) net uptime. Type: float | (gauge) Unit: count |
| power | The power of item. Type: float | (gauge) Unit: unknown |
| powerStatus | The power of item. Type: float | (gauge) Unit: unknown |
| sysUpTimeInstance | The time (in hundredths of a second) since the network management portion of the system was last re-initialized. Type: float | (gauge) Unit: count |
| tcpActiveOpens | The number of times that TCP connections have made a direct transition to the SYN-SENT state from the CLOSED state. Type: float | (count) Unit: count |
| tcpAttemptFails | The number of times that TCP connections have made a direct transition to the CLOSED state from either the SYN-SENT state or the SYN-RCVD state, or to the LISTEN state from the SYN-RCVD state. Type: float | (count) Unit: count |
| tcpCurrEstab | The number of TCP connections for which the current state is either ESTABLISHED or CLOSE-WAIT. Type: float | (gauge) Unit: count |
| tcpEstabResets | The number of times that TCP connections have made a direct transition to the CLOSED state from either the ESTABLISHED state or the CLOSE-WAIT state. Type: float | (count) Unit: count |
| tcpInErrs | (Shown as segment) The total number of segments received in error (e.g., bad TCP checksums). Type: float | (count) Unit: count |
| tcpOutRsts | (Shown as segment) The number of TCP segments sent containing the RST flag. Type: float | (count) Unit: count |
| tcpPassiveOpens | (Shown as connection) The number of times TCP connections have made a direct transition to the SYN-RCVD state from the LISTEN state. Type: float | (count) Unit: count |
| tcpRetransSegs | (Shown as segment) The total number of segments retransmitted; that is, the number of TCP segments transmitted containing one or more previously transmitted octets. Type: float | (count) Unit: count |
| temperature | The Temperature of item. Type: float | (gauge) Unit: temperature,C |
| udpInErrors | (Shown as datagram) The number of received UDP datagram that could not be delivered for reasons other than the lack of an application at the destination port. Type: float | (count) Unit: count |
| udpNoPorts | (Shown as datagram) The total number of received UDP datagram for which there was no application at the destination port. Type: float | (count) Unit: count |
| uptime | (in hundredths of a second, sysUpTime raw) uptime. Type: float | (gauge) Unit: count |
| uptimeTimestamp | uptime timestamp. Type: float | (gauge) Unit: timeStamp,sec |
| voltage | The Volt of item. Type: float | (gauge) Unit: volt |
| voltageStatus | The voltage status of item. Type: float | (gauge) Unit: bool |
Object¶
snmp_object¶
SNMP device object data.
| Tags & Fields | Description |
|---|---|
| device_hostname ( tag) |
Device hostname from SNMP (e.g. sysName). |
| device_type ( tag) |
Device type (e.g. router, switch, pdu). |
| device_vendor ( tag) |
Device vendor. |
| host ( tag) |
Device host, replace with IP. |
| ip ( tag) |
Device IP. |
| name ( tag) |
Device name, replace with IP. |
| snmp_host ( tag) |
Device host. |
| snmp_profile ( tag) |
Device SNMP profile file. |
| all | Device all data (JSON format). (Deprecated) Type: string | (string) Unit: N/A |
| cpus | Device CPUs (JSON format). Type: string | (string) Unit: N/A |
| device_meta | Device meta data (JSON format). Type: string | (string) Unit: N/A |
| interfaces | Device network interfaces (JSON format). Type: string | (string) Unit: N/A |
| mem_pool_names | Device memory pool names (JSON format). Type: string | (string) Unit: N/A |
| mems | Device memories (JSON format). Type: string | (string) Unit: N/A |
| sensors | Device sensors (JSON format). Type: string | (string) Unit: N/A |
| uptime | Device uptime in seconds. Type: float | (gauge) Unit: time,s |
Logging¶
snmp_lldp¶
SNMP LLDP (Link Layer Discovery Protocol) topology data.
| Tags & Fields | Description |
|---|---|
| local_chassis_id ( tag) |
Chassis ID of the local device (string). |
| local_chassis_subtype ( tag) |
Local chassis ID subtype string (e.g., 'mac_address', 'network_address', 'chassis_component', 'locally_assigned', etc.). |
| local_interface ( tag) |
Local interface name. |
| local_ip ( tag) |
IP address of the local device (string). |
| remote_chassis_id ( tag) |
Chassis ID of the remote device (string). |
| remote_chassis_subtype ( tag) |
Remote chassis ID subtype string (e.g., 'mac_address', 'network_address', 'chassis_component', 'locally_assigned', etc.). |
| remote_interface ( tag) |
Interface ID of the remote device. |
| remote_port_subtype ( tag) |
Remote port ID subtype string (e.g., 'mac_address', 'network_address', 'interface_alias', 'agent_circuit_id', 'locally_assigned', etc.). |
| remote_system | Name of the remote system. Type: string | (string) Unit: N/A |
| remote_system_desc | Description of the remote system. Type: string | (string) Unit: N/A |
FAQ¶
How dows DataKit find devices?¶
DataKit supports "Specified device mode" and "auto-discovery mode" two modes. The two modes can enabled at the same time.
In "specified device mode", DataKit communicates with the specified IP device using the SNMP protocol to know its current online status.
In "auto-discovery mode", DataKit sends SNMP packets to all address in the specified IP segment one by one, and if the response matches the corresponding profile, DataKit assumes that there is a SNMP device on that IP.
Device Not Supported¶
DataKit collects common baseline metrics from SNMP devices. If the collected data does not contain the required metrics, you may need to add a custom Profile.
To do this, obtain the OID manual for the device model from the vendor's website.
Can't see any metrics after configuration?¶
Try loosening ACLs/firewall rules for your devices.
Run snmpwalk -O bentU -v 2c -c <COMMUNITY_STRING> <IP_ADDRESS>:<PORT> 1.3.6 from the host DataKit is running on. If you get a timeout without any response, there is likely something blocking DataKit from collecting metrics from your device.