Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DP-1537: Limit Influx db volume getting huge overtime #20

Merged
merged 8 commits into from
May 23, 2024
16 changes: 11 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
ARG TELEGRAF_VERSION="1.24-alpine"
ARG TELEGRAF_VERSION="1.30-alpine"
FROM telegraf:${TELEGRAF_VERSION}

ARG ENVIRONMENT="production"

# Labels
LABEL description="MOV.AI metrics collector"
LABEL maintainer="[email protected]"
LABEL movai="telegraf"
LABEL environment="develop"
LABEL environment=$ENVIRONMENT

COPY files/telegraf.conf /etc/telegraf/telegraf.conf
# Copy configuration files
COPY files/telegraf_debug.conf /etc/telegraf/telegraf_debug.conf
COPY files/telegraf_production.conf /etc/telegraf/telegraf_production.conf
COPY files/entrypoint.sh /entrypoint.sh

RUN chmod o+w /etc/telegraf/telegraf.conf
ENV TELEGRAF_CONFIG_LEVEL $ENVIRONMENT

# Rest is upstream
RUN chmod o+w /etc/telegraf/telegraf_debug.conf /etc/telegraf/telegraf_production.conf \
&& rm -f /etc/telegraf/telegraf.conf \
&& chmod +x /entrypoint.sh
7 changes: 5 additions & 2 deletions files/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
set -e
TELEGRAF_CONFIG_PATH=/etc/telegraf/telegraf_${TELEGRAF_CONFIG_LEVEL}.conf

# Check if linux_cpu inputs required files exist
enable_plugin_cpufreq=false
Expand Down Expand Up @@ -36,16 +37,18 @@ if [ "$enable_plugin_thermalthrottle" = "true" ]; then
metrics="${metrics},\"thermal\""
fi

if [ -n "$metrics" ] && ! grep linux_cpu /etc/telegraf/telegraf.conf -q; then
if [ -n "$metrics" ] && ! grep linux_cpu $TELEGRAF_CONFIG_PATH -q; then
# Include the configuration for the [[inputs.linux_cpu]] plugin
cat <<EOF >> /etc/telegraf/telegraf.conf
cat <<EOF >> $TELEGRAF_CONFIG_PATH

[[inputs.linux_cpu]]
host_sys = "/hostfs/sys"
metrics = [$metrics]
EOF
fi

ln -sf $TELEGRAF_CONFIG_PATH /etc/telegraf/telegraf.conf

if [ "${1:0:1}" = '-' ]; then
set -- telegraf "$@"
fi
Expand Down
59 changes: 59 additions & 0 deletions files/telegraf_debug.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[global_tags]
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "1s"
flush_interval = "10s"
flush_jitter = "0s"
precision = "0s"
debug = false
quiet = false
hostname = "{{.Hostname}}"
mariana-dias-alves marked this conversation as resolved.
Show resolved Hide resolved
omit_hostname = false
[[outputs.influxdb]]
urls = ["udp://influxdb:9096"] # required
database = "telegraf" # required
retention_policy = ""
write_consistency = "any"
timeout = "5s"
udp_payload = "61440B"
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
core_tags = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs", "nsfs", "fuse.portal", "fuse.gvfsd-fuse", "fuse.lxcfs", "fuse.dockerfs", "fuse", "hugetlbfs", "mqueue", "vfat"]
[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.docker]]
endpoint = "unix:///var/run/docker.sock"
timeout = "5s"
perdevice = false
perdevice_include = ["cpu", "blkio", "network"]
[[inputs.influxdb]]
urls = [
"http://influxdb:8086/debug/vars"
]
timeout = "5s"
[[inputs.internal]]
collect_memstats = true
[[inputs.linux_sysctl_fs]]
[[inputs.netstat]]
[[inputs.procstat]]
pattern = "."
pid_finder = "native"
tag_with = ["cmdline"]
[[inputs.wireless]]
host_proc = "/hostfs/proc/1"
[[inputs.docker_log]]
endpoint = "unix:///var/run/docker.sock"
[[inputs.redis]]
servers = ["tcp://redis-local:6379","tcp://redis-master:6379"]
Loading
Loading