Skip to content

Commit 86155be

Browse files
authored
Fix inaccurate MySQL/MariaDB, Redis metrics (#12130)
1 parent e9a2ed2 commit 86155be

File tree

15 files changed

+294
-185
lines changed

15 files changed

+294
-185
lines changed

docs/en/changes/changes.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
- `memory_swap_percentage` -> `memory_virtual_memory_percentage`
106106
* Fix/Change UI init setting for Windows Swap -> Virtual Memory
107107
* Fix `Memory Swap Usage`/`Virtual Memory Usage` display with UI init.(Linux/Windows)
108-
* Fix inaccurate APISIX metrics
108+
109+
* Fix inaccurate APISIX metrics.
109110
* Fix inaccurate MongoDB Metrics.
110111
* Support Apache ActiveMQ server monitoring.
111112
* Add Service Hierarchy auto matching layer relationships (upper -> lower) as following:
@@ -114,6 +115,7 @@
114115
* MQE query: make metadata not return `null`.
115116
* MQE labeled metrics Binary Operation: return empty value if the labels not match rather than report error.
116117
* Fix inaccurate Hierarchy of RabbitMQ Server monitoring metrics.
118+
* Fix inaccurate MySQL/MariaDB, Redis, PostgreSQL metrics.
117119

118120
#### UI
119121

docs/en/setup/backend/backend-mysql-monitoring.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ SkyWalking leverages prometheus/mysqld_exporter for collecting metrics data. It
1717
MySQL/MariaDB monitoring provides monitoring of the status and resources of the MySQL/MariaDB server. MySQL/MariaDB cluster is cataloged as a `Layer: MYSQL` `Service` in OAP.
1818
Each MySQL/MariaDB server is cataloged as an `Instance` in OAP.
1919
#### Supported Metrics
20-
| Monitoring Panel | Unit | Metric Name | Description | Data Source |
21-
|-----|------|-----|-----|-----|
22-
| MySQL Uptime | day | meter_mysql_uptime | The MySQL startup time | mysqld_exporter|
23-
| Max Connections | | meter_mysql_max_connections | The max number of connections. | mysqld_exporter|
24-
| Innodb Buffer Pool Size | MB | meter_mysql_innodb_buffer_pool_size | The buffer pool size in Innodb engine | mysqld_exporter|
25-
| Thread Cache Size | | meter_mysql_thread_cache_size | The size of thread cache | mysqld_exporter|
26-
| Current QPS| | meter_mysql_qps | Queries Per Second | mysqld_exporter|
27-
| Current TPS | | meter_mysql_tps | Transactions Per Second | mysqld_exporter|
20+
| Monitoring Panel | Unit | Metric Name | Description | Data Source |
21+
|-----|------|--------------------------------------------------------------------------------------------------------------------------------------------------|-----|-----|
22+
| MySQL Uptime | day | meter_mysql_uptime | The MySQL startup time | mysqld_exporter|
23+
| Max Connections | | meter_mysql_max_connections | The max number of connections. | mysqld_exporter|
24+
| Innodb Buffer Pool Size | MB | meter_mysql_innodb_buffer_pool_size | The buffer pool size in Innodb engine | mysqld_exporter|
25+
| Thread Cache Size | | meter_mysql_thread_cache_size | The size of thread cache | mysqld_exporter|
26+
| Current QPS| | meter_mysql_qps | Queries Per Second | mysqld_exporter|
27+
| Current TPS | | meter_mysql_tps | Transactions Per Second | mysqld_exporter|
2828
| Commands Rate | | meter_mysql_commands_insert_rate <br/>meter_mysql_commands_select_rate<br />meter_mysql_commands_delete_rate<br />meter_mysql_commands_update_rate | The rate of total number of insert/select/delete/update executed by the current server | mysqld_exporter|
29-
| Threads | | meter_mysql_threads_connected<br />meter_mysql_threads_created<br />meter_mysql_threads_cached<br />meter_mysql_threads_running | The number of currently open connections(threads_connected) <br/> The number of threads created(threads_created) <br/> The number of threads in the thread cache(threads_cached) <br/> The number of threads that are not sleeping(threads_running) | mysqld_exporter|
30-
| Connects | | meter_mysql_connects_available<br />meter_mysql_connects_aborted | The number of available connections(connects_available)<br/>The number of MySQL instance connection rejections(connects_aborted)| mysqld_exporter|
31-
| Connection Errors | | meter_mysql_connection_errors_internal </br> meter_mysql_connection_errors_max_connections | Errors due to exceeding the max_connections(connection_errors_max_connections) </br>Error caused by internal system(connection_errors_internal) | mysqld_exporter|
32-
| Slow Queries Rate | | meter_mysql_slow_queries_rate | The rate of slow queries | mysqld_exporter|
29+
| Threads | | meter_mysql_threads_connected<br />meter_mysql_threads_created<br />meter_mysql_threads_cached<br />meter_mysql_threads_running | The number of currently open connections(threads_connected) <br/> The number of threads created(threads_created) <br/> The number of threads in the thread cache(threads_cached) <br/> The number of threads that are not sleeping(threads_running) | mysqld_exporter|
30+
| Connects | | meter_mysql_max_connections<br />meter_mysql_status_thread_connected<br />meter_mysql_connects_aborted | The number of available connections(connects_available)<br/>The number of MySQL instance connection rejections(connects_aborted)| mysqld_exporter|
31+
| Connection Errors | | meter_mysql_connection_errors_internal </br> meter_mysql_connection_errors_max_connections | Errors due to exceeding the max_connections(connection_errors_max_connections) </br>Error caused by internal system(connection_errors_internal) | mysqld_exporter|
32+
| Slow Queries Rate | | meter_mysql_slow_queries_rate | The rate of slow queries | mysqld_exporter|
3333

3434
### Customizations
3535
You can customize your own metrics/expression/dashboard panel.

docs/en/setup/backend/backend-redis-monitoring.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ SkyWalking leverages redis-exporter for collecting metrics data from Redis. It l
1717
Redis monitoring provides monitoring of the status and resources of the Redis server. Redis cluster is cataloged as a `Layer: REDIS` `Service` in OAP.
1818
Each Redis server is cataloged as an `Instance` in OAP.
1919
#### Supported Metrics
20-
| Monitoring Panel | Unit | Metric Name | Description | Data Source |
21-
|-----------------------------------|--------|---------------------------------------------------------------------------------------------------|----------------------------------------------------|----------------|
22-
| Uptime | day | meter_redis_uptime | The uptime of Redis. | redis-exporter |
23-
| Connected Clients | | meter_redis_connected_clients | The number of connected clients. | redis-exporter |
24-
| Blocked Clients | | meter_redis_blocked_clients | The number of blocked clients. | redis-exporter |
25-
| Memory Max Bytes | MB | meter_redis_memory_max_bytes | The max bytes of memory. | redis-exporter |
26-
| Hits Rate | % | meter_redis_hit_rate | Hit rate of redis when used as a cache. | redis-exporter |
27-
| Average Time Spend By Command | second | meter_redis_average_time_spent_by_command | Average time to execute various types of commands. | redis-exporter |
28-
| Total Commands Trend | | meter_redis_total_commands_rate | The Trend of total commands. | redis-exporter |
20+
| Monitoring Panel | Unit | Metric Name | Description | Data Source |
21+
|-----------------------------------|--------|--------------------------------------------------------------------------------------------------|----------------------------------------------------|----------------|
22+
| Uptime | day | meter_redis_uptime | The uptime of Redis. | redis-exporter |
23+
| Connected Clients | | meter_redis_connected_clients | The number of connected clients. | redis-exporter |
24+
| Blocked Clients | | meter_redis_blocked_clients | The number of blocked clients. | redis-exporter |
25+
| Memory Max Bytes | MB | meter_redis_memory_max_bytes | The max bytes of memory. | redis-exporter |
26+
| Hits Rate | % | meter_redis_hit_rate | Hit rate of redis when used as a cache. | redis-exporter |
27+
| Average Time Spend By Command | second | meter_redis_average_time_spent_by_command | Average time to execute various types of commands. | redis-exporter |
28+
| Total Commands Trend | | meter_redis_total_commands_rate | The Trend of total commands. | redis-exporter |
2929
| DB keys | | meter_redis_evicted_keys_total </br> meter_redis_expired_keys_total </br> meter_redis_db_keys | The number of Expired / Evicted / total keys. | redis-exporter |
30-
| Net Input/Output Bytes | KB | meter_redis_net_input_bytes </br> meter_redis_net_output_bytes | Total bytes of input / output of redis net. | redis-exporter |
31-
| Memory Usage | % | meter_redis_memory_usage | Percentage of used memory. | redis-exporter |
32-
| Total Time Spend By Command Trend | | meter_redis_commands_duration_seconds_total_rate | The trend of total time spend by command | redis-exporter |
30+
| Net Input/Output Bytes | KB | meter_redis_net_input_bytes </br> meter_redis_net_output_bytes | Total bytes of input / output of redis net. | redis-exporter |
31+
| Memory Usage | % | meter_redis_memory_used_bytes </br> meter_redis_memory_max_bytes | Percentage of used memory. | redis-exporter |
32+
| Total Time Spend By Command Trend | | meter_redis_commands_duration </br> meter_redis_commands_total | The trend of total time spend by command | redis-exporter |
3333

3434
### Customizations
3535
You can customize your own metrics/expression/dashboard panel.

oap-server/server-starter/src/main/resources/otel-rules/mysql/mysql-service.yaml

+18-16
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,41 @@ metricPrefix: meter_mysql
3434
metricsRules:
3535
# database throughput
3636
- name: commands_insert_rate
37-
exp: mysql_global_status_commands_total.tagEqual('command','insert').rate('PT1M')
37+
exp: mysql_global_status_commands_total.tagEqual('command','insert').sum(['service_instance_id','host_name']).rate('PT1M')
3838
- name: commands_select_rate
39-
exp: mysql_global_status_commands_total.tagEqual('command','select').rate('PT1M')
39+
exp: mysql_global_status_commands_total.tagEqual('command','select').sum(['service_instance_id','host_name']).rate('PT1M')
4040
- name: commands_delete_rate
41-
exp: mysql_global_status_commands_total.tagEqual('command','delete').rate('PT1M')
41+
exp: mysql_global_status_commands_total.tagEqual('command','delete').sum(['service_instance_id','host_name']).rate('PT1M')
4242
- name: commands_update_rate
43-
exp: mysql_global_status_commands_total.tagEqual('command','update').rate('PT1M')
43+
exp: mysql_global_status_commands_total.tagEqual('command','update').sum(['service_instance_id','host_name']).rate('PT1M')
4444
- name: qps
45-
exp: mysql_global_status_queries.rate('PT1M')
45+
exp: mysql_global_status_queries.rate('PT1M').sum(['service_instance_id','host_name'])
4646
- name: tps
47-
exp: mysql_global_status_commands_total.tagMatch('command','rollback|commit').sum(['host_name']).rate('PT1M')
47+
exp: mysql_global_status_commands_total.tagMatch('command','rollback|commit').sum(['host_name', 'service_instance_id']).rate('PT1M')
4848

4949
# connections
5050
## threads
5151
- name: threads_connected
52-
exp: mysql_global_status_threads_connected
52+
exp: mysql_global_status_threads_connected.sum(['service_instance_id','host_name'])
5353
- name: threads_created
54-
exp: mysql_global_status_threads_created
54+
exp: mysql_global_status_threads_created.sum(['service_instance_id','host_name'])
5555
- name: threads_running
56-
exp: mysql_global_status_threads_running
56+
exp: mysql_global_status_threads_running.sum(['service_instance_id','host_name'])
5757
- name: threads_cached
58-
exp: mysql_global_status_threads_cached
58+
exp: mysql_global_status_threads_cached.sum(['service_instance_id','host_name'])
5959
## connect
6060
- name: connects_aborted
61-
exp: mysql_global_status_aborted_connects
62-
- name: connects_available
63-
exp: mysql_global_variables_max_connections.sum(['host_name']) - mysql_global_status_threads_connected.sum(['host_name'])
61+
exp: mysql_global_status_aborted_connects.sum(['service_instance_id','host_name'])
62+
- name: max_connections
63+
exp: mysql_global_variables_max_connections.sum(['host_name','service_instance_id'])
64+
- name: status_thread_connected
65+
exp: mysql_global_status_threads_connected.sum(['host_name','service_instance_id'])
6466
- name: connection_errors_max_connections
65-
exp: mysql_global_status_connection_errors_total.tagEqual('error','max_connection')
67+
exp: mysql_global_status_connection_errors_total.tagEqual('error','max_connection').sum(['service_instance_id','host_name'])
6668
- name: connection_errors_internal
67-
exp: mysql_global_status_connection_errors_total.tagEqual('error','internal')
69+
exp: mysql_global_status_connection_errors_total.tagEqual('error','internal').sum(['service_instance_id','host_name'])
6870

6971
# slow queries
7072
- name: slow_queries_rate
71-
exp: mysql_global_status_slow_queries.rate('PT1M')
73+
exp: mysql_global_status_slow_queries.sum(['service_instance_id','host_name']).rate('PT1M')
7274

oap-server/server-starter/src/main/resources/otel-rules/postgresql/postgresql-instance.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ metricsRules:
104104

105105
## buffers
106106
- name: instance_buffers_checkpoint
107-
exp: pg_stat_bgwriter_buffers_checkpoint.rate('PT1M')
107+
exp: pg_stat_bgwriter_buffers_checkpoint_total.rate('PT1M')
108108
- name: instance_buffers_clean
109-
exp: pg_stat_bgwriter_buffers_clean.rate('PT1M')
109+
exp: pg_stat_bgwriter_buffers_clean_total.rate('PT1M')
110110
- name: instance_buffers_backend_fsync
111-
exp: pg_stat_bgwriter_buffers_backend_fsync.rate('PT1M')
111+
exp: pg_stat_bgwriter_buffers_backend_fsync_total.rate('PT1M')
112112
- name: instance_buffers_alloc
113-
exp: pg_stat_bgwriter_buffers_alloc.rate('PT1M')
113+
exp: pg_stat_bgwriter_buffers_alloc_total.rate('PT1M')
114114
- name: instance_buffers_backend
115-
exp: pg_stat_bgwriter_buffers_backend.rate('PT1M')
115+
exp: pg_stat_bgwriter_buffers_backend_total.rate('PT1M')

oap-server/server-starter/src/main/resources/otel-rules/postgresql/postgresql-service.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ metricsRules:
4646
exp: pg_stat_database_tup_returned.sum(['service_instance_id','host_name']).rate('PT1M')
4747
## locks
4848
- name: locks_count
49-
exp: pg_locks_count.tag({tags -> tags.mode = tags.datname + ":" + tags.mode}).sum(['service_instance_id','host_name'])
49+
exp: pg_locks_count.sum(['service_instance_id','host_name'])
5050

5151
## sessions
5252
- name: active_sessions
@@ -68,13 +68,13 @@ metricsRules:
6868

6969
## checkpoint
7070
- name: checkpoint_write_time_rate
71-
exp: pg_stat_bgwriter_checkpoint_write_time_total.rate('PT1M')
71+
exp: pg_stat_bgwriter_checkpoint_write_time_total.rate('PT1M').sum(['service_instance_id','host_name'])
7272
- name: checkpoint_sync_time_rate
73-
exp: pg_stat_bgwriter_checkpoint_sync_time_total.rate('PT1M')
73+
exp: pg_stat_bgwriter_checkpoint_sync_time_total.rate('PT1M').sum(['service_instance_id','host_name'])
7474
- name: checkpoint_req_rate
75-
exp: pg_stat_bgwriter_checkpoints_req_total.rate('PT1M')
75+
exp: pg_stat_bgwriter_checkpoints_req_total.rate('PT1M').sum(['service_instance_id','host_name'])
7676
- name: checkpoints_timed_rate
77-
exp: pg_stat_bgwriter_checkpoints_timed_total.rate('PT1M')
77+
exp: pg_stat_bgwriter_checkpoints_timed_total.rate('PT1M').sum(['service_instance_id','host_name'])
7878

7979
## conflicts and deadlocks
8080
- name: conflicts_rate
@@ -84,12 +84,12 @@ metricsRules:
8484

8585
## buffers
8686
- name: buffers_checkpoint
87-
exp: pg_stat_bgwriter_buffers_checkpoint.rate('PT1M')
87+
exp: pg_stat_bgwriter_buffers_checkpoint_total.rate('PT1M').sum(['service_instance_id','host_name'])
8888
- name: buffers_clean
89-
exp: pg_stat_bgwriter_buffers_clean.rate('PT1M')
89+
exp: pg_stat_bgwriter_buffers_clean_total.rate('PT1M').sum(['service_instance_id','host_name'])
9090
- name: buffers_backend_fsync
91-
exp: pg_stat_bgwriter_buffers_backend_fsync.rate('PT1M')
91+
exp: pg_stat_bgwriter_buffers_backend_fsync_total.rate('PT1M').sum(['service_instance_id','host_name'])
9292
- name: buffers_alloc
93-
exp: pg_stat_bgwriter_buffers_alloc.rate('PT1M')
93+
exp: pg_stat_bgwriter_buffers_alloc_total.rate('PT1M').sum(['service_instance_id','host_name'])
9494
- name: buffers_backend
95-
exp: pg_stat_bgwriter_buffers_backend.rate('PT1M')
95+
exp: pg_stat_bgwriter_buffers_backend_total.rate('PT1M').sum(['service_instance_id','host_name'])

0 commit comments

Comments
 (0)