Skip to content

How to Fetch Metrics

These instructions describe the ways to collect metrics from a filtering node.

Exporting Metrics Directly From collectd

You can export the metrics collected by collectd directly to the tools that support working with collectd data streams.

Prerequisites

All further steps must be performed as a superuser (e.g., root).

Exporting Metrics via the collectd Network Plugin

Configure and connect the network plugin to collectd:

  1. In the /etc/collectd/collectd.conf.d/ directory, create a file with the .conf extension (e.g., export-via-network.conf) and the following content:

    LoadPlugin network
    
    <Plugin "network">
      Server "Server IPv4/v6 address or FQDN" "Server port"
    </Plugin>
    

    As stated in this file, the plugin will be loaded upon starting collectd, operate in the client mode, and send the filter node’s metrics data to the specified server.

  2. Configure a server that will receive data from the collectd client. The necessary configuration steps depend on the selected server (see examples for collectd and InfluxDB).

    Working with the Network Plugin

    The network plugin works over UDP (see the plugin documentation). Make sure that the server allows communication over UDP for metrics collection to be operational.

  3. Restart the collectd service by executing the appropriate command:

    sudo service collectd restart
    
    sudo systemctl restart collectd
    

Example

Read an example of exporting metrics to InfluxDB via the Network plugin with subsequent visualization of the metrics in Grafana.

Exporting Metrics via the collectd Write Plugins

To configure export of metrics via the collectd write plugins, refer to the documentation of the corresponding plugin.

Example

To get basic information about using write plugins, read an example of exporting metrics to Graphite with subsequent visualization of the metrics in Grafana.

Exporting Metrics Using the collectd-nagios Utility

To export metrics using this method:

  1. Install the collectd-nagios utility on a host with a filter node by running the appropriate command (for a filter node installed on Linux):

    sudo apt -y install --no-install-recommends collectd-utils
    
    sudo yum install -y collectd-utils
    

    Docker image

    The filter node Docker image ships with a preinstalled collectd-nagios utility.

  2. Make sure that you can run this utility with elevated privileges either on behalf of a superuser (for example, root) or as a regular user. In the latter case, add the user to the sudoers file with the NOPASSWD directive, and use the sudo utility.

    Working with the Docker container

    When executing the collectd-nagios utility in a Docker container with the filter node, elevation of privileges is not required.

  3. Connect and configure the UnixSock plugin to transmit the collectd metrics via a Unix domain socket. To do this, create the file /etc/collectd/collectd.conf.d/unixsock.conf with the following content:

    LoadPlugin unixsock
    
    <Plugin unixsock>
        SocketFile "/var/run/wallarm-collectd-unixsock"
        SocketGroup "root"
        SocketPerms "0770"
        DeleteSocket true
    </Plugin>
    
  4. Restart the collectd service by executing the appropriate command:

    sudo service collectd restart
    
    sudo systemctl restart collectd
    
  5. Get the value of the necessary metric by running the appropriate command:

    /usr/bin/collectd-nagios -s /var/run/wallarm-collectd-unixsock -n <metric name without host name> -H <FQDN of the host with the filter node on which the utility is running>
    
    docker exec <container name> /usr/bin/collectd-nagios -s /var/run/wallarm-collectd-unixsock -n <metric name without host name> -H <container ID>
    

    Getting the Docker container's ID

    You can find the value of the container identifier by running the docker ps command (see the “CONTAINER ID” column).

Setting Thresholds for the collectd-nagios Utility

If necessary, you can specify a range of values for which the collectd-nagios utility will return the WARNING or CRITICAL status by using the corresponding -w and -c options (detailed information is available in the utility documentation).

Examples of using the utility:

  • To get the value of the curl_json-wallarm_nginx/gauge-abnormal metric (at the time collectd-nagios was called) on the Linux host node.example.local with the filter node, run the following command:

    /usr/bin/collectd-nagios -s /var/run/wallarm-collectd-unixsock -n curl_json-wallarm_nginx/gauge-abnormal -H node.example.local
    
  • To get the value of the curl_json-wallarm_nginx/gauge-abnormal metric (at the time collectd-nagios was called) for the filter node running in the Docker container with the wallarm-node name and the 95d278317794 identifier, run the following command:

    docker exec wallarm-node /usr/bin/collectd-nagios -s /var/run/wallarm-collectd-unixsock -n curl_json-wallarm_nginx/gauge-abnormal -H 95d278317794
    

More examples

To get basic information about using the collectd-nagios utility, read examples of exporting metrics

Sending Notifications from collectd

Notifications are configured in the following file:

/etc/collectd/conf.d/traps.conf
/etc/collectd.d/traps.conf

A general description of how notifications work is available here.

More detailed information about how to set up notifications is available here.

Possible methods of sending notifications:

  • NSCA and NSCA-ng

  • SNMP TRAP

  • email messages

  • custom scripts