OceanBase
Collecting OceanBase performance metrics through the sys tenant.
Already tested version:
- OceanBase Enterprise 3.2.4
Configuration¶
Precondition¶
- Create a monitoring account
Create a monitoring account using a sys tenant account and grant the following privileges:
CREATE USER 'datakit'@'localhost' IDENTIFIED BY '<UNIQUEPASSWORD>';
-- MySQL 8.0+ create the datakit user with the caching_sha2_password method
CREATE USER 'datakit'@'localhost' IDENTIFIED WITH caching_sha2_password by '<UNIQUEPASSWORD>';
-- Grant the required permissions
GRANT SELECT ON *.* TO 'datakit'@'localhost';
Info
-
Note that if you find the collector has the following error when using
localhost, you need to replace the abovelocalhostwith::1: -
All the above creation and authorization operations limit that the user
datakitcan only access OceanBase on local host (localhost). If OceanBase is collected remotely, it is recommended to replacelocalhostwith%(indicating that DataKit can access OceanBase on any machine), or use a specific DataKit installation machine address.
Collector Configuration¶
Go to the conf.d/samples directory under the DataKit installation directory, copy oceanbase.conf.sample and name it oceanbase.conf. Examples are as follows:
[[inputs.oceanbase]]
# host name
host = "localhost"
## port
port = 2883
## tenant name
tenant = "sys"
## cluster name
cluster = "obcluster"
## user name
user = "datakit"
## password
password = "<PASS>"
## database name
database = "oceanbase"
## mode. mysql only.
mode = "mysql"
## @param connect_timeout - number - optional - default: 10s
# connect_timeout = "10s"
interval = "10s"
## OceanBase slow query time threshold defined. If larger than this, the executed sql will be reported.
slow_query_time = "0s"
## Set true to enable election
election = true
## Run a custom SQL query and collect corresponding metrics.
# [[inputs.oceanbase.custom_queries]]
# sql = '''
# select
# CON_ID tenant_id,
# STAT_ID,
# replace(name, " ", "_") metric_name,
# VALUE
# from
# v$sysstat;
# '''
# metric = "oceanbase_custom"
# tags = ["metric_name", "tenant_id"]
# fields = ["VALUE"]
[inputs.oceanbase.tags]
# some_tag = "some_value"
# more_tag = "some_other_value"
Once configured, restart DataKit.
The collector can now be turned on by ConfigMap Injection Collector Configuration.
Long Running Queries¶
DataKit could reports the SQLs, those executed time exceeded the threshold time defined by user, to Guance, displays in the Logs side bar, the source name is oceanbase_log.
This function is disabled by default, user could enabling it by modify DataKit's OceanBase configuration like followings:
Change the string value after slow_query_time from 0s to the threshold time, minimal value is 1 millsecond. Generally, recommand it to 10s.
Info
failed_obfuscate:SQL obfuscated failed reason. Only exist when SQL obfuscated failed. Original SQL will be reported when SQL obfuscated failed. For more fields, see here.- If the string value after
--slow-query-timeis0sor empty or less than 1 millisecond, this function is disabled, which is also the default state. - The SQL would not display here when execute not complete.
Metric¶
For all of the following data collections, the global election tags will added automatically, we can add extra tags in [inputs.oceanbase.tags] if needed:
oceanbase_stat¶
| Tags & Fields | Description |
|---|---|
| cluster ( tag) |
Cluster Name |
| host ( tag) |
The server address or the host Name |
| metric_name ( tag) |
The name of the statistical event. |
| stat_id ( tag) |
The ID of the statistical event. |
| svr_ip ( tag) |
The IP address of the server where the information is located. |
| tenant_id ( tag) |
Tenant id |
| tenant_name ( tag) |
Tenant Name |
| metric_value | The value of the statistical item. Type: int | (gauge) Unit: N/A |
oceanbase_cache_block¶
| Tags & Fields | Description |
|---|---|
| cache_name ( tag) |
The cache name. |
| cluster ( tag) |
Cluster Name |
| host ( tag) |
The server address or the host Name |
| svr_ip ( tag) |
The IP address of the server where the information is located. |
| svr_port ( tag) |
The port of the server where the information is located. |
| tenant_id ( tag) |
Tenant id |
| tenant_name ( tag) |
Tenant Name |
| cache_size | The block cache size in the specified statistical range. Type: int | (digital,MB) Unit: digital,MB |
oceanbase_cache_plan¶
| Tags & Fields | Description |
|---|---|
| cluster ( tag) |
Cluster Name |
| host ( tag) |
The server address or the host Name |
| svr_ip ( tag) |
The IP address of the server where the information is located. |
| svr_port ( tag) |
The port of the server where the information is located. |
| tenant_id ( tag) |
Tenant id |
| tenant_name ( tag) |
Tenant Name |
| access_count | The number of times that the query accesses the plan cache. Type: int | (count) Unit: count |
| hit_count | The number of plan cache hits. Type: int | (count) Unit: count |
oceanbase_event¶
| Tags & Fields | Description |
|---|---|
| cluster ( tag) |
Cluster Name |
| event_group ( tag) |
The group of the event. |
| host ( tag) |
The server address or the host Name |
| svr_ip ( tag) |
The IP address of the server where the information is located. |
| tenant_id ( tag) |
Tenant id |
| tenant_name ( tag) |
Tenant Name |
| time_waited | The total wait time for the event in seconds. Type: int | (time,s) Unit: time,s |
| total_waits | The total number of waits for the event. Type: int | (count) Unit: count |
oceanbase_session¶
| Tags & Fields | Description |
|---|---|
| cluster ( tag) |
Cluster Name |
| host ( tag) |
The server address or the host Name |
| svr_ip ( tag) |
The IP address of the server where the information is located. |
| svr_port ( tag) |
The port of the server where the information is located. |
| tenant_id ( tag) |
Tenant id |
| tenant_name ( tag) |
Tenant Name |
| active_cnt | The number of active sessions within a tenant. Type: int | (count) Unit: count |
| all_cnt | The total number of sessions within a tenant. Type: int | (count) Unit: count |
oceanbase_clog¶
| Tags & Fields | Description |
|---|---|
| cluster ( tag) |
Cluster Name |
| host ( tag) |
The server address or the host Name |
| replica_type ( tag) |
The type of the replica |
| svr_ip ( tag) |
The IP address of the server where the information is located. |
| svr_port ( tag) |
The port of the server where the information is located. |
| tenant_id ( tag) |
Tenant id |
| tenant_name ( tag) |
Tenant Name |
| max_clog_sync_delay_seconds | The max clog synchronization delay of an tenant. Type: int | (time,s) Unit: time,s |
Log¶
oceanbase_log¶
| Tags & Fields | Description |
|---|---|
| cluster ( tag) |
Cluster Name |
| host ( tag) |
Hostname. |
| oceanbase_server ( tag) |
The address of the database instance (including port). |
| oceanbase_service ( tag) |
OceanBase service name. |
| tenant_id ( tag) |
Tenant id |
| tenant_name ( tag) |
Tenant Name |
| message | The text of the logging. Type: string Unit: N/A |
| status | The status of the logging, only supported info/emerg/alert/critical/error/warning/debug/OK/unknown.Type: string Unit: N/A |