diff --git a/mysql/changelog.d/18450.fixed b/mysql/changelog.d/18450.fixed new file mode 100644 index 00000000000000..168b96fdd466e7 --- /dev/null +++ b/mysql/changelog.d/18450.fixed @@ -0,0 +1 @@ +Handles mysql azure flexible server warning bug diff --git a/mysql/datadog_checks/mysql/activity.py b/mysql/datadog_checks/mysql/activity.py index 848529efef5ffa..ec987f0e5aab45 100644 --- a/mysql/datadog_checks/mysql/activity.py +++ b/mysql/datadog_checks/mysql/activity.py @@ -135,21 +135,21 @@ def run_job(self): self._log.debug( 'Waiting for events_waits_current availability to be determined by the check, skipping run.' ) - # Azure flexible server - azure_deployment_type = self._config.cloud_metadata.get("azure", {}).get("deployment_type") - if self._check.events_wait_current_enabled is False and azure_deployment_type != 'flexible_server': - self._check.record_warning( - DatabaseConfigurationError.events_waits_current_not_enabled, - warning_with_tags( - 'Query activity and wait event collection is disabled on this host. To enable it, the setup ' - 'consumer `performance-schema-consumer-events-waits-current` must be enabled on the MySQL server. ' - 'Please refer to the troubleshooting documentation: ' - 'https://docs.datadoghq.com/database_monitoring/setup_mysql/troubleshooting#%s', - DatabaseConfigurationError.events_waits_current_not_enabled.value, - code=DatabaseConfigurationError.events_waits_current_not_enabled.value, - host=self._check.resolved_hostname, - ), - ) + if self._check.events_wait_current_enabled is False: + azure_deployment_type = self._config.cloud_metadata.get("azure", {}).get("deployment_type") + if azure_deployment_type != "flexible_server": + self._check.record_warning( + DatabaseConfigurationError.events_waits_current_not_enabled, + warning_with_tags( + 'Query activity and wait event collection is disabled on this host. To enable it, the setup ' + 'consumer `performance-schema-consumer-events-waits-current` must be enabled on the MySQL server. ' + 'Please refer to the troubleshooting documentation: ' + 'https://docs.datadoghq.com/database_monitoring/setup_mysql/troubleshooting#%s', + DatabaseConfigurationError.events_waits_current_not_enabled.value, + code=DatabaseConfigurationError.events_waits_current_not_enabled.value, + host=self._check.resolved_hostname, + ), + ) return self._check_version() self._collect_activity() diff --git a/mysql/tests/test_query_activity.py b/mysql/tests/test_query_activity.py index 936dbdc8d8948a..1833b5a3daf3af 100644 --- a/mysql/tests/test_query_activity.py +++ b/mysql/tests/test_query_activity.py @@ -476,28 +476,30 @@ def test_events_wait_current_disabled(dbm_instance, dd_run_check, root_conn, agg assert check.warnings == [] assert dbm_activity, "should have collected at least one activity" + @pytest.mark.integration @pytest.mark.usefixtures('dd_environment') @pytest.mark.parametrize( "cloud_metadata", [ - ( - { - 'azure': { - 'deployment_type': 'flexible_server', - 'name': 'my-instance', - }, + { + 'azure': { + 'deployment_type': 'flexible_server', + 'name': 'my-instance', }, - ), - ] + }, + ], ) -def test_events_wait_current_disabled_no_warning_azure_flexible_server(dbm_instance, dd_run_check, root_conn, aggregator, cloud_metadata): +def test_events_wait_current_disabled_no_warning_azure_flexible_server( + dbm_instance, dd_run_check, root_conn, aggregator, cloud_metadata +): ''' This test verifies that the check will not emit a warning if the events_waits_current is disabled and Azure deployment_type is flexible_server. ''' if cloud_metadata: for k, v in cloud_metadata.items(): dbm_instance[k] = v + dbm_instance['options']['extra_performance_metrics'] = False check = MySql(CHECK_NAME, {}, [dbm_instance]) # disable events_waits_current, expect events_wait_current_enabled to be set to False