From f23099c038a13a817c768f31bf785cd4c815d1d2 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 7 Nov 2024 12:22:54 +1100 Subject: [PATCH] fix(inputs.mysql): MariaDB example to include mariadb_dialect (#16159) Also use MariaDB names and healthcheck to ensure running before telegraf started. --- plugins/inputs/mysql/dev/docker-compose.yml | 29 ++++++++++++++------- plugins/inputs/mysql/dev/telegraf.conf | 1 + 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/plugins/inputs/mysql/dev/docker-compose.yml b/plugins/inputs/mysql/dev/docker-compose.yml index 5f1773fbcc540..e3cb98cbc0851 100644 --- a/plugins/inputs/mysql/dev/docker-compose.yml +++ b/plugins/inputs/mysql/dev/docker-compose.yml @@ -13,11 +13,17 @@ services: image: mariadb restart: always environment: - MYSQL_ROOT_PASSWORD: telegraf - MYSQL_DATABASE: telegraf - MYSQL_USER: telegraf - MYSQL_PASSWORD: telegraf - command: mysqld --userstat=1 + MARIADB_ROOT_PASSWORD: telegraf + MARIADB_DATABASE: telegraf + MARIADB_USER: telegraf + MARIADB_PASSWORD: telegraf + command: --userstat=1 + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 percona: image: percona restart: always @@ -30,12 +36,15 @@ services: telegraf: image: glinton/scratch depends_on: - - mysql - - maria - - percona + maria: + condition: service_healthy + mysql: + condition: service_started + percona: + condition: service_started volumes: - - ./telegraf.conf:/telegraf.conf - - ../../../../telegraf:/telegraf + - ./telegraf.conf:/telegraf.conf:z + - ../../../../telegraf:/telegraf:z entrypoint: - /telegraf - --config diff --git a/plugins/inputs/mysql/dev/telegraf.conf b/plugins/inputs/mysql/dev/telegraf.conf index 9aa4801eaa938..e40eaee6d6d4d 100644 --- a/plugins/inputs/mysql/dev/telegraf.conf +++ b/plugins/inputs/mysql/dev/telegraf.conf @@ -22,6 +22,7 @@ ## mariadb #[[inputs.mysql]] # servers = ["root:telegraf@tcp(maria:3306)/"] +# mariadb_dialect = true # gather_table_schema = true # gather_process_list = true # gather_user_statistics = true