# Observability

The logs, metrics, traces and profiles of Ella PSAP.

## Logs

JSON, one object per line, on standard output.

| Field | Present |
| --- | --- |
| `ts`, `level`, `msg` | Always. |
| `trace_id`, `span_id`, `trace_flags` | While a trace is active. |
| `smsc`, `account`, `smpp` | On the logs of an SMPP session: the SMSC, the account, and the session's own fields. |

### Audit events

Audit events are logs at level `info` with `msg` set to `audit event`.

| Field | Description |
| --- | --- |
| `action` | What was done. |
| `actor` | Email of the user who did it. Empty when unknown. |
| `ip` | Address the request came from. |
| `details` | What was done, in words. |

## Metrics

Served at [`GET /api/v1/metrics`](<https://docs.ellanetworks.com/psap/reference/api/metrics/index.md>), with the Go runtime (`go_*`) and process (`process_*`) metrics.

| Metric | Type | Labels | Description |
| --- | --- | --- | --- |
| `ellapsap_build_info` | gauge | `version`, `revision`, `branch`, `goversion`, `goos`, `goarch`, `tags` | Always 1. |
| `ellapsap_api_request_duration_seconds` | histogram | `method`, `route`, `code` | Duration of API requests. Profiles under `/api/v1/pprof/` are left out. |
| `ellapsap_database_query_duration_seconds` | histogram | `pool` (`read`, `write`) | Duration of database calls. |
| `ellapsap_database_query_errors_total` | counter | `pool` (`read`, `write`) | Database calls that failed. |
| `ellapsap_database_storage_bytes` | gauge | `file` (`main`, `wal`) | Size of the database on disk. |
| `ellapsap_calls_total` | counter | `trunk`, `outcome` (`abandoned`, `ended`) | Emergency calls received, counted when they end. |
| `ellapsap_callbacks_total` | counter | `trunk`, `outcome` (`ended`, `unanswered`, `failed`) | Callbacks placed, counted when they end. |
| `ellapsap_texts_total` | counter | `smsc`, `direction` (`in`, `out`) | Texts received and sent. A concatenated text counts once. |
| `ellapsap_oidc_logins_total` | counter | `outcome` (`success`, or a [login error](<https://docs.ellanetworks.com/psap/reference/api/auth/index.md#errors>)) | Logins through the identity provider. |
| `ellapsap_aml_reports_total` | counter | `smsc`, `method` (`G`, `W`, `C`, `N`, `other`, or empty when missing) | AML reports received. |
| `ellapsap_aml_findings_total` | counter | `rule` (`AML-1` to `AML-7`), `severity` (`error`, `warning`) | Findings on AML reports. |
| `ellapsap_smpp_sessions` | gauge | `smsc`, `account` (`texts`, `aml`), `status` (`connecting`, `bound`, `disconnected`) | SMPP sessions to the SMSCs. |

## Traces

OpenTelemetry traces, exported over OTLP/gRPC to `telemetry.otlp_endpoint` when `telemetry.enabled` is set. The service name is `ella-psap`. Each API request is a span, except `/api/v1/livez`, `/api/v1/readyz`, `/api/v1/metrics` and `/api/v1/pprof/`, with its database calls as child spans. Incoming W3C `traceparent` headers are honoured.

## Profiles

Go runtime profiles under [`/api/v1/pprof/`](<https://docs.ellanetworks.com/psap/reference/api/pprof/index.md>).
