MySQL Telemetry and OCI Log Analytics

Exports MySQL server logs to OCI Log Analytics.

Telemetry provides a convenient method to view and analyze the MySQL server logs using the OCI Log Analytics Service instead of relying solely on the MySQL command-line client.

Prerequisites

Prerequisites for sending MySQL Logs to OCI Log Analytics.

To send MySQL Logs to OCI Log Analytics, ensure the following:

  • You have access to the OCI Log Analytics service and appropriate permissions.
    Note

    Log Analytics is a billable service, it is not included in your MySQL HeatWave Service subscription and must be activated separately. See Log Analytics for more information.
  • You have created at least one Log Analytics Log Group. This is required to store the MySQL logs.
  • Your DB System runs MySQL version 9.6.1 or higher.
  • You DB System is standalone. Exporting MySQL logs to OCI Log Analytics is not currently supported by High Availability DB Systems or DB Systems with Read Replicas.
  • Your DB System is not Always-free-tier, which has no access to Log Analytics.
  • You have defined IAM policies as described in Policies.
  • To log SQL statements in the Audit Log, you must define Audit Log filters. See Audit Log Filtering.

MySQL Logs

Exports MySQL server logs to OCI Log Analytics or to custom OpenTelemetry endpoints.

The following logs can be exported:

  • Error log: Contains a record of mysqld startup and shutdown times. It also contains diagnostic messages such as errors, warnings, and notes that occur during server startup and shutdown, and while the server is running.
  • Slow query log: Consists of SQL statements that take more than long_query_time seconds to execute and require at least min_examined_row_limit rows to be examined. The slow query log can be used to find queries that take a long time to execute and are therefore candidates for optimization.
  • Audit log: Contains client connection and disconnect details, and what actions they perform while connected, such as which databases and tables they access.
  • General log: A general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and logs each SQL statement received from clients.

Viewing MySQL Logs in OCI Log Analytics

You can view the configured MySQL Logs in the OCI Log Analytics Log Explorer.

This task assumes you have configured all required Prerequisites.
  1. Navigate to the OCI Log Analytics Log Explorer.
  2. Select the appropriate Compartment in the filter and click Apply.
  3. The log sources Open Telemetry Logs and MySQL Database Audit JSON Logs are displayed in the Log Source table.
    Open Telemetry Logs contains the Error, General, and Slow Query logs, and MySQL Database Audit JSON Logs contains the Audit Logs.

Viewing MySQL Telemetry and OCI Log Analytics Table

MySQL Telemetry and OCI Log Analytics table stores monitoring data for exported logs in MySQL Server's Performance Schema.

Using a Command-Line Client

Use a command-line client such as MySQL Client or MySQL Shell to view the MySQL Telemetry and OCI Log Analytics table.

This task requires the following:
  1. For MySQL Shell, switch to SQL mode by entering the \sql command.
  2. Enter the following SQL statement, specifying the table you want to view:
    SELECT * FROM performance_schema.<table_name>;

    For example, to view the status of the exported logs, use the following SQL command:

    SELECT * FROM performance_schema.telemetry_oci_export_status;
    Note

    To view the complete list of tables, you can specify in <table_name>, see MySQL Telemetry and OCI Log Analytics Table.
You get a response similar to the following:
+--------------+---------------+----------------------+--------------------+------------------------+----------------------+-----------------+--------------------+-----------------------+
| CHANNEL_NAME | SERVICE_STATE | EXPORT_SUCCESS_COUNT | EXPORT_ERROR_COUNT | LAST_SUCCESS_TIMESTAMP | LAST_ERROR_TIMESTAMP | LAST_ERROR_CODE | LAST_ERROR_MESSAGE | LAST_ERROR_REQUEST_ID |
+--------------+---------------+----------------------+--------------------+------------------------+----------------------+-----------------+--------------------+-----------------------+
| ERROR_LOG    | OFF           |                    0 |                  0 | NULL                   | NULL                 | NULL            | NULL               | NULL                  |
| GENERAL_LOG  | OFF           |                    0 |                  0 | NULL                   | NULL                 | NULL            | NULL               | NULL                  |
| SLOW_LOG     | OFF           |                    0 |                  0 | NULL                   | NULL                 | NULL            | NULL               | NULL                  |
+--------------+---------------+----------------------+--------------------+------------------------+----------------------+-----------------+--------------------+-----------------------+                

MySQL Telemetry and OCI Log Analytics Table

Performance Schema includes the following MySQL Telemetry and OCI Log Analytics table:

performance_schema.telemetry_oci_export_status Table

Table 17-14 telemetry_oci_export_status Performance Schema Table

Column Description
CHANNEL_NAME Indicates which log types were sent to OCI Log Analytics.

Valid values are: ERROR_LOG, GENERAL_LOG, and SLOW_LOG.

SERVICE_STATE Indicates whether data is collected for each log type.
EXPORT_SUCCESS_COUNT Indicates the number of successful exports.
EXPORT_ERROR_COUNT Indicates the number of failed exports.
LAST_SUCCESS_TIMESTAMP Timestamp of the last successful export.
LAST_ERROR_TIMESTAMP Timestamp of the last failed export.
LAST_ERROR_CODE Error code of the last failed export.
LAST_ERROR_MESSAGE Error message of the last failed export.
LAST_ERROR_REQUEST_ID Request ID of the OCI Log Analytics REST API call for the last failed export, if any.

Viewing MySQL Telemetry and OCI Log Analytics Status Variables

MySQL Telemetry and OCI Log Analytics status variables are static indicators that let you monitor the status of different MySQL Telemetry and OCI Log Analytics components. You cannot change the values of these variables.

Using a Command-Line Client

Use a command-line client such as MySQL Client or MySQL Shell to view the status variables and their values.

This task requires the following:
  • A running DB system.
  • A command-line client such as MySQL Client or MySQL Shell that is connected to the DB system. See Connecting to a DB System.
Do the following to view the Health Monitor variables:
  1. For MySQL Shell, switch to SQL mode by entering the \sql command.
  2. Enter the following SQL statement:
    show status like '<variable_name>';

    For example:

    show status like 'telemetry_oci.run_level';
You get a response similar to the following:
+-------------------------+-----------+
| Variable_name           | Value     |
+-------------------------+-----------+
| telemetry_oci.run_level | CONFIGURE |
+-------------------------+-----------+

MySQL Telemetry and OCI Log Analytics Status Variables

Table 17-15 MySQL Telemetry and OCI Log Analytics Status Variables

System Variable Description Possible Values
log_offload.log_analytics_last_error_code Error code of the last failed export. A string value.
log_offload.log_analytics_last_error_message Error message of the last failed export. A string value.
log_offload.log_analytics_last_error_opc_request_id Request ID of the OCI Log Analytics REST API call for the last failed export. A string value, similar to the following example: /C8DBC62DADE6ECAC222ABF9CAABBC11C/13B10A00F071D7C39DAE333C3CB0DCD8
log_offload.log_analytics_last_error_timestamp Timestamp of the last failed export. A string value, indicating the local time with 6 microsecond decimals similar to the following example: 2025-01-29 04:46:44.009907.
log_offload.log_analytics_ops_skipped Indicates the number of files that were skipped from exporting. An integer value.
telemetry_oci.exports_failed_error_log Indicates the number of failed exports for the error log. An integer value.
telemetry_oci.exports_failed_general_log Indicates the number of failed exports for the general log. An integer value.
telemetry_oci.exports_failed_slow_log Indicates the number of failed exports for the general log. An integer value.
telemetry_oci.exports_success_error_log Indicates the number of successful exports for the error log. An integer value.
telemetry_oci.exports_success_general_log Indicates the number of successful exports for the general log. An integer value.
telemetry_oci.exports_success_slow_log Indicates the number of successful exports for the slow log. An integer value.
telemetry_oci.run_level Indicates the component state.
  • BOOT: the component is being loaded and initialization has started. This state is transitory.
  • CONFIGURE: The component is ready for configuration.
  • READY: configuration completed successfully.
  • FAILED: configuration failed.
  • UNINSTALL: the component is being uninstalled and then unloaded.