SNMP trap input plugin
- A component of thesnmp integration plugin
- Integration version: v4.2.1
- Released on: 2026-01-16
- Changelog
For questions about the plugin, open a topic in theDiscuss forums. For bugs or feature requests, open an issue inGithub. For the list of Elastic supported plugins, please consult theElastic Support Matrix.
Migrating tologstash-integration-snmp from stand-aloneinput-snmptrap
Thelogstash-input-snmptrap plugin is now a component of thelogstash-integration-snmp plugin which is bundled with Logstash 8.15.0 by default. This integrated plugin package provides better alignment in snmp processing, better resource management, easier package maintenance, and a smaller installation footprint.
Before you upgrade to Logstash 8.15.0, be aware ofbehavioral and mapping differences between current stand-alone plugins and the new versions included inintegration-snmp. If you need to maintain current mappings for theinput-snmptrap plugin, you have options topreserve existing behavior.
Thelogstash-input-snmptrap plugin reads SNMP trap messages as events.
Resultingmessage field resembles:
{"agent_addr":"192.168.1.40", "generic_trap":6, "specific_trap":15511, "enterprise":"1.3.6.1.2.1.1.1", "variable_bindings":{"1.3.6.1.2.1.1.2.0":"test one", "1.3.6.1.2.1.1.1.0":"test two"}, "type":"V1TRAP", "community":"public", "version":1, "timestamp":1500}Because SNMP data has specific field names based on OIDs, we recommend setting atarget. The source host field changes based onecs_compatibility.
| ECS disabled | ECS v1, v8 | Availability | Description |
| [host] | [host][ip] | Always | IP address of the host e.g. "192.168.1.11" |
This plugin also adds the trap PDU metadata to each event. The value is stored in the@metadata where it can be used by other plugins in the pipeline.
| ECS disabled, v1, v8 | Availability | Description | ||
| [@metadata][input][snmptrap][pdu][agent_addr] | SNMPv1 | Network address of the object generating the trap | ||
| [@metadata][input][snmptrap][pdu][community] | SNMPv1SNMPv2c | SNMP community | ||
| [@metadata][input][snmptrap][pdu][context_engine_id] | SNMPv3 | SNMP context engine ID | ||
| [@metadata][input][snmptrap][pdu][context_name] | SNMPv3 | SNMP context name | ||
| [@metadata][input][snmptrap][pdu][enterprise] | SNMPv1 | Type of object generating the trap | ||
| [@metadata][input][snmptrap][pdu][error_index] | SNMPv2cSNMPv3 | Provides additional information by identifying which variable binding in the list caused the error | ||
| [@metadata][input][snmptrap][pdu][error_status] | SNMPv2cSNMPv3 | Error status code | ||
| [@metadata][input][snmptrap][pdu][error_status_text] | SNMPv2cSNMPv3 | Error status code description | ||
| [@metadata][input][snmptrap][pdu][generic_trap] | SNMPv1 | Generic trap type | ||
| [@metadata][input][snmptrap][pdu][request_id] | SNMPv2cSNMPv3 | Request ID | ||
| [@metadata][input][snmptrap][pdu][specific_trap] | SNMPv1 | Specific code, presented even if the generic_trap is not enterprise specific | ||
| [@metadata][input][snmptrap][pdu][timestamp] | SNMPv1 | Time elapsed between the last (re)initialization of the network entity and the generation of the trap | ||
| [@metadata][input][snmptrap][pdu][type] | Always | PDU type | ||
| [@metadata][input][snmptrap][pdu][variable_bindings] | Always | SNMP variable bindings values | ||
| [@metadata][input][snmptrap][pdu][version] | Always | SNMP version |
This plugin already includes the IETF MIBs (management information bases), and you do not need to import them. If you need additional MIBs, you need to import them. Check outImporting MIBs for info.
This plugin supports the following configuration options plus theCommon options described later.
| Setting | Input type | Required |
|---|---|---|
community | array | No |
ecs_compatibility | string | No |
host | string | No |
mib_paths | path | No |
oid_mapping_format | string, one of["default", "ruby_snmp", "dotted_string"] | No |
oid_map_field_values | boolean | Yes |
oid_path_length | number | No |
oid_root_skip | number | No |
port | number | No |
supported_transports | string | No |
supported_versions | string | No |
target | string | No |
threads | number | No |
use_provided_mibs | boolean | No |
yamlmibdir | string | Deprecated |
This plugin supports the following SNMPv3 authentication options.
| Setting | Input type | Required |
|---|---|---|
auth_pass | password | No |
auth_protocol | string, one of["md5", "sha", "sha2", "hmac128sha224", "hmac192sha256", "hmac256sha384", "hmac384sha512"] | No |
priv_pass | password | No |
priv_protocol | string, one of["des", "3des", "aes", "aes128", "aes192", "aes256", "aes256with3desKey"] | No |
security_level | string, one of["noAuthNoPriv", "authNoPriv", "authPriv"] | No |
security_name | string | No |
Also seeCommon options for a list of options supported by all input plugins.
- Value type isarray
- Default value is
["public"]
The SNMPv1 and SNMPv2c communities to listen for. To allow any community, set this config value to emptycommunity => [].
Examples
Listen forpublic andguest communities
input { snmptrap { community => ["public", "guest"] }}Listen for all communities
input { snmptrap { community => [] }}Value type isstring
Supported values are:
disabled: does not use ECS-compatible field names (fields might be set at the root of the event)v1,v8: avoids field names that might conflict with Elastic Common Schema (for example, thehostfield)
Default value depends on which version of Logstash is running:
- When Logstash provides a
pipeline.ecs_compatibilitysetting, its value is used as the default - Otherwise, the default value is
disabled.
- When Logstash provides a
Controls this plugin’s compatibility with theElastic Common Schema (ECS).
- Value type isstring
- Default value is
"0.0.0.0"
The address to listen on.
- Value type ispath
- There is no default value for this setting
Themib_paths option specifies the location of one or more imported MIB files. The value can be either a dir path containing the imported MIB (.dic,.yaml) files or a file path to a single MIB file.
- Value can be any of:
default,ruby_snmp,dotted_string - Default value is
"default"
Defines the mapping textual representation of an OID in the Logstash event: *default translates every identifier, using the MIBs resolved names, separated by dots. Example:1.3.6.1.2.1.1.2.0 is mapped asiso.org.dod.internet.mgmt.mib-2.system.sysObjectID.0 *ruby_snmp produces field names prefixed by the MIBs module name, followed by the latest resolved identifier name and unknowns values. Example:1.3.6.1.2.1.1.2.0 is mapped asSNMPv2-MIB::sysObjectID.0. *dotted_string maps fields using the standard dotted string representation, Example:1.3.6.1.2.1.1.2.0 is mapped as1.3.6.1.2.1.1.2.0
- Value type isboolean
- Default value is
false
Defines if the Logstash event fields values, which types areOID, are mapped using the configured OID textual representation set on theoid_mapping_format option.
- Value type isnumber
- Default value is
0
Theoid_root_skip option specifies the number of OID root digits to ignore in the event field name. For example, in a numeric OID like "1.3.6.1.2.1.1.1.0" the first 5 digits could be ignored by settingoid_root_skip => 5 which would result in a field name "1.1.1.0". Similarly when a MIB is used an OID such "1.3.6.1.2.mib-2.system.sysDescr.0" would become "mib-2.system.sysDescr.0"
- You can use this setting or
oid_path_length, but not both at the same time. - Use this setting only if
oid_mapping_formatis set todefault.
- Value type isnumber
- Default value is
0
Theoid_path_length option specifies the number of OID root digits to retain in the event field name. For example, in a numeric OID like "1.3.6.1.2.1.1.1.0" the last 2 digits could be retained by settingoid_path_length => 2 which would result in a field name "1.0". Similarly when a MIB is used an OID such "1.3.6.1.2.mib-2.system.sysDescr.0" would become "sysDescr.0"
- You can use this setting or
oid_root_skip, but not both at the same time. - Use this setting only if
oid_mapping_formatis set todefault.
- Value type isnumber
- Default value is
1062
The port to listen on. Remember that ports less than 1024 (privileged ports) may require root to use. hence the default of 1062.
- Value type isstring
- Allowed values are:
tcp,udp - Default value is
["udp"]
The supported transport protocols to listen on.
SNMP was originally designed for use with UDP as transport protocol and is the official recommendation. TCP is an optional transport mapping and can be enabled if needed. For more details on SNMP over TCP, please refer to theRFC-3430.
- Value type isstring
- Allowed values are:
1,2c,3 - Default value is
["1", "2c"]
The supported SNMP protocol versions to listen on. SNMP messages for versions that are either unsupported and/or disabled are automatically discarded.
- Value type isstring
- There is no default value for this setting
The name of the field under which SNMP payloads are assigned. If not specified data will be stored in the root of the event.
Setting a target is recommended whenecs_compatibility is enabled.
- Value type isnumber
- Default value is 75% of the number of CPU cores
The number of threads to use for processing the received SNMP trap messages.
- Value type isboolean
- Default value is
true
This plugin provides all IETF MIBs (management information bases), publicly available in thelibsmi version0.5.0. When enabled, it automatically loads the bundled MIBs and provides mapping of the numeric OIDs to MIB field names in the resulting event.
Deprecated in 4.0.0.
Replaced bymib_paths
- Value type isstring
- There is no default value for this setting.
directory of YAML MIB maps (same format ruby-snmp uses)
Asingle user can be configured. Multiple snmptrap input declarations will be needed if multiple SNMPv3 users are required. These options are required only if you are using SNMPv3.
- Value type ispassword
- There is no default value for this setting
Theauth_pass option specifies the SNMPv3 authentication passphrase or password.
Theauth_protocol option specifies the SNMPv3 authentication protocol or type
- Value can be any of:
md5,sha,sha2,hmac128sha224,hmac192sha256,hmac256sha384,hmac384sha512 - Note that
sha2andhmac192sha256are equivalent - There is no default value for this setting
- Value type ispassword
- There is no default value for this setting
Thepriv_pass option specifies the SNMPv3 encryption password.
- Value can be any of:
des,3des,aes,aes128,aes192,aes256,aes256with3desKey - Note that
aesandaes128are equivalent - There is no default value for this setting
Thepriv_protocol option specifies the SNMPv3 privacy/encryption protocol.
Value can be any of:
noAuthNoPriv: allows receiving traps messages without authentication or encryption.authNoPriv: trap messages must be authenticated according tosecurity_name/auth_protocol/auth_pass. Encrypted messages are allowed but not required.authPriv: trap messages must be both authenticated according tosecurity_name/auth_protocol/auth_passand encrypted according topriv_protocol/priv_pass.
The default value is
noAuthNoPriv.
Thesecurity_level option specifies the SNMPv3 security level between Authentication, No Privacy; Authentication, Privacy; or no Authentication, no Privacy.
- Value type isstring
- There is no default value for this setting
Thesecurity_name option specifies the SNMPv3 security name or user name.
Specifying SNMPv3 traps settings
input { snmptrap { supported_versions => ['3'] security_name => "mySecurityName" auth_protocol => "sha" auth_pass => "ShaPassword" priv_protocol => "aes" priv_pass => "AesPasword" security_level => "authPriv" }}These configuration options are supported by all input plugins:
| Setting | Input type | Required |
|---|---|---|
add_field | hash | No |
codec | codec | No |
enable_metric | boolean | No |
id | string | No |
tags | array | No |
type | string | No |
- Value type ishash
- Default value is
{}
Add a field to an event
- Value type iscodec
- Default value is
"plain"
The codec used for input data. Input codecs are a convenient method for decoding your data before it enters the input, without needing a separate filter in your Logstash pipeline.
- Value type isboolean
- Default value is
true
Disable or enable metric logging for this specific plugin instance by default we record all the metrics we can, but you can disable metrics collection for a specific plugin.
- Value type isstring
- There is no default value for this setting.
Add a uniqueID to the plugin configuration. If no ID is specified, Logstash will generate one. It is strongly recommended to set this ID in your configuration. This is particularly useful when you have two or more plugins of the same type, for example, if you have 2 snmptrap inputs. Adding a named ID in this case will help in monitoring Logstash when using the monitoring APIs.
input { snmptrap { id => "my_plugin_id" }}- Value type isarray
- There is no default value for this setting.
Add any number of arbitrary tags to your event.
This can help with processing later.
- Value type isstring
- There is no default value for this setting.
Add atype field to all events handled by this input.
Types are used mainly for filter activation.
The type is stored as part of the event itself, so you can also use the type to search for it in Kibana.
If you try to set a type on an event that already has one (for example when you send an event from a shipper to an indexer) then a new input will not override the existing type. A type set at the shipper stays with that event for its life even when sent to another Logstash server.