2015-08-20 20:40:23 +00:00
|
|
|
# Exec Plugin
|
|
|
|
|
2015-10-13 17:50:42 +00:00
|
|
|
The exec plugin can execute arbitrary commands which output JSON. Then it flattens JSON and finds
|
|
|
|
all numeric values, treating them as floats.
|
2015-08-20 20:40:23 +00:00
|
|
|
|
|
|
|
For example, if you have a json-returning command called mycollector, you could
|
|
|
|
setup the exec plugin with:
|
|
|
|
|
|
|
|
```
|
2016-01-14 23:55:53 +00:00
|
|
|
[[inputs.exec]]
|
|
|
|
command = "/usr/bin/mycollector --output=json"
|
|
|
|
name_suffix = "_mycollector"
|
|
|
|
interval = 10
|
2015-08-20 20:40:23 +00:00
|
|
|
```
|
|
|
|
|
2016-01-14 23:55:53 +00:00
|
|
|
The name suffix is appended to exec as "exec_name_suffix" to identify the input stream.
|
2015-09-23 18:21:42 +00:00
|
|
|
|
|
|
|
The interval is used to determine how often a particular command should be run. Each
|
|
|
|
time the exec plugin runs, it will only run a particular command if it has been at least
|
|
|
|
`interval` seconds since the exec plugin last ran the command.
|
2015-10-13 17:50:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Sample
|
|
|
|
|
2016-01-14 23:55:53 +00:00
|
|
|
Let's say that we have a command with the name_suffix "_mycollector", which gives the following output:
|
2015-10-13 17:50:42 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"a": 0.5,
|
|
|
|
"b": {
|
|
|
|
"c": "some text",
|
|
|
|
"d": 0.1,
|
|
|
|
"e": 5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-01-14 23:55:53 +00:00
|
|
|
The collected metrics will be stored as field values under the same measurement "exec_mycollector":
|
2015-10-13 17:50:42 +00:00
|
|
|
```
|
2016-01-14 23:55:53 +00:00
|
|
|
exec_mycollector a=0.5,b_c="some text",b_d=0.1,b_e=5 1452815002357578567
|
2015-10-13 17:50:42 +00:00
|
|
|
```
|