All Products
Search
Document Center

Simple Log Service:Collect SNMP data from servers

Last Updated:Jul 03, 2025

This topic describes how to use the input_snmp plug-in of Logtail to collect Simple Network Management Protocol (SNMP) data from servers.

Prerequisites

A server is available for Logtail installation. The server must meet the following requirements:

  • An SNMP agent runs on the server.

  • The port that is required by snmpget is enabled on the server.

  • The server supports the snmptranslate and snmptable commands.

Procedure

  1. Log on to the Simple Log Service console.

  2. In the Import Data section, select Custom Data Plug-in.

  3. Select a project and a Logstore. Then, click Next.

  4. Create a machine group.

    • If a machine group is available, click Use Existing Machine Groups.

    • If no machine group is available, perform the following steps to create a machine group. In this example, an Elastic Compute Service (ECS) instance is used.

      1. On the ECS Instance tab, select Manually Select Instances. Then, select the ECS instance that you want to use and click Create.

        For more information, see Install Logtail on ECS instances.

        Important

        If your server is an ECS instance that belongs to another Alibaba Cloud account, a server that is provided by a third-party cloud service provider, or a server that is deployed in a data center, you must manually install Logtail on the server. For more information, see Install Logtail on a Linux server or Install Logtail on a Windows server. After you manually install Logtail, you must configure a user identifier for the server. For more information, see Configure a user identifier.

      2. After Logtail is installed, click Complete Installation.

      3. In the Create Machine Group step, configure the Name parameter and click Next.

        Simple Log Service allows you to create IP address-based machine groups and custom identifier-based machine groups. For more information, see Create an IP address-based machine group and Create a custom identifier-based machine group.

  5. Select the machine group from the Source Server Groups section and move the machine group to the Applied Server Groups section. Then, click Next.

    Important

    If you apply a machine group immediately after you create the machine group, the heartbeat status of the machine group may be FAIL. This issue occurs because the machine group is not connected to Simple Log Service. To resolve this issue, you can click Automatic Retry. If the issue persists, see How do I troubleshoot the errors that are related to Logtail machine groups?

  6. In the Specify Data Source step, configure the Config Name and Plug-in Config parameters and click Next.

    • inputs specifies the collection configurations of your data source. This parameter is required.

    • processors specifies the processing configurations that are used to parse data. This parameter is optional. You can specify one or more processing methods.

      If the current inputs configuration no longer meets your log parsing requirements, you can add a processors configuration in the Plug-in Config field. For example, you can add plug-ins to extract fields, extract log time, mask data, and filter logs. For more information, see Use Logtail plug-ins to process data.

    "inputs":[
            {
                "type":"service_snmp",
                "detail":{
                "Targets": ["127.0.0.1"],
                "Port": "161",
                "Community": "public",
                "Timeout": 5,
                "Version":2,
                "Transport":"udp",
                "MaxRepetitions":0,
                "Oids":[
                "1.3.6.1.2.1.1.3.0"
                ]
            }
        }
    ],

    Parameter

    Type

    Required

    Description

    Targets

    string list

    Yes

    The IP address of the machine group.

    Port

    string

    No

    The port that is used by the SNMP protocol. Default value: 161.

    Community

    string

    No

    The name of the community. Default value: public.

    SNMPv1 and SNMPv2 use community names for authentication.

    UserName

    string

    No

    The username. This parameter is empty by default.

    SNMPv3 uses usernames for authentication.

    AuthenticationProtocol

    string

    No

    The authentication protocol. Default value: NoAuth.

    SNMPv3 uses authentication protocols for authentication.

    AuthenticationPassphrase

    string

    No

    The password of the authentication protocol. This parameter is empty by default.

    If you set the AuthenticationProtocol parameter to MD5 or SHA, you must configure the AuthenticationPassphrase parameter.

    PrivacyProtocol

    string

    No

    The privacy protocol. Default value: NoPriv.

    SNMPv3 uses privacy protocols for authentication.

    PrivacyPassphrase

    string

    No

    The password of the privacy protocol. By default, the password is the same as the authentication password.

    If you set the PrivacyProtocol parameter to DES or AES, you must configure the PrivacyPassphrase parameter.

    Timeout

    int

    No

    The timeout period of a query operation. Unit: seconds. Default value: 5.

    Version

    int

    No

    The version of the SNMP protocol. Default value: 2.

    Valid values: 1, 2, and 3.

    Transport

    string

    No

    The transport protocol used for SNMP communication. Default value: udp.

    Valid values: udp and tcp.

    MaxRepetitions

    int

    No

    The number of retries after the query times out. Default value: 0.

    Oids

    string list

    No

    The object identifiers that are queried in the server. This parameter is empty by default.

    Fields

    string list

    No

    The fields that are queried in the server. This parameter is empty by default.

    The plug-in looks up the local management information base, translates the fields into object identifiers, and then queries the object identifiers.

    Tables

    string list

    No

    The tables that are queried in the server. This parameter is empty by default.

    The plug-in queries all the fields in the tables, looks up the local management information base, translates the fields into object identifiers, and then queries the object identifiers.

  7. Preview data, configure indexes, and then click Next.

    By default, full-text indexing is enabled in Simple Log Service. You can configure field indexes based on collected logs in manual or automatic mode. To configure field indexes in automatic mode, click Automatic Index Generation. Simple Log Service automatically creates field indexes. For more information, see Create indexes.

Configuration examples

Example 1

  • Sample Logtail plug-in configuration

    In this example, the SNMPv2 protocol is used and the community name is public.

    "inputs":[
            {
                "type":"service_snmp",
                "detail":{
                "Targets": ["127.0.0.1"],
                "Port": "161",
                "Community": "public",
                "Timeout": 5,
                "Version":2,
                "Transport":"udp",
                "MaxRepetitions":0,
                "Oids":[
                "1.3.6.1.2.1.1.3.0",
                "1.3.6.1.2.1.1.4.0",
                "1.3.6.1.2.1.1.7.0",
                "1.3.6.1.2.1.1.1.0"
                ]
            }
        }
    ],
  • Collection result

    {"_target_":"127.0.0.1","_field_":"DISMAN-EXPRESSION-MIB::sysUpTimeInstance","_oid_":".1.3.6.1.2.1.1.3.0","_conversion_":"","_type_":"TimeTicks","_content_":"10522102","_targetindex_":"0"}
    {"_target_":"127.0.0.1","_field_":"SNMPv2-MIB::sysContact.0","_oid_":".1.3.6.1.2.1.1.4.0","_conversion_":"","_type_":"OctetString","_content_":"Me <me@example.org>","_targetindex_":"0"}
    {"_conversion_":"","_type_":"Integer","_content_":"72","_targetindex_":"0","_target_":"127.0.0.1","_field_":"SNMPv2-MIB::sysServices.0","_oid_":".1.3.6.1.2.1.1.7.0"}
    {"_targetindex_":"0","_target_":"127.0.0.1","_field_":"SNMPv2-MIB::sysDescr.0","_oid_":".1.3.6.1.2.1.1.1.0","_conversion_":"","_type_":"OctetString","_content_":"Linux 4be69bf59c36 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64"}

Example 2

  • Sample Logtail plug-in configuration

    In this example, the SNMPv3 protocol is used. The queried machine group contains only one server. The username is snmpreadonly, the authentication protocol is SHA, the password of the authentication protocol is SecUREDpass, the privacy protocol is AES, and the password of the privacy protocol is StRongPASS.

    "inputs":[
        {
            "type":"service_snmp",
            "detail":{
            "Targets":["127.0.0.1"],
            "Port": "161",
            "Community": "public",
            "Timeout": 5,
            "Version":3,
            "UserName":"snmpreadonly",
            "AuthenticationProtocol":"SHA",
            "AuthenticationPassphrase":"SecUREDpass",
            "PrivacyProtocol":"AES",
            "PrivacyPassphrase":"StRongPASS",
            "Oids":[
            "1.3.6.1.2.1.1.3.0",
            "1.3.6.1.2.1.1.1.0"
            ],
            "Fields":[
            "SNMPv2-MIB::sysContact.0",
            "SNMPv2-MIB::sysServices.0"
            ],
            "Transport":"udp"
            }
        }
    ],
  • Collection result

    {"_target_":"127.0.0.1","_field_":"DISMAN-EXPRESSION-MIB::sysUpTimeInstance","_oid_":".1.3.6.1.2.1.1.3.0","_conversion_":"","_type_":"TimeTicks","_content_":"10423593","_targetindex_":"0"}
    {"_type_":"OctetString","_content_":"Linux 4be69bf59c36 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64","_targetindex_":"0","_target_":"127.0.0.1","_field_":"SNMPv2-MIB::sysDescr.0","_oid_":".1.3.6.1.2.1.1.1.0","_conversion_":""}
    {"_content_":"Me <me@example.org>","_targetindex_":"0","_target_":"127.0.0.1","_field_":"SNMPv2-MIB::sysContact.0","_oid_":".1.3.6.1.2.1.1.4.0","_conversion_":"","_type_":"OctetString"}
    {"_conversion_":"","_type_":"Integer","_content_":"72","_targetindex_":"0","_target_":"127.0.0.1","_field_":"SNMPv2-MIB::sysServices.0","_oid_":".1.3.6.1.2.1.1.7.0"}

Fields

The following table describes the fields in a log after SNMP data is collected from servers.

Field

Description

_target_

The IP address of the server.

_targetindex_

The index of the server in the machine group that is specified in the plug-in configuration.

In this example, only one server whose IP address is 127.0.0.1 is used. In this case, the value of this field is 0.

_field_

The object identifier into which the queried field is translated based on the local management information base.

_oid_

The queried object identifier.

_conversion_

The conversion type of the collection result.

  • ipaddr: IP addresses are converted.

  • hwaddr: Device addresses are converted.

  • Empty value: No conversion occurred.

_type_

The type of the collection result.

_content_

The collected content.