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 abovelocalhost
with::1
: -
All the above creation and authorization operations limit that the user
datakit
can only access OceanBase on local host (localhost
). If OceanBase is collected remotely, it is recommended to replacelocalhost
with%
(indicating that DataKit can access OceanBase on any machine), or use a specific DataKit installation machine address.
Collector Configuration¶
Go to the conf.d/db
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-time
is0s
or 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
Tag | Description |
---|---|
cluster | Cluster Name |
host | The server address or the host Name |
metric_name | The name of the statistical event. |
stat_id | The ID of the statistical event. |
svr_ip | The IP address of the server where the information is located. |
tenant_id | Tenant id |
tenant_name | Tenant Name |
- Metrics
Metric | Description |
---|---|
metric_value | The value of the statistical item. Type: int Unit: N/A |
oceanbase_cache_block
¶
- Tags
Tag | Description |
---|---|
cache_name | The cache name. |
cluster | Cluster Name |
host | The server address or the host Name |
svr_ip | The IP address of the server where the information is located. |
svr_port | The port of the server where the information is located. |
tenant_id | Tenant id |
tenant_name | Tenant Name |
- Metrics
Metric | Description |
---|---|
cache_size | The block cache size in the specified statistical range. Type: int Unit: digital,MB |
oceanbase_cache_plan
¶
- Tags
Tag | Description |
---|---|
cluster | Cluster Name |
host | The server address or the host Name |
svr_ip | The IP address of the server where the information is located. |
svr_port | The port of the server where the information is located. |
tenant_id | Tenant id |
tenant_name | Tenant Name |
- Metrics
Metric | Description |
---|---|
access_count | The number of times that the query accesses the plan cache. Type: int Unit: count |
hit_count | The number of plan cache hits. Type: int Unit: count |
oceanbase_event
¶
- Tags
Tag | Description |
---|---|
cluster | Cluster Name |
event_group | The group of the event. |
host | The server address or the host Name |
svr_ip | The IP address of the server where the information is located. |
tenant_id | Tenant id |
tenant_name | Tenant Name |
- Metrics
Metric | Description |
---|---|
time_waited | The total wait time for the event in seconds. Type: int Unit: time,s |
total_waits | The total number of waits for the event. Type: int Unit: count |
oceanbase_session
¶
- Tags
Tag | Description |
---|---|
cluster | Cluster Name |
host | The server address or the host Name |
svr_ip | The IP address of the server where the information is located. |
svr_port | The port of the server where the information is located. |
tenant_id | Tenant id |
tenant_name | Tenant Name |
- Metrics
Metric | Description |
---|---|
active_cnt | The number of active sessions within a tenant. Type: int Unit: count |
all_cnt | The total number of sessions within a tenant. Type: int Unit: count |
oceanbase_clog
¶
- Tags
Tag | Description |
---|---|
cluster | Cluster Name |
host | The server address or the host Name |
replica_type | The type of the replica |
svr_ip | The IP address of the server where the information is located. |
svr_port | The port of the server where the information is located. |
tenant_id | Tenant id |
tenant_name | Tenant Name |
- Metrics
Metric | Description |
---|---|
max_clog_sync_delay_seconds | The max clog synchronization delay of an tenant. Type: int Unit: time,s |
Log¶
oceanbase_log
¶
- Tags
Tag | Description |
---|---|
cluster | Cluster Name |
host | Hostname. |
oceanbase_server | The address of the database instance (including port). |
oceanbase_service | OceanBase service name. |
tenant_id | Tenant id |
tenant_name | Tenant Name |
- Metrics
Metric | Description |
---|---|
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 |