Migración a La Cumbre de innovación:
Obtenga información sobre cómo migrar y modernizar a Azure puede aumentar el rendimiento, la resistencia y la seguridad de su empresa, lo que le permite adoptar completamente la inteligencia artificial.Regístrese ahora
Este explorador ya no se admite.
Actualice a Microsoft Edge para aprovechar las características y actualizaciones de seguridad más recientes, y disponer de soporte técnico.
Monitor Azure Database for MySQL - Flexible Server
Artículo
Azure Monitor collects and aggregates metrics and logs from your system to monitor availability, performance, and resilience, and notify you of issues affecting your system. You can use the Azure portal, PowerShell, Azure CLI, REST API, or client libraries to set up and view monitoring data.
Different metrics and logs are available for different resource types. This article describes the types of monitoring data you can collect for this service and ways to analyze that data.
Collect data with Azure Monitor
This table describes how you can collect data to monitor your service, and what you can do with the data once collected:
Data to collect
Description
How to collect and route the data
Where to view the data
Supported data
Metric data
Metrics are numerical values that describe an aspect of a system at a particular point in time. Metrics can be aggregated using algorithms, compared to other metrics, and analyzed for trends over time.
- Collected automatically at regular intervals. - You can route some platform metrics to a Log Analytics workspace to query with other data. Check the DS export setting for each metric to see if you can use a diagnostic setting to route the metric data.
Logs are recorded system events with a timestamp. Logs can contain different types of data, and be structured or free-form text. You can route resource log data to Log Analytics workspaces for querying and analysis.
The Azure Monitor activity log provides insight into subscription-level events. The activity log includes information like when a resource is modified or a virtual machine is started.
Built in monitoring for Azure Database for MySQL - Flexible Server
Azure Database for MySQL - Flexible Server offers built-in resources for monitoring.
Server logs
In Azure Database for MySQL Flexible Server, users can configure and download server logs to assist with troubleshooting efforts. With this feature enabled, an Azure Database for MySQL Flexible Server instance starts capturing events of the selected log type and writes them to a file. You can then use the Azure portal and Azure CLI to download the files to work with them.
Server logs support enabling and downloading slow query logs and error logs.
To perform a historical analysis of your data, in the Azure portal, on the Diagnostics settings pane for your server, add a diagnostic setting to send the logs to the Log Analytics workspace, Azure Storage, or event hubs. For more information, see Set up diagnostics.
When logging is enabled for an Azure Database for MySQL Flexible Server instance, logs are available up to seven days from their creation. If the total size of the available logs exceeds 7 GB, then the oldest files are deleted until space is available.
The 7-GB storage limit for server logs is available free of cost and can't be extended.
Logs are rotated every 24 hours or 500 MB, whichever comes first.
Slow query logs in Azure Database for MySQL - Flexible Server
In Azure Database for MySQL Flexible Server, the slow query log is available to users to configure and access. Slow query logs are disabled by default and can be enabled to assist with identifying performance bottlenecks during troubleshooting.
For more information about the MySQL slow query log, see the slow query log section in the MySQL engine documentation.
Configure slow query logging
By default, the slow query log is disabled. To enable logs, set the slow_query_log server parameter to ON. This parameter can be configured using the Azure portal or Azure CLI.
Other parameters you can adjust to control slow query logging behavior include:
long_query_time: log a query if it takes longer than long_query_time (in seconds) to complete. The default is 10 seconds. Server parameter long_query_time applies globally to all newly established connections in MySQL. However, it doesn't affect threads that are already connected. We recommended that you reconnect to Azure Database for MySQL Flexible Server from the application or restart the server to clear out threads with older values of long_query_time and apply the updated parameter value.
log_slow_admin_statements: determines if administrative statements (ex. ALTER_TABLE, ANALYZE_TABLE) are logged.
log_queries_not_using_indexes: determines if queries that don't use indexes are logged.
log_throttle_queries_not_using_indexes: limits the number of nonindexed queries that can be written to the slow query log. This parameter takes effect when log_queries_not_using_indexes is set to ON
Importante
If your tables aren't indexed, setting the log_queries_not_using_indexes and log_throttle_queries_not_using_indexes parameters to ON might affect MySQL performance. All queries that run against these nonindexed tables are written to the slow query log.
Slow query logs are integrated with Azure Monitor diagnostic settings. After you enable slow query logs on your Azure Database for MySQL Flexible Server instance, you can emit them to Azure Monitor logs, Event Hubs, or Azure Storage. To learn more about diagnostic settings, see the diagnostic logs documentation. To learn more about how to enable diagnostic settings in the Azure portal, see the slow query log portal article.
Nota
Premium Storage accounts aren't supported if you're sending the logs to Azure storage via diagnostics and settings.
The following table describes the output of the slow query log. Depending on the output method, the fields included and the order in which they appear might vary.
Property
Description
TenantId
Your tenant ID
SourceSystem
Azure
TimeGenerated [UTC]
Time stamp when the log was recorded in UTC
Type
Type of the log. Always AzureDiagnostics
SubscriptionId
GUID for the subscription that the server belongs to
ResourceGroup
Name of the resource group the server belongs to
ResourceProvider
Name of the resource provider. Always MICROSOFT.DBFORMYSQL
For sql_text_s, log is truncated if it exceeds 2048 characters.
Track database activity with Audit Logs
Azure Database for MySQL flexible server provides users with the ability to configure audit logs. Audit logs can be used to track database-level activity including connection, admin, DDL, and DML events. These types of logs are commonly used for compliance purposes.
Configure audit logging
Importante
We recommend to only log the event types and users required for your auditing purposes. This approach helps to ensure your server's performance isn't heavily affected and a minimum amount of data is collected.
By default, audit logs are disabled. To enable them, set the audit_log_enabled server parameter to ON. Enable audit logs using the Azure portal or Azure CLI.
Other parameters you can adjust to control audit logging behavior include:
audit_log_events: controls the events to be logged. See the following table for specific audit events.
audit_log_include_users: MySQL users to be included for logging. The default value for this parameter is empty, which includes all the users for logging. This parameter has higher priority over audit_log_exclude_users. Max length of the parameter is 512 characters. For example, wildcard value of dev* includes all the users with entries starting with keyword dev like dev1,dev_user,dev_2. Another example for wildcard entry for including user is *dev in this example, all users ending with value "dev" like "stage_dev,prod_dev,user_dev" are included in the audit log entries. Additionally, the use of a question mark (?) as a wildcard character is permitted in patterns.
audit_log_exclude_users: MySQL users to be excluded from logging. The Max length of the parameter is 512 characters. Wildcard entries for user are also accepted to exclude users in audit logs. For example, wildcard value of stage* excludes all the users with entries starting with keyword stage like stage1,stage_user,stage_2. Another example for wildcard entry for excluding user is *com. In this example, all users ending with value com are excluded from the audit log entries. Additionally, the use of a question mark (?) as a wildcard character is permitted in patterns.
Nota
audit_log_include_users has higher priority over audit_log_exclude_users. For example, if audit_log_include_users = demouser and audit_log_exclude_users = demouser, the user is included in the audit logs because audit_log_include_users has higher priority.
All in DML_SELECT, DML_NONSELECT, DML, DDL, DCL, and ADMIN
TABLE_ACCESS
- Table read statements, such as SELECT or INSERT INTO ... SELECT - Table delete statements, such as DELETE or TRUNCATE TABLE - Table insert statements, such as INSERT or REPLACE - Table update statements, such as UPDATE
Access audit logs
Audit logs are integrated with Azure Monitor diagnostic settings. After you enable audit logs on your flexible server, you can emit them to Azure Monitor logs, Azure Event Hubs, or Azure Storage. To learn more about diagnostic settings, see the diagnostic logs documentation. To learn more about how to enable diagnostic settings in the Azure portal, see the audit log portal article.
Nota
Premium Storage accounts aren't supported if you send the logs to Azure storage via diagnostics and settings.
Depending on the output method, the fields included and the order in which they appear might vary.
Connection:
Property
Description
TenantId
Your tenant ID
SourceSystem
Azure
TimeGenerated [UTC]
Time stamp when the log was recorded in UTC
Type
Type of the log. Always AzureDiagnostics
SubscriptionId
GUID for the subscription that the server belongs to
ResourceGroup
Name of the resource group the server belongs to
ResourceProvider
Name of the resource provider. Always MICROSOFT.DBFORMYSQL
ResourceType
Servers
ResourceId
Resource URI
Resource
Name of the server in upper case
Category
MySqlAuditLogs
OperationName
LogEvent
LogicalServerName_s
Name of the server
event_class_s
connection_log
event_subclass_s
CONNECT, DISCONNECT, CHANGE USER
connection_id_d
Unique connection ID generated by MySQL
host_s
Blank
ip_s
IP address of client connecting to MySQL
user_s
Name of user executing the query
db_s
Name of database connected to
\_ResourceId
Resource URI
status_d
Connection Error code entry for CONNECTIONS_V2 event.
General:
The following Schema applies to GENERAL, DML_SELECT, DML_NONSELECT, DML, DDL, DCL, and ADMIN event types.
Nota
For sql_text_s, log is truncated if it exceeds 2048 characters.
Property
Description
TenantId
Your tenant ID
SourceSystem
Azure
TimeGenerated [UTC]
Time stamp when the log was recorded in UTC
Type
Type of the log. Always AzureDiagnostics
SubscriptionId
GUID for the subscription that the server belongs to
ResourceGroup
Name of the resource group the server belongs to
ResourceProvider
Name of the resource provider. Always MICROSOFT.DBFORMYSQL
ResourceType
Servers
ResourceId
Resource URI
Resource
Name of the server in upper case
Category
MySqlAuditLogs
OperationName
LogEvent
LogicalServerName_s
Name of the server
event_class_s
general_log
event_subclass_s
LOG, ERROR, RESULT (only available for MySQL 5.6)
event_time
Query start time in UTC timestamp
error_code_d
Error code if query failed. 0 means no error
thread_id_d
ID of thread that executed the query
host_s
Blank
ip_s
IP address of client connecting to MySQL
user_s
Name of user executing the query
sql_text_s
Full query text
\_ResourceId
Resource URI
Table access:
Nota
For sql_text_s, log is truncated if it exceeds 2048 characters.
Property
Description
TenantId
Your tenant ID
SourceSystem
Azure
TimeGenerated [UTC]
Time stamp when the log was recorded in UTC
Type
Type of the log. Always AzureDiagnostics
SubscriptionId
GUID for the subscription that the server belongs to
ResourceGroup
Name of the resource group the server belongs to
ResourceProvider
Name of the resource provider. Always MICROSOFT.DBFORMYSQL
ResourceType
Servers
ResourceId
Resource URI
Resource
Name of the server in upper case
Category
MySqlAuditLogs
OperationName
LogEvent
LogicalServerName_s
Name of the server
event_class_s
table_access_log
event_subclass_s
READ, INSERT, UPDATE, or DELETE
connection_id_d
Unique connection ID generated by MySQL
db_s
Name of database accessed
table_s
Name of table accessed
sql_text_s
Full query text
\_ResourceId
Resource URI
Use Azure Monitor workbooks
Azure Database for MySQL flexible server is now integrated with Azure Monitor workbooks. With workbooks, you get a flexible canvas for analyzing data and creating rich visual reports within the Azure portal. Workbooks allow you to tap into multiple data sources across Azure and combine them into unified interactive experiences. Workbook templates serve as curated reports that multiple users and teams design for flexible reuse.
When you open a template, you create a transient workbook that's populated with the contents of the template. With this integration, the server links to workbooks and a few sample templates, which can help you monitor the service at scale. You can edit these templates, customize them to your requirements, and pin them to the dashboard to create a focused and organized view of Azure resources.
Azure Database for MySQL flexible server has three available templates:
Overview: Displays an instance summary and top-level metrics to help you visualize and understand the resource utilization on your server. This template displays the following views:
Server Summary
Database Summary
Connection Metrics
Performance Metrics
Storage Metrics
Auditing: Displays a summary and details of the auditing events that are collected for the server. This template displays the following views:
Administrative Actions on the service
Audit Summary
Audit Connection Events Summary
Audit Connection Events
Table Access Summary
Errors Identified
Query Performance Insight: Displays a summary and details of query workload on the instance, long running query, slow query analysis, and connection metrics. This template displays the following views:
Query Load
Total Active Connections
Slow Query Trend (>10 seconds of query time)
Slow Query Details
List top five longest queries
Summarize slow queries by minimum, maximum, average, and standard deviation query time
You can also edit and customize these templates according to your requirements. For more information, see Azure Workbooks.
Access the workbook templates
To view the templates in the Azure portal, go to the Monitoring pane for Azure Database for MySQL flexible server, and then select Workbooks.
You can also display the list of templates by going to the Public Templates pane.
Use Azure Monitor tools to analyze the data
These Azure Monitor tools are available in the Azure portal to help you analyze monitoring data:
Some Azure services have a built-in monitoring dashboard in the Azure portal. These dashboards are called insights, and you can find them in the Insights section of Azure Monitor in the Azure portal.
The Azure portal has a user interface for viewing and basic searches of the activity log. To do more in-depth analysis, route the data to Azure Monitor logs and run more complex queries in Log Analytics.
Application Insights monitors the availability, performance, and usage of your web applications, so you can identify and diagnose errors without waiting for a user to report them. Application Insights includes connection points to various development tools and integrates with Visual Studio to support your DevOps processes. For more information, see Application monitoring for App Service.
Tools that allow more complex visualization include:
Dashboards that let you combine different kinds of data into a single pane in the Azure portal.
Workbooks, customizable reports that you can create in the Azure portal. Workbooks can include text, metrics, and log queries.
Grafana, an open platform tool that excels in operational dashboards. You can use Grafana to create dashboards that include data from multiple sources other than Azure Monitor.
Power BI, a business analytics service that provides interactive visualizations across various data sources. You can configure Power BI to automatically import log data from Azure Monitor to take advantage of these visualizations.
Export Azure Monitor data
You can export data out of Azure Monitor into other tools using:
You can analyze Azure Monitor Log data using the Kusto query language (KQL). For more information, see Log queries in Azure Monitor.
Recommended Kusto queries for Azure Database for MySQL - Flexible Server
You can use slow query logs to find candidates for optimization. After your slow query logs are piped to Azure Monitor Logs through Diagnostic Logs, you can perform further analysis of your slow queries. These sample queries can get you started. Make sure to update them with your server name.
Queries longer than 10 seconds on a particular server
Kusto
AzureDiagnostics
| where Resource == '<your server name>'
| where Category == 'MySqlSlowLogs'
| project TimeGenerated, Resource , event_class_s, start_time_t , query_time_d, sql_text_s
| where query_time_d > 10
List top five longest queries on a particular server
Kusto
AzureDiagnostics
| where Resource == '<your server name>'
| where Category == 'MySqlSlowLogs'
| project TimeGenerated, Resource , event_class_s, start_time_t , query_time_d, sql_text_s
| orderby query_time_d desc
| take5
Summarize slow queries by minimum, maximum, average, and standard deviation query time on a particular server
Kusto
AzureDiagnostics
| where Resource == '<your server name>'
| where Category == 'MySqlSlowLogs'
| project TimeGenerated, Resource , event_class_s, start_time_t , query_time_d, sql_text_s
| summarizecount(), min(query_time_d), max(query_time_d), avg(query_time_d), stdev(query_time_d), percentile(query_time_d, 95) by Resource
Graph the slow query distribution on a particular server
Kusto
AzureDiagnostics
| where Resource == '<your server name>'
| where Category == 'MySqlSlowLogs'
| project TimeGenerated, Resource , event_class_s, start_time_t , query_time_d, sql_text_s
| summarizecount() by Resource , bin(TimeGenerated, 5m)
| rendertimechart
Display queries longer than 10 seconds across all Azure Database for MySQL Flexible Server instances with Diagnostic Logs enabled
For audit logs, after your audit logs are piped to Azure Monitor Logs through Diagnostic Logs, you can perform further analysis of your audited events. These sample queries can get you started. Make sure to update them with your server name.
List GENERAL events on a particular server
Kusto
AzureDiagnostics
| where Resource == '<your server name>'//Server name must be in Upper case
| where Category == 'MySqlAuditLogs'and event_class_s == "general_log"
| project TimeGenerated, Resource, event_class_s, event_subclass_s, event_time_t, user_s , ip_s , sql_text_s
| orderby TimeGenerated ascnullslast
List CONNECTION_V2 events on a particular server, status_d column denotes the client connection error code faced by the client application while connecting.
Kusto
AzureDiagnostics
| where Resource == '<your server name>'//Server name must be in Upper case
| where Category == 'MySqlAuditLogs'and event_subclass_s == "CONNECT"
| project TimeGenerated, Resource, event_class_s, event_subclass_s, user_s, ip_s, status_d
| orderby TimeGenerated ascnullslast
List CONNECTION events on a particular server
Kusto
AzureDiagnostics
| where Resource == '<your server name>'//Server name must be in Upper case
| where Category == 'MySqlAuditLogs'and event_class_s == "connection_log"
| project TimeGenerated, Resource, event_class_s, event_subclass_s, event_time_t, user_s , ip_s , sql_text_s
| orderby TimeGenerated ascnullslast
Summarize audited events on a particular server
Kusto
AzureDiagnostics
| where Resource == '<your server name>'//Server name must be in Upper case
| where Category == 'MySqlAuditLogs'
| project TimeGenerated, Resource, event_class_s, event_subclass_s, event_time_t, user_s , ip_s , sql_text_s
| summarizecount() by event_class_s, event_subclass_s, user_s, ip_s
Graph the audit event type distribution on a particular server
Kusto
AzureDiagnostics
| where Resource == '<your server name>'//Server name must be in Upper case
| where Category == 'MySqlAuditLogs'
| project TimeGenerated, Resource, event_class_s, event_subclass_s, event_time_t, user_s , ip_s , sql_text_s
| summarizecount() by Resource, bin(TimeGenerated, 5m)
| rendertimechart
List audited events across all Azure Database for MySQL Flexible Server instances with Diagnostic Logs enabled for audit logs
Azure Monitor alerts allow you to identify and address issues in your system, and proactively notify you when specific conditions are found in your monitoring data before your customers notice them. You can alert on any metric or log data source in the Azure Monitor data platform. There are different types of Azure Monitor alerts depending on the services you're monitoring and the monitoring data you're collecting. See Choosing the right type of alert rule.
Recommended Azure Monitor alert rules for Azure Database for MySQL - Flexible Server
For some services, you can monitor at scale by applying the same metric alert rule to multiple resources of the same type that exist in the same Azure region. Azure Monitor Baseline Alerts (AMBA) provides a semi-automated method of implementing important platform metric alerts, dashboards, and guidelines at scale.
Get personalized recommendations using Azure Advisor
For some services, if critical conditions or imminent changes occur during resource operations, an alert displays on the service Overview page in the portal. You can find more information and recommended fixes for the alert in Advisor recommendations under Monitoring in the left menu. During normal operations, no advisor recommendations display.
Administre una infraestructura de base de datos de SQL Server para bases de datos relacionales locales e híbridas en la nube mediante las ofertas de bases de datos relacionales PaaS de Microsoft.
En este artículo se muestran las herramientas para ayudar a visualizar la información de rendimiento de consultas en el servidor flexible de Azure Database for MySQL.
En este artículo se explican las métricas de supervisión y alerta de Azure Database for MySQL: servidor flexible, incluidas las estadísticas de CPU, almacenamiento y conexión.