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 | N/A |
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 /*+ MONITOR_AGENT READ_CONSISTENCY(WEAK) */ case when cnt is null then 0 else cnt end as cnt, tenant_name, tenant_id from (select __all_tenant.tenant_name, __all_tenant.tenant_id, cnt from __all_tenant left join (select count(`state`='ACTIVE' OR NULL) as cnt, tenant as tenant_name from __all_virtual_processlist where svr_ip = ? and svr_port = ? group by tenant) t1 on __all_tenant.tenant_name = t1.tenant_name) t2If you use OceanBase Database V4.0 or later, execute the following statement:
select /* MONITOR_AGENT */ case when cnt is null then 0 else cnt end as cnt, tenant_name, tenant_id from (select DBA_OB_TENANTS.tenant_name, DBA_OB_TENANTS.tenant_id, cnt from DBA_OB_TENANTS left join (select count(`state`='ACTIVE' OR NULL) as cnt, tenant as tenant_name from GV$OB_PROCESSLIST where svr_ip = ? and svr_port = ? group by tenant) t1 on DBA_OB_TENANTS.tenant_name = t1.tenant_name where DBA_OB_TENANTS.tenant_type<>'META') t2
all_session
Definition
The total number of sessions within a tenant.
Description
| Metric | Metric name | Unit |
|---|---|---|
| all_session | all_session | N/A |
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 /*+ MONITOR_AGENT READ_CONSISTENCY(WEAK) */ case when cnt is null then 0 else cnt end as cnt, tenant_name, tenant_id from (select __all_tenant.tenant_name, __all_tenant.tenant_id, cnt from __all_tenant left join (select count(1) as cnt, tenant as tenant_name from __all_virtual_processlist where svr_ip = ? and svr_port = ? group by tenant) t1 on __all_tenant.tenant_name = t1.tenant_name) t2If you use OceanBase Database V4.0 or later, execute the following statement:
select /* MONITOR_AGENT */ case when cnt is null then 0 else cnt end as cnt, tenant_name, tenant_id from (select DBA_OB_TENANTS.tenant_name, DBA_OB_TENANTS.tenant_id, cnt from DBA_OB_TENANTS left join (select count(1) as cnt, tenant as tenant_name from GV$OB_PROCESSLIST where svr_ip = ? and svr_port = ? group by tenant) t1 on DBA_OB_TENANTS.tenant_name = t1.tenant_name where DBA_OB_TENANTS.tenant_type<>'META') t2