Merge pull request #1588 from influxdata/telegraf-additional-packages

Add docs for installing additional commands in telegraf image
This commit is contained in:
yosifkit 2019-11-04 14:10:40 -08:00 committed by GitHub
commit 745be7d580
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 42 additions and 0 deletions

View File

@ -207,3 +207,45 @@ $ docker run -d --name=telegraf \
```
Refer to the docker [plugin documentation](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/docker/README.md) for more information.
### Install Additional Packages
Some plugins require additional packages to be installed. For example, the `ntpq` plugin requires `ntpq` command. It is recommended to create a custom derivative image to install any needed commands.
As an example this Dockerfile add the `mtr-tiny` image to the stock image and save it as `telegraf-mtr.docker`:
```dockerfile
FROM telegraf:1.12.3
RUN apt-get update && apt-get install -y --no-install-recommends mtr-tiny && \
rm -rf /var/lib/apt/lists/*
```
Build the derivative image:
```console
$ docker build -t telegraf-mtr:1.12.3 - < telegraf-mtr.docker
```
Create a `telegraf.conf` configuration file:
```toml
[[inputs.exec]]
interval = "60s"
commands=["mtr -C -n example.org"]
timeout = "40s"
data_format = "csv"
csv_skip_rows = 1
csv_column_names=["", "", "status", "dest", "hop", "ip", "loss", "snt", "", "", "avg", "best", "worst", "stdev"]
name_override = "mtr"
csv_tag_columns = ["dest", "hop", "ip"]
[[outputs.file]]
files = ["stdout"]
```
Run your derivative image:
```console
$ docker run --name telegraf --rm -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf telegraf-mtr:1.12.3
```