From 91166b4e01e8833386580daf32b4efacdde28173 Mon Sep 17 00:00:00 2001 From: marknmel Date: Tue, 15 Mar 2016 09:29:05 -0400 Subject: [PATCH] Cleanup of Exec Inputs documentation - redux Hi @sparrc (Sorry for the noise - new pr) closes #853 Please find some improvements to readability including the \n for the exec/telegraf line-protocol input. I hope you (and others) find it easier to read. /Mark This is an ammend --- plugins/inputs/exec/README.md | 60 ++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/plugins/inputs/exec/README.md b/plugins/inputs/exec/README.md index eddc86ada..730da1fd5 100644 --- a/plugins/inputs/exec/README.md +++ b/plugins/inputs/exec/README.md @@ -1,28 +1,20 @@ # Exec Input Plugin -The exec plugin can execute arbitrary commands which output: +Please also see: [Telegraf Input Data Formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) -* JSON -* InfluxDB [line-protocol](https://docs.influxdata.com/influxdb/v0.9/write_protocols/line/) +The exec input plugin can execute arbitrary commands which output: + +* JSON [javascript object notation](http://www.json.org/) +* InfluxDB [line-protocol](https://docs.influxdata.com/influxdb/v0.10/write_protocols/line/) * Graphite [graphite-protocol](http://graphite.readthedocs.org/en/latest/feeding-carbon.html) -> Graphite understands messages with this format: -> ``` -metric_path value timestamp\n -``` +### Example 1 - JSON -> __metric_path__ is the metric namespace that you want to populate. +#### Configuration -> __value__ is the value that you want to assign to the metric at this time. - -> __timestamp__ is the unix epoch time. - - -If using JSON, only numeric values are parsed and turned into floats. Booleans -and strings will be ignored. - -### Configuration +In this example a script called ```/tmp/test.sh``` and a script called ```/tmp/test2.sh``` +are configured for ```[[inputs.exec]]``` in JSON format. ``` # Read flattened metrics from one or more commands that output JSON to stdout @@ -64,8 +56,6 @@ Other options for modifying the measurement names are: name_prefix = "prefix_" ``` -### Example 1 - Let's say that we have the above configuration, and mycollector outputs the following JSON: @@ -85,10 +75,16 @@ The collected metrics will be stored as fields under the measurement ``` exec_mycollector a=0.5,b_c=0.1,b_d=5 1452815002357578567 ``` +If using JSON, only numeric values are parsed and turned into floats. Booleans +and strings will be ignored. -### Example 2 +### Example 2 - Influx Line-Protocol -Now let's say we have the following configuration: +In this example an application called ```/usr/bin/line_protocol_collector``` +and a script called ```/tmp/test2.sh``` are configured for ```[[inputs.exec]]``` +in influx line-protocol format. + +#### Configuration ``` [[inputs.exec]] @@ -103,7 +99,7 @@ Now let's say we have the following configuration: data_format = "influx" ``` -And line_protocol_collector outputs the following line protocol: +The line_protocol_collector application outputs the following line protocol: ``` cpu,cpu=cpu0,host=foo,datacenter=us-east usage_idle=99,usage_busy=1 @@ -117,16 +113,19 @@ cpu,cpu=cpu6,host=foo,datacenter=us-east usage_idle=99,usage_busy=1 You will get data in InfluxDB exactly as it is defined above, tags are cpu=cpuN, host=foo, and datacenter=us-east with fields usage_idle -and usage_busy. They will receive a timestamp at collection time. +and usage_busy. They will receive a timestamp at collection time. +Each line must end in \n, just as the Influx line protocol does. -### Example 3 +### Example 3 - Graphite We can also change the data_format to "graphite" to use the metrics collecting scripts such as (compatible with graphite): * Nagios [Mertics Plugins] (https://exchange.nagios.org/directory/Plugins) * Sensu [Mertics Plugins] (https://github.com/sensu-plugins) +In this example a script called /tmp/test.sh and a script called /tmp/test2.sh are configured for [[inputs.exec]] in graphite format. + #### Configuration ``` # Read flattened metrics from one or more commands that output JSON to stdout @@ -161,6 +160,17 @@ We can also change the data_format to "graphite" to use the metrics collecting s "measurement*" ] ``` +Graphite messages are in this format: + +``` +metric_path value timestamp\n +``` + +__metric_path__ is the metric namespace that you want to populate. + +__value__ is the value that you want to assign to the metric at this time. + +__timestamp__ is the unix epoch time. And test.sh/test2.sh will output: @@ -177,4 +187,4 @@ sensu.metric.net.server0.eth0.rx_dropped 0 1444234982 The templates configuration will be used to parse the graphite metrics to support influxdb/opentsdb tagging store engines. More detail information about templates, please refer to [The graphite Input] (https://github.com/influxdata/influxdb/blob/master/services/graphite/README.md) - +