mirror of
https://github.com/11notes/docker-telegraf.git
synced 2025-10-23 00:02:10 +00:00
first commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
maintain/
|
41
README.md
Normal file
41
README.md
Normal 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
46
amd64.dockerfile
Normal 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"]
|
25
rootfs/telegraf/etc/telegraf.conf
Normal file
25
rootfs/telegraf/etc/telegraf.conf
Normal 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"]
|
7
rootfs/usr/local/bin/entrypoint.sh
Normal file
7
rootfs/usr/local/bin/entrypoint.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/ash
|
||||
if [ -z "${1}" ]; then
|
||||
set -- "telegraf" \
|
||||
--config /telegraf/etc/telegraf.conf
|
||||
fi
|
||||
|
||||
exec "$@"
|
Reference in New Issue
Block a user