diff --git a/checks.d/mysql.py b/checks.d/mysql.py index cbace47ccc..7057ae5259 100644 --- a/checks.d/mysql.py +++ b/checks.d/mysql.py @@ -1188,7 +1188,7 @@ def _query_exec_time_per_schema(self, db): # Fetches the avg query execution time per schema and returns the # value in microseconds - sql_avg_query_run_time = """SELECT schema_name, SUM(count_star) cnt, ROUND(AVG(avg_timer_wait)/1000000) AS avg_us + sql_avg_query_run_time = """SELECT schema_name, ROUND((SUM(sum_timer_wait) / SUM(count_star)) / 1000000) AS avg_us FROM performance_schema.events_statements_summary_by_digest WHERE schema_name IS NOT NULL GROUP BY schema_name""" @@ -1204,7 +1204,7 @@ def _query_exec_time_per_schema(self, db): schema_query_avg_run_time = {} for row in cursor.fetchall(): schema_name = str(row[0]) - avg_us = long(row[2]) + avg_us = long(row[1]) # set the tag as the dictionary key schema_query_avg_run_time["schema:{0}".format(schema_name)] = avg_us