Updated on 2024-10-23 GMT+08:00

Custom Plug-in Access

Application Scenario

Use a custom plug-in to create a collection task to monitor specified metrics. In addition, use Exporter to report database metrics for exception detection and Grafana dashboard display.

Prerequisites

Creating a Custom Plug-in

UniAgent allows you to create custom plug-ins. You can create a plug-in using scripts and create a collection task to use this plug-in by referring to Custom Plug-in Access to collect metrics.

  1. Log in to the AOM 2.0 console.
  2. In the navigation pane, choose Access Center.
  3. In the Custom Prometheus Plug-in Access panel, click Custom Plug-in.
  4. On the displayed page, set related parameters.

    • Plug-in information
      Table 1 Plug-in parameters

      Parameter

      Description

      Plug-in Name

      Name of a custom plug-in. Enter a maximum of 32 characters starting with a letter. Only letters, digits, and underscores (_) are allowed.

      Plug-in Type

      Type of a plug-in. The default value is Custom.

      Description

      Description of the plug-in to be created. Enter a maximum of 10,000 characters.

    • Set Plug-in
      Table 2 Plug-in configuration parameters

      Parameter

      Description

      Plug-in Version

      Version of the custom plug-in.

      Plug-in Script

      Custom plug-in script. Options: Linux and Windows.

      Linux: Shell or Python script.

      Example:

      #!/bin/bash
      #Examples
      echo "metric_name{label_name=\"label_value\"} 100"

      Windows: BAT script

      Example:

      ::Examples
      @echo off
      echo metric_name{label_name="label_value"} 100

      Default Script Parameter

      Custom script parameter template. Only letters, digits, and underscores (_) are allowed. Ensure that the following rules are met:

      • Letter: For example, -a.
      • Character combination: For example, http://127.0.0.1:80. The following special characters are not allowed: &|><;`!()$-
      • ${Parameter}: Enter a maximum of 64 characters starting with a letter. Only letters, digits, and underscores (_) are allowed. For example, ${a_b}.

      You can combine parameters as required and separate them with spaces. The total length of these parameters cannot exceed 250 characters.

      Script Parameter

      Parameters in the default script parameters. After you enter the default script parameters, the system automatically identifies script parameters based on your settings.

      Script parameter description:

      • Mandatory: If this option is enabled, the parameter value in the plug-in debugging area is mandatory. If this option is disabled, the parameter value in the plug-in debugging area is optional.
      • Parameter: name of a script parameter.
      • Default Value: default value of the script parameter.
      • Description: description of the parameter.

  5. Click Save.

    After a plug-in is created, you can modify it, create a version for it, or delete it.

    Table 3 Related operations

    Operation

    Description

    Checking the plug-in status

    Locate the target plug-in, hover the mouse pointer over the plug-in, and choose > Version. On the page that is displayed, check the plug-in status.

    • Unreleased: When you create a plug-in or create a plug-in version, the plug-in status is Unreleased. You can click the version number to edit the plug-in.
    • Released: After you click Release in the Operation column, the plug-in status changes to Released. You can click the version number to view the plug-in details.

    Creating a version

    Locate the target plug-in, hover the mouse pointer over the plug-in, and choose > Version. Click Create Version. On the displayed page, set the plug-in information.

    NOTE:
    • A maximum of five versions can be created for a plug-in.
    • If there is only one plug-in version, only Copy is available in the Operation column. If there is more than one plug-in, both Copy and Delete are available in the Operation column. You can click Delete to delete a plug-in version.

    Modifying a plug-in

    Locate the target plug-in, hover the mouse pointer over the plug-in, and choose > Modify. On the displayed page, modify the plug-in information.

    Deleting a plug-in

    Locate the target plug-in, hover the mouse pointer over the plug-in, and choose > Delete. On the displayed page, click Yes to delete the plug-in.

    NOTE:

    If a collection task has been configured for a plug-in, deleting the plug-in will also delete the collection task.

Custom Plug-in Access

  1. Log in to the AOM 2.0 console.
  2. In the navigation pane on the left, choose Access Center. Click the custom plug-in on the Custom Prometheus Plug-in Access panel.
  3. On the collection task configuration page, set parameters by referring to the following table.

    Figure 1 Configuring a collection task
    Table 4 Parameters for creating a collection task

    Operation

    Parameter

    Description

    Select Instance

    Prometheus Instance

    Select a Prometheus instance for ECS to store collected data.

    A collection task will be associated with the Prometheus instance to mark and classify collected data. If no Prometheus instance is available, create one.

    Set Plug-in

    OS

    Operating system of the host. Options: Linux and Windows. For a custom plug-in, the OS is automatically selected.

    Collection Plug-in

    (Default) Created custom plug-in.

    Plug-in Version

    Select a plug-in version.
    NOTE:

    Plug-in versions that have not been released are dimmed and cannot be selected.

    Set Collection Task

    Collection Task Name

    Name of a collection task. Enter 1 to 50 characters and start with a letter. Only letters, digits, underscores (_), and hyphens (-) are allowed.

    Host

    Click Add Host and select a host.

    Specify host: Select a host that has been connected.

    • On the Specify host page, search for and select a host by the host name, IP address, or Agent status.
    • On the Specify host page, click in the upper right corner to deselect the host.
    • Ensure that the UniAgent of the selected host is running. Otherwise, no data can be collected.
    NOTE:

    If you select a custom plug-in, you can select multiple hosts.

    Advanced Settings

    Includes Collection Period (s) and Timeout Period (s).

    • Collection Period (s): O&M data collection period, in seconds. Options: 10s, 30s, and 60s (default).
    • Timeout Period (s): the maximum time allowed for executing a collection task, in seconds. Options: 10s, 30s, and 60s (default).
      NOTE:

      The timeout period cannot exceed the collection period.

    • Executor: user who executes the collection task, that is, the user of the selected host. Default: root. Enter a username. Recommended: root.

  4. Click Create.
  5. On the displayed collection task page, click the target collection task to view its details.