Skip to content

Commit 6514cc8

Browse files
authored
Merge pull request #111183 from ajlam/slowlog
Slow log updates
2 parents 34501b9 + 29244bb commit 6514cc8

File tree

8 files changed

+68
-51
lines changed

8 files changed

+68
-51
lines changed

articles/mariadb/concepts-server-logs.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,15 @@ author: ajlam
55
ms.author: andrela
66
ms.service: mariadb
77
ms.topic: conceptual
8-
ms.date: 3/18/2020
8+
ms.date: 4/13/2020
99
---
1010
# Slow query logs in Azure Database for MariaDB
1111
In Azure Database for MariaDB, the slow query log is available to users. Access to the transaction log is not supported. The slow query log can be used to identify performance bottlenecks for troubleshooting.
1212

1313
For more information about the slow query log, see the MariaDB documentation for [slow query log](https://mariadb.com/kb/en/library/slow-query-log-overview/).
1414

15-
## Access slow query logs
16-
You can list and download Azure Database for MariaDB slow query logs using the Azure portal, and the Azure CLI.
17-
18-
In the Azure portal, select your Azure Database for MariaDB server. Under the **Monitoring** heading, select the **Server Logs** page.
19-
20-
For more information on Azure CLI, see [Configure and access server logs using Azure CLI](howto-configure-server-logs-cli.md).
21-
22-
Similarly, you can pipe the logs to Azure Monitor using Diagnostic Logs. See [below](concepts-server-logs.md#diagnostic-logs) for more information.
23-
24-
## Log retention
25-
Logs are available for 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.
26-
27-
Logs are rotated every 24 hours or 7 GB, whichever comes first.
28-
2915
## Configure slow query logging
30-
By default the slow query log is disabled. To enable it, set slow_query_log to ON.
16+
By default the slow query log is disabled. To enable it, set `slow_query_log` to ON. This can be enabled using the Azure portal or Azure CLI.
3117

3218
Other parameters you can adjust include:
3319

@@ -43,6 +29,21 @@ Other parameters you can adjust include:
4329
4430
See the MariaDB [slow query log documentation](https://mariadb.com/kb/en/library/slow-query-log-overview/) for full descriptions of the slow query log parameters.
4531

32+
## Access slow query logs
33+
There are two options for accessing slow query logs in Azure Database for MariaDB: local server storage or Azure Monitor Diagnostic Logs. This is set using the `log_output` parameter.
34+
35+
For local server storage, you can list and download slow query logs using the Azure portal or the Azure CLI. In the Azure portal, navigate to your server in the Azure portal. Under the **Monitoring** heading, select the **Server Logs** page. For more information on Azure CLI, see [Configure and access server logs using Azure CLI](howto-configure-server-logs-cli.md).
36+
37+
Azure Monitor Diagnostic Logs allows you to pipe slow query logs to Azure Monitor Logs (Log Analytics), Azure Storage, or Event Hubs. See [below](concepts-server-logs.md#diagnostic-logs) for more information.
38+
39+
## Local server storage log retention
40+
When logging to the server's local storage, logs are available for 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.
41+
42+
Logs are rotated every 24 hours or 7 GB, whichever comes first.
43+
44+
> [!Note]
45+
> The above log retention does not apply to logs that are piped using Azure Monitor Diagnostic Logs. You can change the retention period for the data sinks being emitted to (ex. Azure Storage).
46+
4647
## Diagnostic logs
4748
Azure Database for MariaDB is integrated with Azure Monitor Diagnostic Logs. Once you have enabled slow query logs on your MariaDB server, you can choose to have them emitted to Azure Monitor logs, Event Hubs, or Azure Storage. To learn more about how to enable diagnostic logs, see the how to section of the [diagnostic logs documentation](../azure-monitor/platform/platform-logs-overview.md).
4849

@@ -76,6 +77,9 @@ The following table describes what's in each log. Depending on the output method
7677
| `thread_id_s` | Thread ID |
7778
| `\_ResourceId` | Resource URI |
7879

80+
> [!Note]
81+
> For `sql_text`, log will be truncated if it exceeds 2048 characters.
82+
7983
## Analyze logs in Azure Monitor Logs
8084

8185
Once your slow query logs are piped to Azure Monitor Logs through Diagnostic Logs, you can perform further analysis of your slow queries. Below are some sample queries to help you get started. Make sure to update the below with your server name.

articles/mariadb/howto-configure-server-logs-cli.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: andrela
66
ms.service: mariadb
77
ms.devlang: azurecli
88
ms.topic: conceptual
9-
ms.date: 3/18/2020
9+
ms.date: 4/13/2020
1010
---
1111
# Configure and access slow query logs by using Azure CLI
1212
You can download the Azure Database for MariaDB slow query logs by using Azure CLI, the Azure command-line utility.
@@ -16,30 +16,32 @@ To step through this how-to guide, you need:
1616
- [Azure Database for MariaDB server](quickstart-create-mariadb-server-database-using-azure-cli.md)
1717
- The [Azure CLI](/cli/azure/install-azure-cli) or Azure Cloud Shell in the browser
1818

19-
## Configure logging for Azure Database for MariaDB
20-
You can configure the server to access the MariaDB slow query log by taking the following steps:
21-
1. Turn on logging by setting the **slow\_query\_log** parameter to ON.
22-
2. Adjust other parameters, such as **long\_query\_time** and **log\_slow\_admin\_statements**.
19+
## Configure logging
20+
You can configure the server to access the MySQL slow query log by taking the following steps:
21+
1. Turn on slow query logging by setting the **slow\_query\_log** parameter to ON.
22+
2. Select where to output the logs to using **log\_output**. To send logs to both local storage and Azure Monitor Diagnostic Logs, select **File**. To send logs only to Azure Monitor Logs, select **None**
23+
3. Adjust other parameters, such as **long\_query\_time** and **log\_slow\_admin\_statements**.
2324

2425
To learn how to set the value of these parameters through Azure CLI, see [How to configure server parameters](howto-configure-server-parameters-cli.md).
2526

2627
For example, the following CLI command turns on the slow query log, sets the long query time to 10 seconds, and then turns off the logging of the slow admin statement. Finally, it lists the configuration options for your review.
2728
```azurecli-interactive
2829
az mariadb server configuration set --name slow_query_log --resource-group myresourcegroup --server mydemoserver --value ON
30+
az mariadb server configuration set --name log_output --resource-group myresourcegroup --server mydemoserver --value FILE
2931
az mariadb server configuration set --name long_query_time --resource-group myresourcegroup --server mydemoserver --value 10
3032
az mariadb server configuration set --name log_slow_admin_statements --resource-group myresourcegroup --server mydemoserver --value OFF
3133
az mariadb server configuration list --resource-group myresourcegroup --server mydemoserver
3234
```
3335

3436
## List logs for Azure Database for MariaDB server
35-
To list the available slow query log files for your server, run the [az mariadb server-logs list](/cli/azure/mariadb/server-logs#az-mariadb-server-logs-list) command.
37+
If **log_output** is configured to "File", you can access logs directly from the server's local storage. To list the available slow query log files for your server, run the [az mariadb server-logs list](/cli/azure/mariadb/server-logs#az-mariadb-server-logs-list) command.
3638

3739
You can list the log files for server **mydemoserver.mariadb.database.azure.com** under the resource group **myresourcegroup**. Then direct the list of log files to a text file called **log\_files\_list.txt**.
3840
```azurecli-interactive
3941
az mariadb server-logs list --resource-group myresourcegroup --server mydemoserver > log_files_list.txt
4042
```
4143
## Download logs from the server
42-
With the [az mariadb server-logs download](/cli/azure/mariadb/server-logs#az-mariadb-server-logs-download) command, you can download individual log files for your server.
44+
If **log_output** is configured to "File", you can download individual log files from your server with the [az mariadb server-logs download](/cli/azure/mariadb/server-logs#az-mariadb-server-logs-download) command.
4345

4446
Use the following example to download the specific log file for the server **mydemoserver.mariadb.database.azure.com** under the resource group **myresourcegroup** to your local environment.
4547
```azurecli-interactive

articles/mariadb/howto-configure-server-logs-portal.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: ajlam
55
ms.author: andrela
66
ms.service: mariadb
77
ms.topic: conceptual
8-
ms.date: 3/18/2020
8+
ms.date: 4/13/2020
99
---
1010

1111
# Configure and access slow query logs from the Azure portal
@@ -27,11 +27,15 @@ Configure access to the slow query log.
2727

2828
4. To see the server parameters, select **Click here to enable logs and configure log parameters**.
2929

30-
5. Change the parameters that you need to adjust, including turning **slow_query_log** to **ON**. All changes you make in this session are highlighted in purple.
30+
5. Turn **slow_query_log** to **ON**.
3131

32-
After you have changed the parameters, select **Save**. Or, you can discard your changes.
32+
6. Select where to output the logs to using **log_output**. To send logs to both local storage and Azure Monitor Diagnostic Logs, select **File**.
3333

34-
![Screenshot of Server Parameters options](./media/howto-configure-server-logs-portal/3-save-discard.png)
34+
7. Change any other parameters needed.
35+
36+
8. Select **Save**.
37+
38+
:::image type="content" source="./media/howto-configure-server-logs-portal/3-save-discard.png" alt-text="Screenshot of slow query log parameters and save.":::
3539

3640
From the **Server Parameters** page, you can return to the list of logs by closing the page.
3741

825 Bytes
Loading

articles/mysql/concepts-server-logs.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,15 @@ author: ajlam
55
ms.author: andrela
66
ms.service: mysql
77
ms.topic: conceptual
8-
ms.date: 01/28/2020
8+
ms.date: 4/13/2020
99
---
1010
# Slow query logs in Azure Database for MySQL
1111
In Azure Database for MySQL, the slow query log is available to users. Access to the transaction log is not supported. The slow query log can be used to identify performance bottlenecks for troubleshooting.
1212

1313
For more information about the MySQL slow query log, see the MySQL reference manual's [slow query log section](https://dev.mysql.com/doc/refman/5.7/en/slow-query-log.html).
1414

15-
## Access slow query logs
16-
You can list and download Azure Database for MySQL slow query logs using the Azure portal, and the Azure CLI.
17-
18-
In the Azure portal, select your Azure Database for MySQL server. Under the **Monitoring** heading, select the **Server Logs** page.
19-
20-
For more information on Azure CLI, see [Configure and access slow query logs using Azure CLI](howto-configure-server-logs-in-cli.md).
21-
22-
Similarly, you can pipe the logs to Azure Monitor using Diagnostic Logs. See [below](concepts-server-logs.md#diagnostic-logs) for more information.
23-
24-
## Log retention
25-
Logs are available for 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.
26-
27-
Logs are rotated every 24 hours or 7 GB, whichever comes first.
28-
2915
## Configure slow query logging
30-
By default the slow query log is disabled. To enable it, set slow_query_log to ON.
16+
By default the slow query log is disabled. To enable it, set `slow_query_log` to ON. This can be enabled using the Azure portal or Azure CLI.
3117

3218
Other parameters you can adjust include:
3319

@@ -43,6 +29,21 @@ Other parameters you can adjust include:
4329
4430
See the MySQL [slow query log documentation](https://dev.mysql.com/doc/refman/5.7/en/slow-query-log.html) for full descriptions of the slow query log parameters.
4531

32+
## Access slow query logs
33+
There are two options for accessing slow query logs in Azure Database for MySQL: local server storage or Azure Monitor Diagnostic Logs. This is set using the `log_output` parameter.
34+
35+
For local server storage, you can list and download slow query logs using the Azure portal or the Azure CLI. In the Azure portal, navigate to your server in the Azure portal. Under the **Monitoring** heading, select the **Server Logs** page. For more information on Azure CLI, see [Configure and access slow query logs using Azure CLI](howto-configure-server-logs-in-cli.md).
36+
37+
Azure Monitor Diagnostic Logs allows you to pipe slow query logs to Azure Monitor Logs (Log Analytics), Azure Storage, or Event Hubs. See [below](concepts-server-logs.md#diagnostic-logs) for more information.
38+
39+
## Local server storage log retention
40+
When logging to the server's local storage, logs are available for 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.
41+
42+
Logs are rotated every 24 hours or 7 GB, whichever comes first.
43+
44+
> [!Note]
45+
> The above log retention does not apply to logs that are piped using Azure Monitor Diagnostic Logs. You can change the retention period for the data sinks being emitted to (ex. Azure Storage).
46+
4647
## Diagnostic logs
4748
Azure Database for MySQL is integrated with Azure Monitor Diagnostic Logs. Once you have enabled slow query logs on your MySQL server, you can choose to have them emitted to Azure Monitor logs, Event Hubs, or Azure Storage. To learn more about how to enable diagnostic logs, see the how to section of the [diagnostic logs documentation](../azure-monitor/platform/platform-logs-overview.md).
4849

articles/mysql/howto-configure-server-logs-in-cli.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: andrela
66
ms.service: mysql
77
ms.devlang: azurecli
88
ms.topic: conceptual
9-
ms.date: 3/18/2020
9+
ms.date: 4/13/2020
1010
---
1111
# Configure and access slow query logs by using Azure CLI
1212
You can download the Azure Database for MySQL slow query logs by using Azure CLI, the Azure command-line utility.
@@ -19,27 +19,29 @@ To step through this how-to guide, you need:
1919
## Configure logging
2020
You can configure the server to access the MySQL slow query log by taking the following steps:
2121
1. Turn on slow query logging by setting the **slow\_query\_log** parameter to ON.
22-
2. Adjust other parameters, such as **long\_query\_time** and **log\_slow\_admin\_statements**.
22+
2. Select where to output the logs to using **log\_output**. To send logs to both local storage and Azure Monitor Diagnostic Logs, select **File**. To send logs only to Azure Monitor Logs, select **None**
23+
3. Adjust other parameters, such as **long\_query\_time** and **log\_slow\_admin\_statements**.
2324

2425
To learn how to set the value of these parameters through Azure CLI, see [How to configure server parameters](howto-configure-server-parameters-using-cli.md).
2526

2627
For example, the following CLI command turns on the slow query log, sets the long query time to 10 seconds, and then turns off the logging of the slow admin statement. Finally, it lists the configuration options for your review.
2728
```azurecli-interactive
2829
az mysql server configuration set --name slow_query_log --resource-group myresourcegroup --server mydemoserver --value ON
30+
az mysql server configuration set --name log_output --resource-group myresourcegroup --server mydemoserver --value FILE
2931
az mysql server configuration set --name long_query_time --resource-group myresourcegroup --server mydemoserver --value 10
3032
az mysql server configuration set --name log_slow_admin_statements --resource-group myresourcegroup --server mydemoserver --value OFF
3133
az mysql server configuration list --resource-group myresourcegroup --server mydemoserver
3234
```
3335

3436
## List logs for Azure Database for MySQL server
35-
To list the available slow query log files for your server, run the [az mysql server-logs list](/cli/azure/mysql/server-logs#az-mysql-server-logs-list) command.
37+
If **log_output** is configured to "File", you can access logs directly from the server's local storage. To list the available slow query log files for your server, run the [az mysql server-logs list](/cli/azure/mysql/server-logs#az-mysql-server-logs-list) command.
3638

3739
You can list the log files for server **mydemoserver.mysql.database.azure.com** under the resource group **myresourcegroup**. Then direct the list of log files to a text file called **log\_files\_list.txt**.
3840
```azurecli-interactive
3941
az mysql server-logs list --resource-group myresourcegroup --server mydemoserver > log_files_list.txt
4042
```
4143
## Download logs from the server
42-
With the [az mysql server-logs download](/cli/azure/mysql/server-logs#az-mysql-server-logs-download) command, you can download individual log files for your server.
44+
If **log_output** is configured to "File", you can download individual log files from your server with the [az mysql server-logs download](/cli/azure/mysql/server-logs#az-mysql-server-logs-download) command.
4345

4446
Use the following example to download the specific log file for the server **mydemoserver.mysql.database.azure.com** under the resource group **myresourcegroup** to your local environment.
4547
```azurecli-interactive

articles/mysql/howto-configure-server-logs-in-portal.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: ajlam
55
ms.author: andrela
66
ms.service: mysql
77
ms.topic: conceptual
8-
ms.date: 3/18/2020
8+
ms.date: 4/13/2020
99
---
1010

1111
# Configure and access slow query logs from the Azure portal
@@ -27,11 +27,15 @@ Configure access to the MySQL slow query log.
2727

2828
4. To see the server parameters, select **Click here to enable logs and configure log parameters**.
2929

30-
5. Change the parameters that you need to adjust. All changes you make in this session are highlighted in purple.
30+
5. Turn **slow_query_log** to **ON**.
3131

32-
After you have changed the parameters, select **Save**. Or, you can discard your changes.
32+
6. Select where to output the logs to using **log_output**. To send logs to both local storage and Azure Monitor Diagnostic Logs, select **File**.
3333

34-
![Screenshot of Server Parameters options](./media/howto-configure-server-logs-in-portal/3-save-discard.png)
34+
7. Change any other parameters needed.
35+
36+
8. Select **Save**.
37+
38+
:::image type="content" source="./media/howto-configure-server-logs-in-portal/3-save-discard.png" alt-text="Screenshot of slow query log parameters and save.":::
3539

3640
From the **Server Parameters** page, you can return to the list of logs by closing the page.
3741

-511 Bytes
Loading

0 commit comments

Comments
 (0)