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

# Metrics 

Connectivity Gateway (CGW) exposes the following metrics in the Prometheus
format on the `/metrics` endpoint. Metrics are grouped by the exporter that
produces them; each exporter is enabled independently.

## Bird Exporter

When the Bird Exporter is enabled (`bird.enabled` and
`bird.birdExporter.enabled`), the following metrics are exposed:

| Name | Type | Description |
| --- | --- | --- |
| bird_protocol_changes_update_export_accept_count | GAUGE | Number of accepted outgoing updates |
| bird_protocol_changes_update_export_filter_count | GAUGE | Number of filtered outgoing updates |
| bird_protocol_changes_update_export_ignore_count | GAUGE | Number of ignored outgoing updates |
| bird_protocol_changes_update_export_receive_count | GAUGE | Number of sent updates |
| bird_protocol_changes_update_export_reject_count | GAUGE | Number of rejected outgoing updates |
| bird_protocol_changes_update_import_accept_count | GAUGE | Number of accepted incoming updates |
| bird_protocol_changes_update_import_filter_count | GAUGE | Number of filtered incoming updates |
| bird_protocol_changes_update_import_ignore_count | GAUGE | Number of ignored incoming updates |
| bird_protocol_changes_update_import_receive_count | GAUGE | Number of received updates |
| bird_protocol_changes_update_import_reject_count | GAUGE | Number of rejected incoming updates |
| bird_protocol_changes_withdraw_export_accept_count | GAUGE | Number of accepted outgoing withdraws |
| bird_protocol_changes_withdraw_export_filter_count | GAUGE | Number of filtered outgoing withdraws |
| bird_protocol_changes_withdraw_export_ignore_count | GAUGE | Number of ignored outgoing withdraws |
| bird_protocol_changes_withdraw_export_receive_count | GAUGE | Number of outgoing withdraws |
| bird_protocol_changes_withdraw_export_reject_count | GAUGE | Number of rejected outgoing withdraws |
| bird_protocol_changes_withdraw_import_accept_count | GAUGE | Number of accepted incoming withdraws |
| bird_protocol_changes_withdraw_import_filter_count | GAUGE | Number of filtered incoming withdraws |
| bird_protocol_changes_withdraw_import_ignore_count | GAUGE | Number of ignored incoming withdraws |
| bird_protocol_changes_withdraw_import_receive_count | GAUGE | Number of received withdraws |
| bird_protocol_changes_withdraw_import_reject_count | GAUGE | Number of rejected incoming withdraws |
| bird_protocol_prefix_export_count | GAUGE | Number of exported routes |
| bird_protocol_prefix_filter_count | GAUGE | Number of filtered routes |
| bird_protocol_prefix_import_count | GAUGE | Number of imported routes |
| bird_protocol_prefix_preferred_count | GAUGE | Number of preferred routes |
| bird_protocol_up | GAUGE | Specifies that the protocol is up |
| bird_protocol_uptime | GAUGE | Uptime of the protocol in seconds |

## Bird Config Watcher

When the Bird Config Watcher is enabled (`bird.birdConfigWatcher.enabled`), the
following metrics are exposed. Each is a stateset: it carries a label of the
same name as the metric whose value is either `valid` or `invalid` (e.g.
`bird4_config_state{bird4_config_state="valid"} 1`).

| Name | Type | Description |
| --- | --- | --- |
| bird4_config_state | GAUGE | Bird IPv4 config state |
| bird6_config_state | GAUGE | Bird IPv6 config state |

## Ping Exporter

When the Ping Exporter is enabled (`pingExporter.enabled`), the following
metrics are exposed:

| Name | Type | Description |
| --- | --- | --- |
| ping_loss_percent | GAUGE | Packet loss in percent |
| ping_rtt_best_ms | GAUGE | Best round trip time in milliseconds |
| ping_rtt_mean_ms | GAUGE | Mean round trip time in milliseconds |
| ping_rtt_ms | GAUGE | Round trip time in milliseconds (deprecated) |
| ping_rtt_std_deviation_ms | GAUGE | Standard deviation in milliseconds |
| ping_rtt_worst_ms | GAUGE | Worst round trip time in milliseconds |

## IPsec Exporter

When the IPsec Exporter is enabled (`ipsecExporter.enabled`), the following
metrics are exposed. The `strongswan_conn_*` metrics are only present when
`--enable-conn-metrics` is set, and the `strongswan_cert_*` metrics only when
`--enable-cert-metrics` is set.

`strongswan_ike_info` carries the labels `ike_name`, `ike_id`, `local_id`,
`remote_id` and `remote_host`. Joining it on `ike_name` and `ike_id` adds the
peer to any `strongswan_ike_*` or `strongswan_sa_*` metric:

```promql
sum by (remote_id) (
  rate(strongswan_sa_inbound_bytes[5m])
  * on (ike_name, ike_id) group_left (remote_id)
  strongswan_ike_info
)
```

| Name | Type | Description |
| --- | --- | --- |
| strongswan_ike_count | GAUGE | Number of known IKEs |
| strongswan_ike_info | GAUGE | Identities and remote host of this IKE, always 1 |
| strongswan_ike_version | GAUGE | Version of this IKE |
| strongswan_ike_status | GAUGE | Status of this IKE |
| strongswan_ike_initiator | GAUGE | Flag if the server is the initiator for this connection |
| strongswan_ike_nat_local | GAUGE | Flag if the local endpoint is behind nat |
| strongswan_ike_nat_remote | GAUGE | Flag if the remote server is behind nat |
| strongswan_ike_nat_fake | GAUGE | Flag if NAT situation has been faked as responder |
| strongswan_ike_nat_any | GAUGE | Flag if any endpoint is behind a NAT (also if faked) |
| strongswan_ike_encryption_key_size | GAUGE | Key size of the encryption algorithm |
| strongswan_ike_integrity_key_size | GAUGE | Key size of the integrity algorithm |
| strongswan_ike_established_seconds | GAUGE | Seconds since the IKE was established |
| strongswan_ike_rekey_seconds | GAUGE | Seconds until the IKE will be rekeyed |
| strongswan_ike_reauth_seconds | GAUGE | Seconds until the IKE will be reauthed |
| strongswan_ike_children_size | GAUGE | Count of children of this IKE |
| strongswan_sa_status | GAUGE | Status of this child sa |
| strongswan_sa_encap | GAUGE | Forced Encapsulation in UDP Packets |
| strongswan_sa_encryption_key_size | GAUGE | Key size of the encryption algorithm |
| strongswan_sa_integrity_key_size | GAUGE | Key size of the integrity algorithm |
| strongswan_sa_inbound_bytes | GAUGE | Number of input bytes processed |
| strongswan_sa_inbound_packets | GAUGE | Number of input packets processed |
| strongswan_sa_last_inbound_seconds | GAUGE | Number of seconds since the last inbound packet was received |
| strongswan_sa_outbound_bytes | GAUGE | Number of output bytes processed |
| strongswan_sa_outbound_packets | GAUGE | Number of output packets processed |
| strongswan_sa_last_outbound_seconds | GAUGE | Number of seconds since the last outbound packet was sent |
| strongswan_sa_established_seconds | GAUGE | Seconds since the child SA was established |
| strongswan_sa_rekey_seconds | GAUGE | Seconds until the child SA will be rekeyed |
| strongswan_sa_lifetime_seconds | GAUGE | Seconds until the lifetime expires |
| strongswan_conn_count | GAUGE | Number of loaded connections |
| strongswan_conn_version | GAUGE | IKE version for connection |
| strongswan_conn_reauth_time | GAUGE | IKE_SA reauthentication interval in seconds |
| strongswan_conn_rekey_time | GAUGE | IKE_SA rekeying interval in seconds |
| strongswan_conn_child_count | GAUGE | Number of CHILD_SA configurations |
| strongswan_conn_child_rekey_time | GAUGE | CHILD_SA rekeying interval in seconds |
| strongswan_conn_child_rekey_bytes | GAUGE | CHILD_SA rekeying interval in bytes |
| strongswan_conn_child_rekey_packets | GAUGE | CHILD_SA rekeying interval in packets |
| strongswan_cert_count | GAUGE | Number of X509 certificates |
| strongswan_cert_valid | GAUGE | X509 certificate validity |
| strongswan_cert_expire_secs | GAUGE | Seconds until the X509 certificate expires |

## Conntrack Exporter

When the Conntrack Exporter is enabled (`conntrackExporter.enabled`), the
following metrics of the pod network namespace are exposed:

| Name | Type | Description |
| --- | --- | --- |
| node_nf_conntrack_entries | GAUGE | Current number of conntrack entries |
| node_nf_conntrack_entries_limit | GAUGE | Maximum of conntrack entries (`net.netfilter.nf_conntrack_max`) |
| node_sysctl_net_netfilter_nf_conntrack_buckets | GAUGE | Size of the conntrack hash table |
| node_sysctl_net_netfilter_nf_conntrack_generic_timeout | GAUGE | Lifetime of an entry of a protocol without its own tracker, in seconds |
| node_sysctl_net_netfilter_nf_conntrack_icmp_timeout | GAUGE | Lifetime of an ICMP entry, in seconds |
| node_sysctl_net_netfilter_nf_conntrack_tcp_timeout_close_wait | GAUGE | Lifetime of a TCP entry in CLOSE_WAIT, in seconds |
| node_sysctl_net_netfilter_nf_conntrack_tcp_timeout_established | GAUGE | Lifetime of an established TCP entry, in seconds (kernel default 432000, five days) |
| node_sysctl_net_netfilter_nf_conntrack_tcp_timeout_fin_wait | GAUGE | Lifetime of a TCP entry in FIN_WAIT, in seconds |
| node_sysctl_net_netfilter_nf_conntrack_tcp_timeout_time_wait | GAUGE | Lifetime of a TCP entry in TIME_WAIT, in seconds |
| node_sysctl_net_netfilter_nf_conntrack_udp_timeout | GAUGE | Lifetime of a UDP entry that has seen traffic in one direction only, in seconds |
| node_sysctl_net_netfilter_nf_conntrack_udp_timeout_stream | GAUGE | Lifetime of a UDP entry that has seen traffic in both directions, in seconds |
| node_scrape_collector_duration_seconds | GAUGE | Duration of the last collector scrape |

> **NOTE:** All values are read from `/proc/sys/net/netfilter/`, which is per
> network namespace. They describe the conntrack of the CGW pod, not of the
> node.

A conntrack table fills up for one of two reasons: the limit is too low for the
traffic, or entries live longer than the traffic that created them. The timeout
values above cover the second case, which the entry count alone does not show —
the kernel keeps an established TCP entry for five days by default, so a
gateway that sees many short lived TCP connections can accumulate entries far
beyond the number of connections actually in use. Comparing
`node_nf_conntrack_entries` against `node_nf_conntrack_entries_limit` tells you
how full the table is; the timeouts tell you which protocol is holding it.

`node_sysctl_net_netfilter_nf_conntrack_buckets` relates to lookup cost rather
than capacity: it is the number of hash buckets, and dividing
`node_nf_conntrack_entries_limit` by it yields the average chain length the
kernel has to walk (the default ratio is 4).

> **NOTE:** The exporter also exposes
> `node_scrape_collector_success{collector="conntrack"}`, which is `0` on
> kernels built without `CONFIG_NF_CONNTRACK_PROCFS`. Those kernels do not
> provide `/proc/net/stat/nf_conntrack`, so the exporter cannot read the
> per-CPU conntrack statistics (`insert_failed`, `drop`, `early_drop`, …) and
> reports the collector as failed even though the two metrics above are
> collected. The option is marked obsolete by the kernel — the statistics are
> only reachable over Netlink, e.g. with `conntrack -S`.
