Skip to content
Florian Forster edited this page Nov 26, 2023 · 1 revision
Name: Write HTTP plugin
Type: write
Callbacks: config, flush, write
Status: supported
FirstVersion: 4.8
Copyright: 2009 Paul Sadauskas, 2009 Doug MacEachern, 2007–2014 Florian octo Forster
License: GPLv2
Manpage: collectd.conf(5)
See also: 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.

Synopsis

 <Plugin "write_http">
   <Node "example">
     URL "<nowiki>http://example.com/post-collectd</nowiki>"
     User "collectd"
     Password "weCh3ik0"
   </Node>
 </Plugin>

Example data

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

Command format

 PUTVAL leeloo.lan.home.verplant.org/disk-sda/disk_octets interval=10 1251533299:197141504:175136768
 PUTVAL leeloo.lan.home.verplant.org/disk-sda/disk_ops interval=10 1251533299:10765:12858
 PUTVAL leeloo.lan.home.verplant.org/disk-sda/disk_time interval=10 1251533299:5:140
 PUTVAL leeloo.lan.home.verplant.org/disk-sda/disk_merged interval=10 1251533299:4658:29899
 ⋮

JSON format

 [
   {
     "values": [197141504, 175136768],
     "dstypes": ["counter", "counter"],
     "dsnames": ["read", "write"],
     "time": 1251533299,
     "interval": 10,
     "host": "leeloo.lan.home.verplant.org",
     "plugin": "disk",
     "plugin_instance": "sda",
     "type": "disk_octets",
     "type_instance": ""
   },
   
 ]

RestMQ

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:

Synopsis

 <Plugin "write_http">
   <Node "restmq_example">
     URL "<nowiki>http://restmq.example.com/collectd/data</nowiki>"
     Format "Command"
     #User "collectd"
     #Password "weCh3ik0"
   </Node>
 </Plugin>

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:

Synopsis

 <Plugin "write_http">
   <Node "restmq_example">
     URL "<nowiki>http://restmq.example.com/collectd/data</nowiki>"
     Format "JSON"
     #User "collectd"
     #Password "weCh3ik0"
   </Node>
 </Plugin>

Example JSON

 [{
   "values": [1.16497e+08,3.91247e+08],
   "time":1288638055,
   "interval":10,
   "host":"collectd_restmq_server",
   "plugin":"df",
   "plugin_instance":"",
   "type":"df",
   "type_instance":"boot"}
 }]

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:

Synopsis

 LoadPlugin write_http
 <Plugin "write_http">
   <Node "example_node">
     URL "<nowiki>http://example.com/post-collectd</nowiki>"
   </Node>
 </Plugin>
 PostCacheChain "PostCache"
 <Chain "PostCache">
   <Rule "snmp">
     <Match "regex">
       Plugin "^snmp$"
     </Match>
     <Target "write">
       Plugin "write_http/example_node"
     </Target>
     Target "stop"
   </Rule>
   # Default target
   <Target "write">
     Plugin "rrdtool"
   </Target>
 </Chain>

Weblinks

Dependencies

See also

Clone this wiki locally