MySQL 8.4 参考手册  /  遥测  /  安装 OpenTelemetry 支持

35.1 安装 OpenTelemetry 支持

本节介绍服务器和客户端 OpenTelemetry 支持的安装。

安装服务器组件

要安装服务器组件,请运行以下命令

install component 'file://component_telemetry';

要确认组件是否存在于您的服务器中,请运行以下查询

mysql> select * from mysql.component;
+--------------+--------------------+------------------------------------+
| component_id | component_group_id | component_urn                      |
+--------------+--------------------+------------------------------------+
|            1 |                  1 | file://component_validate_password |
|            2 |                  2 | file://component_telemetry         |
+--------------+--------------------+------------------------------------+

如果 component_urn 列中存在 component_telemetry,则表示组件已安装。

组件安装还会添加特定于遥测的系统变量。

mysql> show variables like "%telemetry%";
+----------------------------------------------------------+----------------------------------+
| Variable_name                                            | Value                            |
+----------------------------------------------------------+----------------------------------+
| telemetry.metrics_enabled                                | ON                               |
| telemetry.metrics_reader_frequency_1                     | 10                               |
| telemetry.metrics_reader_frequency_2                     | 60                               |
| telemetry.metrics_reader_frequency_3                     | 0                                |
| telemetry.otel_bsp_max_export_batch_size                 | 512                              |
| telemetry.otel_bsp_max_queue_size                        | 2048                             |
| telemetry.otel_bsp_schedule_delay                        | 5000                             |
| telemetry.otel_exporter_otlp_metrics_certificates        |                                  |
| telemetry.otel_exporter_otlp_metrics_cipher              |                                  |
| telemetry.otel_exporter_otlp_metrics_cipher_suite        |                                  |
| telemetry.otel_exporter_otlp_metrics_client_certificates |                                  |
| telemetry.otel_exporter_otlp_metrics_client_key          |                                  |
| telemetry.otel_exporter_otlp_metrics_compression         | none                             |
| telemetry.otel_exporter_otlp_metrics_endpoint            | http://localhost:4318/v1/metrics |
| telemetry.otel_exporter_otlp_metrics_headers             |                                  |
| telemetry.otel_exporter_otlp_metrics_max_tls             |                                  |
| telemetry.otel_exporter_otlp_metrics_min_tls             |                                  |
| telemetry.otel_exporter_otlp_metrics_protocol            | http/protobuf                    |
| telemetry.otel_exporter_otlp_metrics_timeout             | 10000                            |
| telemetry.otel_exporter_otlp_traces_certificates         |                                  |
| telemetry.otel_exporter_otlp_traces_cipher               |                                  |
| telemetry.otel_exporter_otlp_traces_cipher_suite         |                                  |
| telemetry.otel_exporter_otlp_traces_client_certificates  |                                  |
| telemetry.otel_exporter_otlp_traces_client_key           |                                  |
| telemetry.otel_exporter_otlp_traces_compression          | none                             |
| telemetry.otel_exporter_otlp_traces_endpoint             | http://localhost:4318/v1/traces  |
| telemetry.otel_exporter_otlp_traces_headers              |                                  |
| telemetry.otel_exporter_otlp_traces_max_tls              |                                  |
| telemetry.otel_exporter_otlp_traces_min_tls              |                                  |
| telemetry.otel_exporter_otlp_traces_protocol             | http/protobuf                    |
| telemetry.otel_exporter_otlp_traces_timeout              | 10000                            |
| telemetry.otel_log_level                                 | info                             |
| telemetry.otel_resource_attributes                       |                                  |
| telemetry.query_text_enabled                             | ON                               |
| telemetry.trace_enabled                                  | ON                               |
+----------------------------------------------------------+----------------------------------+

请参阅 服务器配置

安装客户端插件

可以通过命令行开关 --telemetry_client 或在配置文件的 [mysql] 部分中定义的配置选项 telemetry-client=ON |OFF 启用 MySQL 客户端的遥测插件。