Skip to content

Using custom emitters

Alexis Lê-Quôc edited this page Jul 30, 2013 · 1 revision

Custom emitters are ways to tell the agent to send its data to more than one destination. This is useful if you want to process agent data yourself in addition to relying on Datadog. Custom emitters are an experimental feature; use at your own risk.

Class Signature

First a few noteworthy considerations.

  1. Each custom emitter runs in its own thread so you probably want to keep the number of custom emitters to the low single-digit numbers.
  2. Because of the way custom emitters are built, data is first unmarshalled from the collector's output (long story short, thank CentOS5 for this). This means decompressing and parsing the json output of the packet that the collector assembled. There is a computational cost attached to it.

The module loader will instantiate your custom emitter once on startup, and call it each time the agent sends a payload.

The emitter itself must be callable and its signature should be:

class MyEmitter(object):
    def __call__ (self, payload, logger, config):
        """payload is a dictionary as collected by the agent
           logger is a logging.Logger object
           config is a dictionary of all the configuration values, in case you need them
        """
        # do your thing

Setup

Let us assume that you have created a custom emitter MyEmitter, in the file /usr/local/mine/my_emitter.py. To activate this emitter, simply add to /etc/dd-agent/datadog.conf

custom_emitters: /usr/local/mine/my_emitter.py:MyEmitter

The class name and the file name don't have to match, but the python file obviously has to be valid and it must be readable by the dd-agent user (at least on the linux platform).

Background

See this pull request for some background.

Clone this wiki locally