We recently went from Metricbeat 7.14 to 8.14
We have found idle metricbeat connections piling up in mysql.
Problem: We use the sql module to run queries on mysql. The queries use prepared statements. Since going to metricbeat 8, the connections leak, maybe a difference in the GO driver. The queries still work but the connections stay until we hit the mysql connection limit.
Duplicate: spin up a mysql 8.0 instance and use this sql.yml to query it.
Check connections to mysql
sample sql.yml:
# Module: sql
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/8.14/metricbeat-module-sql.html
- module: sql
metricsets:
- query
period: 10s
hosts: ["metricbeat:password(127.0.0.1:3306)/?multiStatements=true"]
driver: "mysql"
sql_query: |
SET @schema_name = 'mysql';
SET @sql = CONCAT(
'SELECT TABLE_NAME, TABLE_TYPE ',
'FROM information_schema.tables ',
'WHERE TABLE_SCHEMA = \'', @schema_name, '\''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
sql_response_format: table