Add disk-space and DB-size monitoring to Telegraf
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) <noreply@anthropic.com>
This commit is contained in:
parent
cffb835f30
commit
fc164a5689
@ -339,10 +339,20 @@ services:
|
|||||||
entrypoint: ["telegraf"]
|
entrypoint: ["telegraf"]
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /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:
|
depends_on:
|
||||||
- influxdb
|
- influxdb
|
||||||
environment:
|
environment:
|
||||||
- INFLUXDB_TOKEN=openbmp-telemetry-token
|
- 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
|
# gNMI fleet — quoted, comma-separated host:port list. Default = the two
|
||||||
# ESXi CORE routers; extend via GNMI_ADDRESSES in .env for more routers.
|
# 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"}'
|
- 'GNMI_ADDRESSES=${GNMI_ADDRESSES:-"10.100.0.100:57400", "10.100.0.200:57400"}'
|
||||||
|
|||||||
@ -64,6 +64,28 @@
|
|||||||
total = true
|
total = true
|
||||||
timeout = "10s"
|
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 #
|
# OUTPUT PLUGINS #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user