first commit

This commit is contained in:
11notes
2022-10-18 14:43:49 +02:00
parent 1d1321fbb9
commit 3b0e3ff8cf
5 changed files with 120 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
maintain/

41
README.md Normal file
View File

@@ -0,0 +1,41 @@
# Info
The plugin-driven server agent for collecting & reporting metrics.
This container provides an easy and simple way to use telegraf without the hassle of library dependencies and compiling the source yourself.
## Volumes
None
## Run
```shell
docker run --name telegraf \
-v /.../telegraf.conf:/telegraf/etc/telegraf.conf:ro \
-d 11notes/telegraf:[tag]
```
# Examples telegraf.conf
```shell
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = "0s"
hostname = "telegraf"
[[outputs.influxdb_v2]]
urls = ["http://localhost:8086"]
token = "**********************************************"
organization = "influxdb"
bucket = "global"
[[inputs.prometheus]]
urls = ["http://localhost:8080/metrics"]
```
## Build with
* [telegraf](https://github.com/influxdata/telegraf) - Telegraf
* [Alpine Linux](https://alpinelinux.org/) - Alpine Linux

46
amd64.dockerfile Normal file
View File

@@ -0,0 +1,46 @@
# :: Build
FROM golang:alpine as telegraf
ENV checkout=v1.24.2
RUN set -ex; \
apk add --update --no-cache \
make \
git; \
git clone https://github.com/influxdata/telegraf.git; \
cd /go/telegraf; \
git checkout ${checkout}; \
make build -j $(nproc); \
mv telegraf /usr/local/bin;
# :: Header
FROM alpine:3.16
COPY --from=telegraf /usr/local/bin/ /usr/local/bin
# :: Run
USER root
# :: prepare
RUN set -ex; \
mkdir -p /telegraf; \
mkdir -p /telegraf/etc;
RUN set -ex; \
apk add --update --no-cache \
shadow;
RUN set -ex; \
addgroup --gid 1000 -S telegraf; \
adduser --uid 1000 -D -S -h /telegraf -s /sbin/nologin -G telegraf telegraf;
# :: copy root filesystem changes
COPY ./rootfs /
# :: docker -u 1000:1000 (no root initiative)
RUN set -ex; \
chown -R telegraf:telegraf \
/telegraf
# :: Start
RUN set -ex; chmod +x /usr/local/bin/entrypoint.sh
USER telegraf
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

View File

@@ -0,0 +1,25 @@
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = "0s"
hostname = "telegraf"
###############################################################################
# OUTPUT PLUGINS #
###############################################################################
[[outputs.influxdb_v2]]
urls = ["http://localhost:8086"]
token = "**********************************************"
organization = "influxdb"
bucket = "global"
###############################################################################
# INPUT PLUGINS #
###############################################################################
[[inputs.prometheus]]
urls = ["http://localhost:8080/metrics"]

View File

@@ -0,0 +1,7 @@
#!/bin/ash
if [ -z "${1}" ]; then
set -- "telegraf" \
--config /telegraf/etc/telegraf.conf
fi
exec "$@"