From bddc8cdba798cb149485cf6c5d44fa04529619a0 Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Sun, 9 Nov 2025 12:09:55 +0100 Subject: [PATCH] tweak logging from telegraf --- telegraf/telegraf.conf | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/telegraf/telegraf.conf b/telegraf/telegraf.conf index 2aec279..8741975 100644 --- a/telegraf/telegraf.conf +++ b/telegraf/telegraf.conf @@ -83,11 +83,11 @@ name_override = "borgmatic_split" ############################################################################### -# DATABASE +# DATABASES ############################################################################### [[inputs.postgresql_extensible]] - address = "host=${DATABASE_HOST} port=${DATABASE_PORT} user=${DATABASE_USER} password=${DATABASE_PASS} dbname=${DATABASE_NAME} sslmode=disable" + address = "host=host port=11111 user=postgres password=postgres dbname=postgres sslmode=disable" interval = "1m" [[inputs.postgresql_extensible.query]] @@ -95,10 +95,9 @@ SELECT datname, pg_database_size(datname) AS size_bytes - FROM pg_database WHERE datname NOT IN ('template0', 'template1') + FROM pg_database WHERE datname IN ('dagster', 'gitea', 'teslamate') """ - withdbname = true - measurement = "postgresql_database_size" + measurement = "postgres_db_size" [[inputs.postgresql_extensible.query]] sqlquery = """ @@ -109,8 +108,31 @@ FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND schemaname NOT LIKE '_timescaledb_%' """ - withdbname = false - measurement = "postgresql_table_size" + measurement = "postgres_table_size" + +[[inputs.postgresql_extensible]] + address = "host=${DATABASE_HOST} port=${DATABASE_PORT} user=${DATABASE_USER} password=${DATABASE_PASS} dbname=${DATABASE_NAME} sslmode=disable" + interval = "1m" + + [[inputs.postgresql_extensible.query]] + sqlquery = """ + SELECT + datname, + pg_database_size(datname) AS size_bytes + FROM pg_database WHERE datname IN ('homeassistant', 'fluentbit', 'telegraf') + """ + measurement = "postgres_db_size" + + [[inputs.postgresql_extensible.query]] + sqlquery = """ + SELECT + schemaname AS schema_name, + tablename AS table_name, + pg_total_relation_size(schemaname || '.' || tablename) AS size_bytes + FROM pg_tables + WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND schemaname NOT LIKE '_timescaledb_%' + """ + measurement = "postgres_table_size" ############################################################################### # OUTPUTS @@ -136,6 +158,7 @@ [[outputs.loki]] domain = "http://host:3100" timeout = "10s" + # TODO: configure which metrics to include [[outputs.mqtt]] servers = ["tcp://host:1883"] @@ -146,3 +169,4 @@ retain = false client_id = "telegraf" data_format = "json" + # TODO: configure which metrics to include