Skip to content

Commit

Permalink
Cleanup of Exec Inputs documentation - redux
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marknmel authored and sparrc committed Mar 17, 2016
1 parent 5afe819 commit 57f7582
Showing 1 changed file with 35 additions and 25 deletions.
60 changes: 35 additions & 25 deletions plugins/inputs/exec/README.md
Original file line number Diff line number Diff line change
@@ -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/)
* Graphite [graphite-protocol](http://graphite.readthedocs.org/en/latest/feeding-carbon.html)

> Graphite understands messages with this format:
> ```
metric_path value timestamp\n
```
> __metric_path__ is the metric namespace that you want to populate.
The exec input plugin can execute arbitrary commands which output:

> __value__ is the value that you want to assign to the metric at this time.
* 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)

> __timestamp__ is the unix epoch time.

### Example 1 - JSON

If using JSON, only numeric values are parsed and turned into floats. Booleans
and strings will be ignored.
#### Configuration

### 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
Expand Down Expand Up @@ -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:

Expand All @@ -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 - Influx Line-Protocol

### Example 2
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.

Now let's say we have the following configuration:
#### Configuration

```
[[inputs.exec]]
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:

Expand All @@ -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)

0 comments on commit 57f7582

Please sign in to comment.