This topic describes the performance metrics related to the number of sessions within an OceanBase Database tenant. A session is a connection established between an application and a database. The related metrics include all_session and active_session. The all_session metric indicates the total number of sessions within the tenant and the active_session metric indicates the number of active sessions within the tenant. You can specify a statistical range to query the number of sessions in a single zone or on a single OBServer of an OceanBase Database tenant.
active_session
Definition
The number of active sessions within a tenant.
Description
| Metric | Metric name | Unit |
|---|---|---|
| active_session | active_session | times/s |
Calculation expression
sum(ob_active_session_num{@LABELS}) by (@GBLABELS)
SQL statements for metric collection
If you use OceanBase Database of a version earlier than V4.0, execute the following statement:
select t1.tenant_name, coalesce(t2.active_cnt, 0) as active_cnt, coalesce(t2.all_cnt, 0) as all_cnt from (select tenant_name from v$unit) t1 left join (select count(`state`='ACTIVE' OR NULL) as active_cnt, count(1) as all_cnt, tenant as tenant_name from __all_virtual_processlist where svr_ip = ? and svr_port = ? group by tenant) t2 on t1.tenant_name = t2.tenant_nameIf you use OceanBase Database V4.0 or later, execute the following statement:
select t1.tenant_name, coalesce(t2.active_cnt, 0) as active_cnt, coalesce(t2.all_cnt, 0) as all_cnt from (select tenant_name from dba_ob_tenants where tenant_type <> 'META') t1 left join (select count(`state`='ACTIVE' OR NULL) as active_cnt, count(1) as all_cnt, tenant as tenant_name from V$OB_PROCESSLIST where svr_ip = ? and svr_port = ? group by tenant) t2 on t1.tenant_name = t2.tenant_name
all_session
Definition
The total number of sessions within a tenant.
Description
| Metric | Metric name | Unit |
|---|---|---|
| all_session | all_session | times/s |
Calculation expression
sum(ob_all_session_num{@LABELS}) by (@GBLABELS)
SQL statements for metric collection
If you use OceanBase Database of a version earlier than V4.0, execute the following statement:
select t1.tenant_name, coalesce(t2.active_cnt, 0) as active_cnt, coalesce(t2.all_cnt, 0) as all_cnt from (select tenant_name from v$unit) t1 left join (select count(`state`='ACTIVE' OR NULL) as active_cnt, count(1) as all_cnt, tenant as tenant_name from __all_virtual_processlist where svr_ip = ? and svr_port = ? group by tenant) t2 on t1.tenant_name = t2.tenant_nameIf you use OceanBase Database V4.0 or later, execute the following statement:
select t1.tenant_name, coalesce(t2.active_cnt, 0) as active_cnt, coalesce(t2.all_cnt, 0) as all_cnt from (select tenant_name from dba_ob_tenants where tenant_type <> 'META') t1 left join (select count(`state`='ACTIVE' OR NULL) as active_cnt, count(1) as all_cnt, tenant as tenant_name from V$OB_PROCESSLIST where svr_ip = ? and svr_port = ? group by tenant) t2 on t1.tenant_name = t2.tenant_name