2020-05-24 18:47:16 +00:00
# net collector
The net collector exposes metrics about network interfaces
|||
-|-
Metric name prefix | `net`
Data source | Perflib
Classes | [`Win32_PerfRawData_Tcpip_NetworkInterface` ](https://technet.microsoft.com/en-us/security/aa394340(v=vs.80 ))
Enabled by default? | Yes
## Flags
2023-04-01 07:48:23 +00:00
### `--collector.net.nic-include`
2020-05-24 18:47:16 +00:00
2023-04-01 07:48:23 +00:00
If given, an interface name needs to match the include regexp in order for the corresponding metrics to be reported
2020-05-24 18:47:16 +00:00
2023-04-01 07:48:23 +00:00
### `--collector.net.nic-exclude`
2020-05-24 18:47:16 +00:00
2023-04-01 07:48:23 +00:00
If given, an interface name needs to *not* match the exclude regexp in order for the corresponding metrics to be reported
2020-05-24 18:47:16 +00:00
## Metrics
Name | Description | Type | Labels
-----|-------------|------|-------
`windows_net_bytes_received_total` | Total bytes received by interface | counter | `nic`
`windows_net_bytes_sent_total` | Total bytes transmitted by interface | counter | `nic`
`windows_net_bytes_total` | Total bytes received and transmitted by interface | counter | `nic`
2023-03-25 20:27:07 +00:00
`windows_net_output_queue_length_packets` | Length of the output packet queue (in packets). If this is longer than 2, delays occur. | gauge | `nic`
2021-02-02 19:42:38 +00:00
`windows_net_packets_outbound_discarded_total` | Total outbound packets that were chosen to be discarded even though no errors had been detected to prevent transmission | counter | `nic`
2020-11-14 02:38:01 +00:00
`windows_net_packets_outbound_errors_total` | Total packets that could not be transmitted due to errors | counter | `nic`
`windows_net_packets_received_discarded_total` | Total inbound packets that were chosen to be discarded even though no errors had been detected to prevent delivery | counter | `nic`
`windows_net_packets_received_errors_total` | Total packets that could not be received due to errors | counter | `nic`
2021-11-10 01:03:05 +00:00
`windows_net_packets_received_total` | Total packets received by interface | counter | `nic`
2020-11-14 02:38:01 +00:00
`windows_net_packets_received_unknown_total` | Total packets received by interface that were discarded because of an unknown or unsupported protocol | counter | `nic`
2020-05-24 18:47:16 +00:00
`windows_net_packets_total` | Total packets received and transmitted by interface | counter | `nic`
`windows_net_packets_sent_total` | Total packets transmitted by interface | counter | `nic`
2021-06-14 15:33:27 +00:00
`windows_net_current_bandwidth_bytes` | Estimate of the interface's current bandwidth in bytes per second | gauge | `nic`
2020-05-24 18:47:16 +00:00
### Example metric
Query the rate of transmitted network traffic
```
rate(windows_net_bytes_sent_total{instance="localhost"}[2m])
```
## Useful queries
Get total utilisation of network interface as a percentage
```
2021-06-14 15:33:27 +00:00
rate(windows_net_bytes_total{instance="localhost", nic="Microsoft_Hyper_V_Network_Adapter__1"}[2m]) / windows_net_current_bandwidth_bytes{instance="localhost", nic="Microsoft_Hyper_V_Network_Adapter__1"} * 100
2020-05-24 18:47:16 +00:00
```
## Alerting examples
**prometheus.rules**
```yaml
- alert: NetInterfaceUsage
2021-06-14 15:33:27 +00:00
expr: rate(windows_net_bytes_total[2m]) / windows_net_current_bandwidth_bytes * 100 > 95
2020-05-24 18:47:16 +00:00
for: 10m
labels:
severity: high
annotations:
summary: "Network Interface Usage (instance {{ $labels.instance }})"
description: "Network traffic usage is greater than 95% for interface {{ $labels.nic }}\n VALUE = {{ $value }}\n LABELS: {{ $labels }}"
```