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
This commit is contained in:
parent
4465fbeee6
commit
91166b4e01
|
@ -1,28 +1,20 @@
|
||||||
# Exec Input Plugin
|
# 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
|
The exec input plugin can execute arbitrary commands which output:
|
||||||
* InfluxDB [line-protocol](https://docs.influxdata.com/influxdb/v0.9/write_protocols/line/)
|
|
||||||
|
* 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 [graphite-protocol](http://graphite.readthedocs.org/en/latest/feeding-carbon.html)
|
||||||
|
|
||||||
> Graphite understands messages with this format:
|
|
||||||
|
|
||||||
> ```
|
### Example 1 - JSON
|
||||||
metric_path value timestamp\n
|
|
||||||
```
|
|
||||||
|
|
||||||
> __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.
|
In this example a script called ```/tmp/test.sh``` and a script called ```/tmp/test2.sh```
|
||||||
|
are configured for ```[[inputs.exec]]``` in JSON format.
|
||||||
> __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
|
|
||||||
|
|
||||||
```
|
```
|
||||||
# Read flattened metrics from one or more commands that output JSON to stdout
|
# 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_"
|
name_prefix = "prefix_"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example 1
|
|
||||||
|
|
||||||
Let's say that we have the above configuration, and mycollector outputs the
|
Let's say that we have the above configuration, and mycollector outputs the
|
||||||
following JSON:
|
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
|
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]]
|
[[inputs.exec]]
|
||||||
|
@ -103,7 +99,7 @@ Now let's say we have the following configuration:
|
||||||
data_format = "influx"
|
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
|
cpu,cpu=cpu0,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||||
|
@ -118,15 +114,18 @@ 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,
|
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
|
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):
|
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)
|
* Nagios [Mertics Plugins] (https://exchange.nagios.org/directory/Plugins)
|
||||||
* Sensu [Mertics Plugins] (https://github.com/sensu-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
|
#### Configuration
|
||||||
```
|
```
|
||||||
# Read flattened metrics from one or more commands that output JSON to stdout
|
# 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*"
|
"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:
|
And test.sh/test2.sh will output:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue