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

# Metrics

NetCap Sink and NetCap Collector expose metrics in the [Prometheus format](https://prometheus.io/docs/concepts/data_model/#notation) on the `/metrics` endpoint on port `9999`.

| Name | Type | Labels |Description |
|:---|:---|---|---|
| netcap_collected_packets_total | COUNTER | | Total number of packets collected from NetCap VPP Plugins. |
| netcap_nats_collected_packets_total | COUNTER | subject | Total number of packets collected from NATS messages. |
| netcap_nats_messages_received | COUNTER | subject | Total number of messages received over NATS. |
| netcap_nats_messages_sent | COUNTER | subject | Total number of messages sent over NATS. |
| netcap_nats_payload_bytes_received | COUNTER | subject | NATS message payload bytes received in total. |
| netcap_nats_payload_bytes_sent | COUNTER | subject | NATS message payload bytes sent in total. |
| netcap_packets_dropped_total | COUNTER | subject | Total number of packets dropped before reaching destinations. |
| netcap_plugins | GAUGE | subject | Number of NetCap VPP Plugins connected to NetCap Collector. |
| netcap_stream | GAUGE | batchingStrategyDuration, batchingStrategyPacketBytes, batchingStrategyPacketCount, compress, destination, max_bytes, max_files, max_packets, natsMode, path_prefix, rotation, schedule, subject, target | List of all streams that existed. The value `1` means that the stream is created. The value `0` means that the stream was deleted. |
| netcap_wrote_uncompressed_bytes | COUNTER | | Total number of bytes written to the destination output. |

The `subject` label provides information about the NATS subject associated with the event on which the metric change is triggered. See the example of a label for the subject string:

`cdm.local.netcap.v1alpha1.bcast.pcaps.jetstream.cluster.test-cluster.namespace.pgw-ocs.pod.upg-inst01-8446f5867f-gn69s.interface.sxb.nwi.not_available.imsi.not_available.filter.not_available.target.sx-ex.labels.not_available`

The **netcap_stream** metric has the following labels that describe the parameters of a stream created by NetCap Sink or Collector:
- `batchingStrategyDuration` - Time interval before sending a batch of packets
- `batchingStrategyPacketBytes` - Number of bytes gathered before sending a batch of packets
- `batchingStrategyPacketCount` - Number of packets to accumulate before sending a batch of packets
- `compress` - Defines the compression format of PCAP data. The possible values are: `zstd`, `lz4`, `gzip` or empty
- `destination` - Specifies where the packets are sent. The possible values are: `nats`, `file`, `s3`, `sftp`
- `max_bytes` - Rotation parameter that specifies the maximum bytes per file
- `max_files` - Rotation parameter that specifies the maximum number of files
- `max_packets` - Rotation parameter that specifies the maximum number of packets per file
- `natsMode` - NATS mode to use for sending and receiving NATS messages. The possible values are: `pubsub` or `jetstream`
- `path_prefix` - Prefix for the autogenerated name of the PCAP file
- `rotation` - Bool values if the PCAP file rotation is enabled
- `schedule` - Defines the rotation schedule of a PCAP file, can be a cron expression
- `target` - A stream identifier that equals to the name of a `NetCaptureJob` object

## NetCap VPP Plugin metrics

FPP and UPG pods expose the following NetCap-related metrics:

| Name | Type | Labels |Description |
|:---|:---|---|---|
| **vpp_netcap_dropped_packets_total** | COUNTER | reason | Number of packets dropped for the reason provided in the label. |
| **vpp_netcap_streams_created** | GAUGE | | Number of NetCap streams created. |

The `reason` label specifies a reason why packets were dropped. The possible values are:

- `ring-overflow` - NetCap Collector is too slow to process packets
- `stream-stopped` - the stream is stopped

## Capture information

You can use the additional metadata provided in a `.pcapng` file for advanced filters in tools like Wireshark:

| Name | Description |
|:---|:---|
| `frame.interface_name` | Interface name. |
| `frame.interface_description` | Additional information that includes a target name. |
| `frame.interface_queue` | Worker index where packet capture happened. |
| `frame.packet_flags_direction` | Direction of a packet relative to VPP. |
| `frame.time` | Time of packet capture. Multiple packets can have the same capture time when they share the same vector in VPP. |
| `frame.cap_len` | Capture length. It can be different from the packet length when additional capture limiter parameters are provided. |
| `frame.drop_count` | Number of dropped packets for the packet interface. This field is optional. It exists when slow IO causes packet loss. |
