Create a monitoring account using a sys tenant account and grant the following privileges:
CREATEUSER'datakit'@'localhost'IDENTIFIEDBY'<UNIQUEPASSWORD>';-- MySQL 8.0+ create the datakit user with the caching_sha2_password methodCREATEUSER'datakit'@'localhost'IDENTIFIEDWITHcaching_sha2_passwordby'<UNIQUEPASSWORD>';-- Grant the required permissions GRANTSELECTON*.*TO'datakit'@'localhost';
Attention
Note that if you find the collector has the following error when using localhost , you need to replace the above localhost with ::1 Error 1045: Access denied for user 'datakit'@'localhost' (using password: YES)
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 replace localhost with % (indicating that DataKit can access OceanBase on any machine), or use a specific DataKit installation machine address.
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 namehost="localhost"## portport=2883## tenant nametenant="sys"## cluster namecluster="obcluster"## user nameuser="datakit"## passwordpassword="<PASS>"## database namedatabase="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 electionelection=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"
Datakit could reports the SQLs, those executed time exceeded the threshold time defined by user, to Guance Cloud, 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.
slow_query_time = "0s"
Fields description
failed_obfuscate:SQL obfuscated failed reason. Only exist when SQL obfuscated failed. Original SQL will be reported when SQL obfuscated failed.
More fields.
Attention
If the string value after --slow-query-time is 0s or empty or less than 1 millisecond, this function is disabled, which is also the default state.
The SQL would not display here when NOT executed completed.
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: