MySQL 서버 느린 쿼리 비율 모니터

Microsoft.MySQLServer.ManagedServer.Unix.SlowQueryPct.Monitor (UnitMonitor)

Knowledge Base article:

요약

MySQL 서버 느린 쿼리가 모든 쿼리에 비교된 비율입니다. 느린 쿼리는 MySQL 데이터베이스에서 전역 변수 ‘long_query_time’보다 더 오래 실행되는 쿼리입니다. 이 모니터는 전역 상태 변수 ‘Slow_queries’의 느린 쿼리 수를 전역 상태 변수 ‘Queries’의 쿼리 수로 나눕니다. MySQL 5.0 및 5.1의 경우 쿼리 수는 전역 상태 변수 ‘Questions’, ‘Com_ping’, ‘Com_statistics’, ‘Com_stmt_prepare’, ‘Com_stmt_close’ 및 ‘Com_stmt_reset’의 합계입니다. 모니터 임계값은 에이전트에 대한 폴링에 반환된 평균 값에 대해 분석됩니다. 여기서 샘플 수 매개 변수가 평균 계산에 포함된 샘플 수를 제어합니다.

원인

비정상 상태는 전역 변수 ‘long_query_time’보다 더 큰 쿼리의 비율이 높음을 나타냅니다.

해결 방법

높은 비율의 느린 쿼리를 해결하기 위해 구성 파일에서 느린 쿼리 로깅을 켜면 느린 쿼리를 확인할 수 있습니다. 이 작업을 하려면 인스턴스 그룹 옵션 아래에 대상 로그 파일 경로와 함께 다음 줄을 추가합니다. “log-slow-queries= file path to log”. 또는 다음 옵션을 사용하여 서버를 시작할 수 있습니다. “--log-slow-queries=file path to log”.

구성

기본 구성

매개 변수

기본값

경고 임계값

15보다 큼

오류 임계값

25보다 큼

샘플 수

3

모든 인스턴스나 특정 인스턴스 또는 그룹에 대해 위에서 정의한 매개 변수 값을 변경하는 데 재정의를 사용할 수 있습니다.

Element properties:

TargetMicrosoft.MySQLServer.ManagedServer.Unix
Parent MonitorMicrosoft.MySQLServer.RowOperationsPerformanceRollup
CategoryPerformanceHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Oss.WSManEnumeration.GreaterThanThreshold.ThreeState.MonitorType
RemotableTrue
AccessibilityPublic
Alert Message
MySQL 서버 느린 쿼리 비율
MySQL 서버에 대한 현재 느린 쿼리 비율({0}\%)이 높습니다.
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.MySQLServer.ManagedServer.Unix.SlowQueryPct.Monitor" Accessibility="Public" Target="Microsoft.MySQLServer.ManagedServer.Unix" TypeID="Oss!Microsoft.Oss.WSManEnumeration.GreaterThanThreshold.ThreeState.MonitorType" Enabled="onStandardMonitoring" ParentMonitorID="Microsoft.MySQLServer.RowOperationsPerformanceRollup">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.MySQLServer.ManagedServer.Unix.SlowQueryPct.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Value$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState HealthState="Success" MonitorTypeStateID="StatusOK" ID="UnderThreshold"/>
<OperationalState HealthState="Warning" MonitorTypeStateID="StatusWarning" ID="OverWarningThreshold"/>
<OperationalState HealthState="Error" MonitorTypeStateID="StatusError" ID="OverErrorThreshold"/>
</OperationalStates>
<Configuration>
<Interval>300</Interval>
<TargetSystem>$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem>
<Uri>http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/MySQL_ServerStatistics?__cimnamespace=root/mysql</Uri>
<WSManFilter/>
<ObjectName>MySQL Server</ObjectName>
<CounterName>Slow Query Pct</CounterName>
<InstanceXPath>/DataItem/WsManData/*[local-name(.)='MySQL_ServerStatistics']/*[local-name(.)='InstanceID']</InstanceXPath>
<InstanceName>$Target/Property[Type="Microsoft.MySQLServer.Installation"]/InstanceID$</InstanceName>
<Value>$Data/WsManData/*[local-name(.)='MySQL_ServerStatistics']/*[local-name(.)='SlowQueryPct']$</Value>
<WarningThreshold>15</WarningThreshold>
<ErrorThreshold>25</ErrorThreshold>
<NumSamples>3</NumSamples>
</Configuration>
</UnitMonitor>