Skip to content

Latest commit

 

History

History
106 lines (80 loc) · 5.05 KB

collectd-custom.md

File metadata and controls

106 lines (80 loc) · 5.05 KB

collectd/custom

Monitor Type: collectd/custom (Source)

Accepts Endpoints: Yes

Multiple Instances Allowed: Yes

Overview

This monitor lets you provide custom collectd configuration to be run by the managed collectd instance. You can provide configuration for as many plugins as you want in a single instance of this monitor configuration by either putting multiple <Plugin> blocks in a single template option, or specifying multiple templates.

Note that a distinct instance of collectd is run for each instance of this monitor, so it is more efficient to group plugin configurations into a single monitor configuration (either in one big template text blob, or split into multiple templates). You should not group configurations if using a discoveryRule since that would result in duplicate config for each instance of the service endpoint discovered.

You can also use your own Python plugins in conjunction with the ModulePath option in collectd-python. If your Python plugin has dependencies of its own, you can specify the path to them by specifying multiple ModulePath options with those paths.

Here is an example of a configuration with a custom Python plugin:

  - type: collectd/custom
    discoveryRule: container_image =~ "myservice"
    template: |
      LoadPlugin "python"
      <Plugin python>
        ModulePath "/usr/lib/python2.7/dist-packages/health_checker"
        Import "health_checker"
        <Module health_checker>
          URL "http://{{.Host}}:{{.Port}}"
          JSONKey "isRunning"
          JSONVal "1"
        </Module>
      </Plugin>

We have many collectd plugins included in the image that are not exposed as monitors. You can see the plugins in the <AGENT_BUNDLE>/lib/collectd directory, where <AGENT_BUNDLE> is the root of the filesystem in the containerized version, and is normally /usr/lib/signalfx-agent in the non-containerized agent.

Running the collectd/exec plugin

You can use the collectd/custom monitor to run the collectd/exec plugin. If you are not running the Smart Agent in the container, you can use any appropriate user on your system. If you are running the Smart Agent in a container, then you need to use a non-root user when you run your script:

  - type: collectd/custom
    template: |
      LoadPlugin exec
      <Plugin exec>
        Exec "`non-root user`" "/path/to/script.sh"
      </Plugin>

(replace non-root user with an actual non-root user on your host)

To learn how to use the collectd/exec plugin, see the collectd-exec documentation.

Configuration

To activate this monitor in the Smart Agent, add the following to your agent config:

monitors:  # All monitor config goes under this key
 - type: collectd/custom
   ...  # Additional config

For a list of monitor options that are common to all monitors, see Common Configuration.

Config option Required Type Description
host no string This should generally not be set manually, but will be filled in by the agent if using service discovery. It can be accessed in the provided config template with {{.Host}}. It will be set to the hostname or IP address of the discovered service. If you aren't using service discovery, you can just hardcode the host/port in the config template and ignore these fields.
port no integer This should generally not be set manually, but will be filled in by the agent if using service discovery. It can be accessed in the provided config template with {{.Port}}. It will be set to the port of the discovered service, if it is a TCP/UDP endpoint. (default: 0)
name no string This should generally not be set manually, but will be filled in by the agent if using service discovery. It can be accessed in the provided config template with {{.Name}}. It will be set to the name that the observer creates for the endpoint upon discovery. You can generally ignore this field.
template no string A config template for collectd. You can include as many plugin blocks as you want in this value. It is rendered as a standard Go template, so be mindful of the delimiters {{ and }}.
templates no list of strings A list of templates, but otherwise equivalent to the above template option. This enables you to have a single directory with collectd configuration files and load them all by using a globbed remote config value:
collectdReadThreads no integer The number of read threads to use in collectd. Will default to the number of templates provided, capped at 10, but if you manually specify it there is no limit. (default: 0)

The agent does not do any built-in filtering of metrics coming out of this monitor.