> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/rpr/3.0/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/rpr/3.0/observability/metrics.md).

# Metrics

RADIUS Proxy exposes metrics on the `/metrics/v1/values` endpoint. The metrics are exported in the [Prometheus format](https://prometheus.io/docs/concepts/data_model/#notation). To access metrics, an HTTP client must send a request that contains the [Accept](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Accept) header with the `text/plain` value; otherwise, RADIUS Proxy returns the [406](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/406) response code.

RADIUS Proxy metrics are divided into the following groups:

- RADIUS server metrics
- RADIUS client metrics
- HTTP API metrics
- Erlang/OTP VM runtime metrics

To expose metrics, you can configure a [ServiceMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/developer/getting-started.md#using-servicemonitors) using these Helm chart configuration options:

```
# Labels that are attached to the ServiceMonitor
additionalLabels: {}

service:
  serviceMonitor:
    # Enables the Prometheus ServiceMonitor.
    enabled: true
    # The list of labels transferred from the associated Kubernetes Service object
    # into the ingested metrics.
    targetLabels: []
    # Matches RPR Kubernetes services from the given Kubernetes namespaces
    namespaceSelector:
      matchNames:
        - monitoring
```

## RADIUS server metrics

RADIUS Proxy exposes the following RADIUS server metrics:

| Metric | Labels | Type | Description |
|---|---|---|---|
| radiusServUpTime | server_name, server_ip, server_port | gauge | Uptime of a RADIUS server in milliseconds |
| radiusServTotalRequests | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of requests received by a RADIUS server |
| radiusServTotalResponses | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of responses sent from a RADIUS server |
| radiusServTotalAccessRequests | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of Access-Requests received by a RADIUS server |
| radiusServTotalAccessAccepts | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of Access-Accept responses from a RADIUS server |
| radiusServTotalAccessRejects | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of Access-Reject responses from a RADIUS server |
| radiusServTotalAccessChallenges | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of Access-Challenge responses from a RADIUS server |
| radiusServAcctStartRequests | server_name, server_ip, server_port, nas_id, nas_ip, acct_type | counter | Number of Accounting-Start requests received by a RADIUS server |
| radiusServAcctUpdateRequests | server_name, server_ip, server_port, nas_id, nas_ip, acct_type | counter | Number of Accounting-Update requests received by a RADIUS server |
| radiusServAcctStopRequests | server_name, server_ip, server_port, nas_id, nas_ip, acct_type | counter | Number of Accounting-Stop requests received by a RADIUS server |
| radiusServAcctStartResponses | server_name, server_ip, server_port, nas_id, nas_ip, acct_type | counter | Number of Accounting-Start responses from a RADIUS server |
| radiusServAcctUpdateResponses | server_name, server_ip, server_port, nas_id, nas_ip, acct_type | counter | Number of Accounting-Update responses from a RADIUS server |
| radiusServAcctStopResponses | server_name, server_ip, server_port, nas_id, nas_ip, acct_type | counter | Number of Accounting-Stop responses from a RADIUS server |
| radiusServTotalMalformedAccessRequests | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of malformed requests received by a RADIUS server |
| radiusServTotalDupRequests | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of duplicated requests received by a RADIUS server |
| radiusServTotalUnknownTypes | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of requests of an unknown type received by a RADIUS server |
| radiusServTotalBadAuthenticators | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of requests received by a RADIUS server with a secret that is not matched to the one configured for this server |
| radiusServTotalPacketsDropped | server_name, server_ip, server_port, nas_id, nas_ip | counter | Number of packets dropped by a RADIUS server |
| radiusServRtt_bucket | le, server_name, server_ip, server_port, nas_id, nas_ip | histogram | RADIUS requests handle time on a RADIUS server provided in milliseconds |
| radiusServerActive | server_ip, server_port | gauge | State of the RADIUS relay server with the `server_ip:server_port` listener. The value of the metric is `1` if RADIUS Proxy receives responses for the forwarded requests, `0` otherwise. |

All RADIUS server metrics contain special labels which allow for accumulating metrics data for different conditions, such as the total number of RADIUS Accounting requests, the mean time of RADIUS requests handling, and so on.

The following labels are present in the RADIUS server metrics:

- `acct_type` - the type of the RADIUS Accounting request. The possible values of this label are `start`, `update`, and `stop`.
- `server_name` - the name of a RADIUS server, taken from the RPR configuration. It is created by combining `proxy_` with `auth_` or `acct_` and the server identifier. For example, with the configuration below, the server names would be `proxy_auth_1` and `proxy_acct_1`:

   ```yaml
   auth:
     1:
       listen: 127.0.0.1
   acct:
     1:
       listen: 127.0.0.1
   ```

- `server_port` - the port used by a RADIUS server
- `server_ip` - the IP address a RADIUS server listens on for incoming RADIUS requests
- `nas_ip` - the NAS IP address from which RADIUS Proxy receives RADIUS requests
- `nas_id` - the NAS identifier from which RADIUS Proxy receives RADIUS requests.

The value of the `nas_id` label depends on the RADIUS Proxy configuration. If the RADIUS source configuration specifies `nas_id`, its value is used as the label value.

For example, the following configuration of the RADIUS server produces the metric **radiusServAcctUpdateRequests{nas_id="PGW"} 2060744**:

```yaml
auth:
  proxy_radius_mock_1:
    listen: 127.0.0.1
    ports:
      - 1812
    sources:
      - secret: "secret"
        source: 127.0.0.1/28
        nas_id: PGW
```

If the `nas_id` is not defined in the RADIUS source, the value of the `nas_id` is a joint string of the RADIUS server name (the `proxy_radius_mock_1` in the example above) and the source IP address where the given request was received from.

For example, the following configuration of the RADIUS server produces the metric - **radiusServAcctUpdateRequests{nas_id="proxy_radius_mock_1_127.0.0.4"} 2060744** for the RADIUS request received from the `127.0.0.4` address:

```yaml
auth:
  proxy_radius_mock_1:
    listen: 127.0.0.1
    ports:
      - 1812
    sources:
      - secret: "secret"
        source: 127.0.0.1/28
```

The `le` label of the **radiusServRtt_bucket** metric specifies the histogram bucket for the time taken to handle incoming RADIUS requests. Since the metric is represented as a [Prometheus histogram](https://prometheus.io/docs/practices/histograms/), there are two additional associated metrics:

- **radiusServRtt_count** - total number of RADIUS requests taken into account by the histogram
- **radiusServRtt_sum** - sum of round trip time periods taken into account by the histogram

## RADIUS client metrics

RADIUS Proxy exposes the following RADIUS client metrics:

| Metric | Labels | Type | Description |
| --- |---|---|---|
| radiusClientTotalCoARequests | server_name, server_ip, server_port, client_name, client_ip | counter | Number of sent CoA requests |
| radiusClientTotalCoAAckResponses | server_name, server_ip, server_port, client_name, client_ip | counter | Number of received CoA-ACK responses |
| radiusClientTotalCoANakResponses | server_name, server_ip, server_port, client_name, client_ip | counter | Number of received CoA-NAK responses |
| radiusClientTotalDisconnectRequests | server_name, server_ip, server_port, client_name, client_ip | counter | Number of sent Disconnect requests |
| radiusClientTotalDisconnectAckResponses | server_name, server_ip, server_port, client_name, client_ip | counter | Number of received Disconnect-ACK responses |
| radiusClientTotalDisconnectNakResponses | server_name, server_ip, server_port, client_name, client_ip | counter | Number of received Disconnect-NAK responses |
| radiusClientTotalTimeouts | server_name, server_ip, server port, client_name, client_ip | counter | Number of timed out requests |
| radiusClientAcctStartRequests | server_name, server_ip, server_port, client_name, client_ip, acct_type | counter | Number of sent Accounting-Start requests |
| radiusClientAcctStartResponses | server_name, server_ip, server_port, client_name, client_ip, acct_type | counter | Number of received Accounting-Start responses |
| radiusClientAcctUpdateRequests | server_name, server_ip, server_port, client_name, client_ip, acct_type | counter | Number of sent Accounting-Update requests |
| radiusServAcctUpdateResponses | server_name, server_ip, server_port, client_name, client_ip, acct_type | counter | Number of received Accounting-Update responses |
| radiusClientAcctStopRequests | server_name, server_ip, server_port, client_name, client_ip, acct_type | counter | Number of sent Accounting-Stop requests |
| radiusClientAcctStopResponses | server_name, server_ip, server_port, client_name, client_ip, acct_type | counter | Number of received Accounting-Stop responses |

Each RADIUS client metric contains the following labels:

- `client_ip` - the IP address used by the RADIUS Proxy client to send RADIUS requests
- `client_name` - the name of the RADIUS client used by RADIUS Proxy to send RADIUS requests
- `server_name` - the RADIUS server name where the RADIUS Proxy client sends RADIUS requests
- `server_ip` - the RADIUS server IP address where the RADIUS Proxy client sends RADIUS requests
- `server_port` - the RADIUS server port where the RADIUS Proxy client sends RADIUS requests
- `acct_type` - type of RADIUS Accounting request. The possible values of this label are `start`, `update`, and `stop`.

## HTTP API metrics

RADIUS Proxy exposes the following HTTP API-related metrics:

| Metric | Labels | Type | Description |
| ---|---|---|---|
| api_request_rtt_bucket | le | histogram | API request handle time in milliseconds |
| api_request_total | | counter | Total number of API requests |
| api_request_success | | counter | Total number of successfully handled requests |
| api_request_error | | counter | Total number of failed API requests |

The **api_requests_rtt** metric contains the `le` label that specifies the [Prometheus histogram](https://prometheus.io/docs/practices/histograms/) bucket for the time taken to handle incoming HTTP API requests. There are two additional metrics for the HTTP API handling time:

- **api_requests_rtt_count** - total number of observations taken into account by the histogram
- **api_requests_rtt_sum** - sum of time periods that RADIUS Proxy spent to handle HTTP API requests

## VM runtime metrics

RADIUS Proxy exposes the following Open Telecom Platform (OTP) runtime metrics:

| Metric | Labels | Type | Description |
| ---|---|---|---|
| runtime_otp_release | | counter | Version of Erlang Open Telecom Platform (OTP) |
| runtime_start_time | | counter | Start time of Erlang OTP virtual machine (VM) |
| runtime_uptime | | counter | Uptime of Erlang VM in milliseconds |
| runtime_garbage_collection | datapoint | counter | Garbage collection information |
| runtime_io | datapoint | counter | Input/Output information that specifies the total number of bytes received and sent from/to ports.|
| runtime_ram | datapoint | counter | Memory usage information |
| runtime_ports | datapoint | counter | Erlang VM ports information |
| runtime_processes | datapoint | counter | Number of Erlang OTP processes |
| runtime_processors | datapoint | counter | Number of processors used in the system |

The value of the `datapoint` label depends on the metric.

The **runtime_garbage_collection** metric may have the following datapoint values:

- `number_of_gcs` - total number of garbage collections performed by a VM
- `words_reclaimed` - total number of words reclaimed during garbage collections

The **runtime_io** metric may have the following datapoint values:

- `input` - total number of bytes received by a VM
- `output` - total number of bytes sent by a VM

The **runtime_ram** metric may have the following datapoint values:

- `total` - total number of bytes currently allocated by the RADIUS Proxy VM
- `processes` - total number of bytes allocated for the processes
- `processes_used` - total number of bytes currently used by the processes
- `system` - total number of bytes allocated by the RADIUS Proxy VM for system purposes
- `atom` - total number of bytes allocated by the RADIUS Proxy VM for atoms
- `atom_used` - total number of bytes currently used for atoms
- `binary` - total number of bytes allocated by the RADIUS Proxy VM for binaries
- `code` - total number of bytes allocated by the RADIUS Proxy VM for code
- `ets` - total number of bytes allocated by the RADIUS Proxy VM for in-memory Erlang Term Storage (ETS) tables

The **runtime_ports** metric may have the following datapoint values:

- `port_count` - number of ports currently existing at the RADIUS Proxy node
- `port_limit` - maximum number of simultaneously existing ports at the RADIUS Proxy node

The **runtime_processes** metric may have the following datapoint values:

- `process_count` - number of processes launched by RADIUS Proxy
- `process_limit` - maximum number of processes that can be launched by RADIUS Proxy
- `run_queue_size` - total length of all normal and dirty CPU run queues

The **runtime_processors** metric may have the following datapoint values:

- `logical_processors` - detected number of logical processors configured in the system
- `logical_processors_available` - detected number of logical processors available to the RADIUS Proxy runtime system
