Skip to content

Commit 745be7d

Browse files
authored
Merge pull request docker-library#1588 from influxdata/telegraf-additional-packages
Add docs for installing additional commands in telegraf image
2 parents 70760ca + ac7f6ef commit 745be7d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

telegraf/content.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,45 @@ $ docker run -d --name=telegraf \
207207
```
208208

209209
Refer to the docker [plugin documentation](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/docker/README.md) for more information.
210+
211+
### Install Additional Packages
212+
213+
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.
214+
215+
As an example this Dockerfile add the `mtr-tiny` image to the stock image and save it as `telegraf-mtr.docker`:
216+
217+
```dockerfile
218+
FROM telegraf:1.12.3
219+
220+
RUN apt-get update && apt-get install -y --no-install-recommends mtr-tiny && \
221+
rm -rf /var/lib/apt/lists/*
222+
```
223+
224+
Build the derivative image:
225+
226+
```console
227+
$ docker build -t telegraf-mtr:1.12.3 - < telegraf-mtr.docker
228+
```
229+
230+
Create a `telegraf.conf` configuration file:
231+
232+
```toml
233+
[[inputs.exec]]
234+
interval = "60s"
235+
commands=["mtr -C -n example.org"]
236+
timeout = "40s"
237+
data_format = "csv"
238+
csv_skip_rows = 1
239+
csv_column_names=["", "", "status", "dest", "hop", "ip", "loss", "snt", "", "", "avg", "best", "worst", "stdev"]
240+
name_override = "mtr"
241+
csv_tag_columns = ["dest", "hop", "ip"]
242+
243+
[[outputs.file]]
244+
files = ["stdout"]
245+
```
246+
247+
Run your derivative image:
248+
249+
```console
250+
$ docker run --name telegraf --rm -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf telegraf-mtr:1.12.3
251+
```

0 commit comments

Comments
 (0)