> 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/api.md).

# API metrics

> [!TIP]
> TPOSS always exposes these metrics regardless of configuration. TPOSS configuration can have an impact only on the `nnas_*`, `npcf_*`, and `nchf_*` values of the `api` label and the [external API](#external-api) metrics. Those can appear only if **sbi.enabled** or **cdmp.enabled** is set to `true`.
>
> 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 API-related metrics:

| Metric | Type | Labels | Description |
| ---|---|---|---|
| api_requests_rtt | histogram | api, le | Latency distribution (in milliseconds) for handling API requests |
| api_requests_total | counter | api | Total number of API requests received by TPOSS |
| api_requests_success | counter | api | Total number of successfully handled API requests |
| api_requests_error | counter | api, code | Total number of failed API requests |

Look at these metrics when provisioning is slow or fails. They show how many API calls arrive, how many fail, and how long they take.

The `code` label of the **api_requests_error** metric is the [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status) returned by the TPOSS API handlers.

The `api` label identifies the type of TPOSS API. The metrics listed above are collected for the following API types:

- [HTTP REST API](https://docs.cennso.com/components/tposs/latest/api-reference/rest/api.md)
- [CDMP API](https://docs.cennso.com/components/tposs/latest/architecture/cdmp.md)
- [SBI API](https://docs.cennso.com/components/tposs/latest/architecture/sbi.md)

For the TPOSS HTTP REST API, the `api` label consists of the API name and action split by an underscore. The following API actions are used:

- `create`
- `update`
- `upgrade`
- `read`
- `bulk_read`
- `fetch`
- `import`
- `delete`
- `delete_old`
- `list`
- `combined_list`
- `stop`

For example - `subscriber_create`, `account_delete`, `balance_upgrade`, `cdr_bulk_read`, and so on.

For SBI and CDMP, the `api` label may have the following values that show the number of requests, responses, and the latency of the given type of API:

- `nnas_auth_create`
- `nnas_auth_update`
- `nnas_auth_release`
- `nnas_acct_create`
- `nnas_acct_update`
- `nnas_acct_release`
- `npcf_create`
- `npcf_update`
- `npcf_release`
- `nchf_create`
- `nchf_update`
- `nchf_release`

## External API

In addition to the API handlers that TPOSS provides, TPOSS also uses external API and exposes the following metrics triggered when TPOSS executes external API calls:

| Metric | Type | Labels | Description |
| ---|---|---|---|
| npcf_rar_requests_total | counter | | Total number of SBI Npcf reauthorization requests |
| npcf_rar_request_errors_total | counter | reason | Total number of SBI Npcf reauthorization errors |
| nchf_rar_requests_total | counter | | Total number of SBI Nchf reauthorization requests |
| nchf_rar_request_errors_total | counter | reason | Total number of SBI Nchf reauthorization errors |
| nchf_asr_requests_total | counter | | Total number of SBI Nchf abort session requests |
| nchf_asr_request_errors_total | counter | reason | Total number of SBI Nchf abort session errors |

The `reason` label of the error metrics represents the reason why the outgoing request failed. The `reason` can be an [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status) or one of the following values:

- `cant_send_request` - TPOSS should send an outgoing request, but can not do it because of not enough data for the given session.
- `client_failure` - A client used by TPOSS failed to send a request due to overload or another reason, or sent a request but did not get a response.
- `pool_error` - TPOSS should send an outgoing request, but can not do it because no connections are available.
