From fc164a56899596e4519a711aaaaaf391331a477c Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 19 May 2026 08:28:36 -0700 Subject: [PATCH] Add disk-space and DB-size monitoring to Telegraf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Telegraf now collects host filesystem usage ([[inputs.disk]], via a read-only /hostfs mount) and PostgreSQL database + per-table sizes ([[inputs.postgresql_extensible]]) into InfluxDB. Surfaces RIB growth and disk pressure — relevant now that the full-table GoBGP feed has pushed the openbmp DB to ~30 GB. Co-Authored-By: Claude Opus 4.7 (1M context) --- docker-compose.yml | 10 ++++++++++ telegraf/telegraf.conf | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index ec95bf9..21958ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -339,10 +339,20 @@ services: entrypoint: ["telegraf"] volumes: - /var/run/docker.sock:/var/run/docker.sock + # Host root, read-only — lets [[inputs.disk]] report the real host + # filesystems (Postgres/Kafka/InfluxDB data) instead of the container's. + - /:/hostfs:ro depends_on: - influxdb environment: - INFLUXDB_TOKEN=openbmp-telemetry-token + # Point gopsutil-based inputs (disk) at the host filesystem mount above. + - HOST_MOUNT_PREFIX=/hostfs + - HOST_PROC=/hostfs/proc + - HOST_SYS=/hostfs/sys + - HOST_ETC=/hostfs/etc + # PostgreSQL credentials for [[inputs.postgresql_extensible]] (DB size). + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-openbmp} # gNMI fleet — quoted, comma-separated host:port list. Default = the two # ESXi CORE routers; extend via GNMI_ADDRESSES in .env for more routers. - 'GNMI_ADDRESSES=${GNMI_ADDRESSES:-"10.100.0.100:57400", "10.100.0.200:57400"}' diff --git a/telegraf/telegraf.conf b/telegraf/telegraf.conf index 7c6aac3..872291d 100644 --- a/telegraf/telegraf.conf +++ b/telegraf/telegraf.conf @@ -64,6 +64,28 @@ total = true timeout = "10s" +## Host filesystem usage — free/used space on the volumes holding the +## Postgres data, Kafka, InfluxDB and the OpenBMP data root. The host root is +## bind-mounted read-only at /hostfs and HOST_MOUNT_PREFIX / HOST_PROC (set in +## docker-compose.yml) point the plugin at the host, not the container. +[[inputs.disk]] + interval = "60s" + ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs", "ramfs", "nsfs", "iso9660"] + +## PostgreSQL database + table sizes — tracks RIB growth, which expands +## sharply once the full-table GoBGP feed is ingesting (~1M routes). +[[inputs.postgresql_extensible]] + interval = "60s" + address = "host=localhost port=5432 user=openbmp password=${POSTGRES_PASSWORD} dbname=openbmp sslmode=disable" + [[inputs.postgresql_extensible.query]] + sqlquery = "SELECT datname, pg_database_size(datname) AS bytes FROM pg_database WHERE datname = 'openbmp'" + measurement = "postgresql_db_size" + tagvalue = "datname" + [[inputs.postgresql_extensible.query]] + sqlquery = "SELECT c.relname AS tablename, pg_total_relation_size(c.oid) AS bytes FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = 'public' AND c.relkind = 'r' ORDER BY 2 DESC LIMIT 20" + measurement = "postgresql_table_size" + tagvalue = "tablename" + ############################################################################### # OUTPUT PLUGINS # ###############################################################################