Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
258 lines (190 sloc) 10 KB


collectd-librato is a collectd plugin that publishes collectd values to Librato Metrics using the Librato Metrics API. Librato Metrics is a hosted, time-series data service.

Collectd-librato was largely influenced by collectd-carbon.


  • Collectd 4.9 or later (for the Python plugin) (A patch may be required to fix the Python plugin - see below)
  • Python 2.4 or later
  • An active Librato Metrics account (sign up here).


Installation is provided by the Makefile included in the project. Simply clone this repository and run make install as root:

$ git clone git://
$ cd collectd-librato
$ sudo make install
Installed collected-librato plugin, add this
to your collectd configuration to load this plugin:

    <LoadPlugin "python">
        Globals true

    <Plugin "python">
        # is at /opt/collectd-librato-0.0.3/lib/
        ModulePath "/opt/collectd-librato-0.0.3/lib"

        Import "collectd-librato"

        <Module "collectd-librato">
            APIToken "1985481910fe29ab201302011054857292"
            Email    ""

The output above includes a sample configuration file for the plugin. Simply add this to /etc/collectd.conf or drop in the configuration directory as /etc/collectd.d/librato.conf and restart collectd. See the next section for an explanation of the plugin's configuration variables.


The plugin requires some configuration. This is done by passing parameters via the config section in your Collectd config.

The following parameters are required:

  • Email - The email address associated with your Librato Metrics account.

  • APIToken - The API token for you Librato Metrics account. This value can be found your account page.

The following parameters are optional:

  • TypesDB - file(s) defining your Collectd types. This should be the sames as your TypesDB global config parameters. This will default to the file /usr/share/collectd/types.db. NOTE: This plugin will not work if it can't find the types.db file.

  • LowercaseMetricNames - If preset, all metric names will be converted to lower-case (default no lower-casing).

  • MetricPrefix - If present, all metric names will contain this string prefix. Do not include a trailing period or separation character (see MetricSeparator). Set to the empty string to disable any prefix. Defaults to "collectd".

  • MetricSeparator - String to separate the components of a metric name when combining the plugin name, type, and instance name. Defaults to a period (".").

  • IncludeSingleValueNames - Normally, any metric type listed in types.db that only has a single value will not have the name of the value suffixed onto the metric name. For most single value metrics the name is simply a placeholder like "value" or "count", so adding it to the metric name does not add any particular value. If IncludeSingleValueNames is set however, these value names will be suffixed onto the metric name regardless.

  • FlushIntervalSecs - This value determines how frequently metrics are flushed to Librato Metrics. For each collectd write request the plugin will check if it has been FlushIntervalSecs seconds since the last flush and if so will POST all metrics to Librato. Internally there is a hard limit on the maximum number of metrics that the plugin will buffer before a flush is forced which may supersede the FlushIntervalSecs. The default flush interval is 30 seconds.


The following is an example Collectd configuration for this plugin:

<LoadPlugin "python">
    Globals true

<Plugin "python">
    # is at /opt/collectd-librato-0.0.3/lib/
    ModulePath "/opt/collectd-librato-0.0.3/lib"

    Import "collectd-librato"

    <Module "collectd-librato">
        APIToken "1985481910fe29ab201302011054857292"
        Email    ""

Supported Metrics

Collectd-Librato currently supports the following collectd metric types:

  • GAUGE - Reported as a Librato Metric gauge.
  • COUNTER - Reported as a Librato Metric counter.

Other metric types are currently ignored. This list will be expanded in the future.

Operational Notes

This plugin uses a best-effort attempt to deliver metrics to Librato Metrics. If a flush fails to POST metrics to Librato Metrics the flush will not currently be retried, but instead dropped. In most cases this should not happen, but if it does the plugin will continue to flush metrics after the failure. So in the worst case there may appear a short gap in your metric graphs.

The plugin needs to parse Collectd type files. If there was an error parsing a specific type (look for log messages at Collectd startup time), the plugin will fail to write values for this type. It will simply skip over them and move on to the next value. It will write a log message every time this happens so you can correct the problem.

The plugin needs to perform redundant parsing of the type files because the Collectd Python API does not provide an interface to the types information (unlike the Perl and Java plugin APIs). Hopefully this will be addressed in a future version of Collectd.

Data Mangling

Collectd data is collected/written in discrete tuples having the following:

(host, plugin, plugin_instance, type, type_instance, time, interval, metadata, values)

values is itself a list of { counter, gauge, derive, absolute } (numeric) values. To further complicate things, each distinct type has its own definition corresponding to what's in the values field.

Librato Metrics, by contrast, deals with tuples of:

(source, metric_name, value, measurement_time)

So we effectively have to mangle the collectd tuple down to the fields above.

The source is simply set to the host field of the collectd tuple. The plugin mangles the remaining fields of the collectd tuple to the following Librato Metrics metric_name:


Where data_source is the name of the data source (i.e. ds_name) in the type being written. In the case that the plugin data source only has a single value, the data_source is not included in the name (unless IncludeSingleValueNames is set).

For example, the Collectd distribution has a built-in df type:

df used:GAUGE:0:1125899906842623, free:GAUGE:0:1125899906842623

The data_source values for this type would be used and free yielding the metric names (along the lines of) collectd.df.df.root.used and for the root file-system.


Collectd Python Write Callback Bug

Collectd versions through 4.10.2 and 4.9.4 have a bug in the Python plugin where Python would receive bad values for certain data sets. The bug would typically manifest as data values appearing to be 0. The collectd-carbon author identified the bug and sent a fix to the Collectd development team.

Collectd versions 4.9.5, 4.10.3, and 5.0.0 are the first official versions with a fix for this bug. If you are not running one of these versions or have not applied the fix (which can be seen at, you will likely dispatch wrong values to Librato Metrics.

Collectd on Redhat ImportError

Using the plugin with collectd on Redhat-based distributions (RHEL, CentOS, Fedora) may produce the following error:

Jul 20 14:54:38 mon0 collectd[2487]: plugin_load_file: The global flag is not supported, libtool 2 is required for this.
Jul 20 14:54:38 mon0 collectd[2487]: python plugin: Error importing module "collectd_librato".
Jul 20 14:54:38 mon0 collectd[2487]: Unhandled python exception in importing module: ImportError: /usr/lib64/python2.4/lib-dynload/ undefined symbol: PyExc_ValueError
Jul 20 14:54:38 mon0 collectd[2487]: python plugin: Found a configuration for the "collectd_librato" plugin, but the plugin isn't loaded or didn't register a configuration callback.
Jul 20 14:54:38 mon0 collectd[2488]: plugin_dispatch_values: No write callback has been registered. Please load at least one output plugin, if you want the collected data to be stored.
Jul 20 14:54:38 mon0 collectd[2488]: Filter subsystem: Built-in target `write': Dispatching value to all write plugins failed with status 2 (ENOENT). Most likely this means you didn't load any write plugins.

This may also occur on other operating systems and collectd versions. It is caused by a libtool/libltdl quirk described in this mailing list thread. As per the workarounds detailed there, you may either:

  1. Modify the init script /etc/init.d/collectd to preload the libpython shared library:

    @@ -25,7 +25,7 @@
            echo -n $"Starting $prog: "
            if [ -r "$CONFIG" ]
    -               daemon /usr/sbin/collectd -C "$CONFIG"
    +               LD_PRELOAD=/usr/lib64/ daemon /usr/sbin/collectd -C "$CONFIG"
                    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
  2. Modify the RPM and rebuild.

    @@ -182,7 +182,7 @@
    -%configure \
         --disable-static \
         --disable-ascent \
         --disable-apple_sensors \


If you would like to contribute a fix or feature to this plugin please feel free to fork this repo, make your change and submit a pull request!

Something went wrong with that request. Please try again.