Add docker_log monitoring to telegraf

This commit is contained in:
Tobias Reisinger 2023-12-13 01:11:54 +01:00
parent 253206da97
commit a90840b1dc
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
8 changed files with 58 additions and 13 deletions

View file

@ -25,3 +25,9 @@ compose_file_volumes:
services:
app:
volumes: "{{ compose.volumes }}"
compose_file_monitoring_label:
services:
app:
labels:
com.influxdata.telegraf.enable: true

View file

@ -15,6 +15,7 @@ svc:
compose:
watchtower: true
monitoring: true
image: joohoi/acme-dns
volumes:
- ./config:/etc/acme-dns:ro

View file

@ -26,7 +26,10 @@ compose:
watchtower: true
image: ghcr.io/coder/coder:latest
env: true
group_add:
- "972" # docker group on host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
file:
services:
app:
group_add:
- "972" # docker group on host

View file

@ -30,3 +30,11 @@
ignored_databases = ["postgres", "template0", "template1"]
prepared_statements = true
[[inputs.docker_log]]
endpoint = "{{ svc.docker_log.endpoint }}"
docker_label_include = [
"com.influxdata.telegraf.enable"
]
source_tag = {{ svc.docker_log.source_tag|lower }}

View file

@ -18,12 +18,38 @@ svc:
host: "{{ postgres.host }}"
port: "{{ postgres.port }}"
database: "telegraf"
docker_log:
endpoint: "unix:///var/run/docker.sock"
# from_beginning: false
# timeout: "5s"
# container_name_include: []
# container_name_exclude: []
# docker_label_include: []
# docker_label_exclude: []
## Set the source tag for the metrics to the container ID hostname, eg first 12 chars
source_tag: false
## Optional TLS Config
# tls_ca: "/etc/telegraf/ca.pem"
# tls_cert: "/etc/telegraf/cert.pem"
# tls_key: "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify: false
compose:
watchtower: false
image: telegraf:1.28
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
file:
services:
app:
user: telegraf
group_add:
- "972" # docker group on host
volumes:
data:

View file

@ -26,10 +26,10 @@ compose:
- app:/var/www/html:ro
- ./nginx.conf:/etc/nginx/nginx.conf
file:
services:
app:
depends_on:
- tt-rss
services:
tt-rss:
image: cthulhoo/ttrss-fpm-pgsql-static
restart: always

View file

@ -9,4 +9,8 @@
{%- set compose_file = compose_file | combine(compose_file_volumes, recursive=True) -%}
{%- endif -%}
{%- if compose.monitoring | default(False) -%}
{%- set compose_file = compose_file | combine(compose_file_monitoring_label, recursive=True) -%}
{%- endif -%}
{{ compose_file | to_nice_yaml }}

View file

@ -1,6 +1,3 @@
FROM ubuntu
FROM restic/restic
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update -y \
&& apt install -y curl restic
RUN apk add curl