From c8d727a047bade8946474e47ff878406d982ece2 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Mon, 14 Oct 2019 16:44:27 -0700 Subject: [PATCH 1/3] Add docs for installing additional commands in telegraf image --- telegraf/content.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/telegraf/content.md b/telegraf/content.md index fd957c337..9a6d20d28 100644 --- a/telegraf/content.md +++ b/telegraf/content.md @@ -207,3 +207,42 @@ $ 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 DEBIAN_FRONTEND=noninteractive \ + 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 +``` From 4a710d2b2cd14dc7f3e55fdff6c7f804b22147d1 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Tue, 15 Oct 2019 12:10:45 -0700 Subject: [PATCH 2/3] Fix whitespace and remove DEBIAN_FRONTEND env var --- telegraf/content.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/telegraf/content.md b/telegraf/content.md index 9a6d20d28..f0c2bbff2 100644 --- a/telegraf/content.md +++ b/telegraf/content.md @@ -210,23 +210,25 @@ Refer to the docker [plugin documentation](https://github.com/influxdata/telegra ### 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. +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 DEBIAN_FRONTEND=noninteractive \ - apt-get update && apt-get install -y --no-install-recommends mtr-tiny && \ +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" @@ -243,6 +245,7 @@ Create a `telegraf.conf` configuration file: ``` Run your derivative image: + ```console $ docker run --name telegraf --rm -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf telegraf-mtr:1.12.3 ``` From ac7f6efc805dbcb2b31b6e9f98409578c2ec75c4 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Tue, 15 Oct 2019 12:13:29 -0700 Subject: [PATCH 3/3] Fix whitespace --- telegraf/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegraf/content.md b/telegraf/content.md index f0c2bbff2..43c344afd 100644 --- a/telegraf/content.md +++ b/telegraf/content.md @@ -210,7 +210,7 @@ Refer to the docker [plugin documentation](https://github.com/influxdata/telegra ### 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. +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`: