> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/tposs/latest/observability/db.md).

# Database and storage metrics

> [!TIP]
> For the metrics endpoint, the export formats, and the conventions that apply to all the metrics, see the [Metrics](https://docs.cennso.com/components/tposs/latest/observability/metrics.md) document.

TPOSS exposes the following database metrics:

| Metric | Type | Labels | Description |
|---|---|---|---|
| db_requests_total | counter | | Total number of queries to the database |
| db_requests_ok | counter | | Total number of successful queries to the database |
| db_requests_error | counter | | Total number of failed queries to the database |
| db_requests_rtt | histogram | le | Duration of calls to the database in milliseconds |
| db_requests_query_rtt | histogram | le | Duration of database queries in milliseconds |
| db_requests_queue_rtt | histogram | le | Duration of the query queue time in milliseconds |
| db_requests_decode_rtt | histogram | le | Time spent decoding the result of a query in milliseconds |
| db_requests_idle_rtt | histogram | le | Duration a connection was idle before use in milliseconds |
| db_pool_free_connections | gauge | | Number of free connections in a database pool |
| db_pool_queue_length | gauge | | Number of queries waiting in a database pool queue for a free database connection |
| db_connections_total | gauge | | Number of database connections configured in TPOSS |
| db_connections_connected_total | gauge | | Number of database connections successfully connected to a database |
| db_health_status | gauge | component | Database health status |
| tposs_cdr_db_handler_errors | counter | | Number of failures of TPOSS CDR database controller |
| accounts_activated | counter | | Total number of activated accounts |
| accounts_total | counter | | Total number of accounts |
| balances_total | counter | | Total number of balances |
| cdrs_total | counter | | Total number of closed CDRs |
| sessions_total | counter | | Total number of charging sessions |
| carriers_total | counter | | Total number of carriers |
| carrier_groups_total | counter | | Total number of carrier groups |
| services_total | counter | | Total number of services |
| tariffs_total | counter | | Total number of tariffs |
| service_profiles_total | counter | | Total number of service profiles |
| public_users_total | counter | | Total number of public users |
| private_users_total | counter | | Total number of private users |
| credentials_total | counter | | Total number of credentials |
| subscribers_total | counter | | Total number of subscribers |
| whitelist_imeis | gauge | | Number of IMEIs in the whitelist |

Look at these metrics when TPOSS becomes slow. They show whether the database can handle the workload and whether TPOSS still has free connections to it.

The **db_health_status** metric provides the `component` value, which represents the status of the database health check procedure. The label may have the following values:

- `ping` - Result of the MySQL protocol-level ping sent directly to the database host.
- `queue` - Specifies whether the database connection pool queue length is below the configured maximum.

The value of the metric is `1` if the check was successful, or `0` if not.

For more information, see the [Database health check](https://docs.cennso.com/components/tposs/latest/configuration/db.md#database-health-check) settings section.

## CDR file storage

TPOSS writes CDRs to the MySQL database, to files that an external billing system fetches, or to both. The following metric counts the failures of the file-based storage:

| Metric | Type | Description |
|---|---|---|
| tposs_cdr_file_handler_errors | counter | Number of failures from accessing the filesystem for CDR storage operations. |
