Plugin:Write HTTP

From collectd Wiki
Revision as of 07:20, 2 October 2016 by Octo (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Write HTTP plugin
Type: write
Callbacks: config, flush, write
Status: supported
First version: 4.8
Copyright: 2009 Paul Sadauskas
2009 Doug MacEachern
2007–2014 Florian octo Forster
License: GPLv2
Manpage: collectd.conf(5)
List of Plugins

The Write HTTP plugin sends the values collected by collectd to a web-server using HTTP POST requests. The data is formatted as PUTVAL commands, see plain text protocol.

In order to improve performance the plugin fills a 4 kByte buffer as full as possible and sends multiple lines at once.



<Plugin "write_http">
  <Node "example"> 
    URL ""
    User "collectd"
    Password "weCh3ik0"

Example data

The data transmitted to the web-server has the following form:

Command format

PUTVAL interval=10 1251533299:197141504:175136768
PUTVAL interval=10 1251533299:10765:12858
PUTVAL interval=10 1251533299:5:140
PUTVAL interval=10 1251533299:4658:29899

JSON format

     "values": [197141504, 175136768],
     "dstypes": ["counter", "counter"],
     "dsnames": ["read", "write"],
     "time": 1251533299,
     "interval": 10,
     "host": "",
     "plugin": "disk",
     "plugin_instance": "sda",
     "type": "disk_octets",
     "type_instance": ""


You can use RestMQ with the collectd "entry point" to consume the data sent by the Write HTTP plugin. RestMQ is a message queue based on Redis which provides a RESTful interface. It includes a special "entry point" which parses the PUTVAL command data and emits the data in a specialized JSON format, it also accepts the JSON produced by the collectd daemon.

Plain Text Protocol Example

You need to set the Format option to "Command" (the default) in order to work with this module:


<Plugin "write_http">
  <Node "restmq_example">
    URL ""
    Format "Command"
    #User "collectd"
    #Password "weCh3ik0"

Example JSON

   "host": "collectd_restmq_server",
   "type_instance": "df-boot",
   "plugin_instance": "df",
   "value": "1288548767:116497408.000000:391246848.000000",
   "interval": "10"

JSON Example

You need to set the Format option to "JSON" in order to work with this module:


<Plugin "write_http">
  <Node "restmq_example">
    URL ""
    Format "JSON"
    #User "collectd"
    #Password "weCh3ik0"

Example JSON

   "values": [1.16497e+08,3.91247e+08],

Chains Example

A common requirement is the ability to direct selected metrics toward the 'write_http' plugin, while continuing to process other metrics via another write plugin:


LoadPlugin write_http
<Plugin "write_http">
  <Node "example_node">
    URL ""
PostCacheChain "PostCache"
<Chain "PostCache">
  <Rule "snmp">
    <Match "regex">
      Plugin "^snmp$"
    <Target "write">
      Plugin "write_http/example_node"
    Target "stop"
  # Default target
  <Target "write">
    Plugin "rrdtool"



See also

Personal tools