# Network I/O metrics

{% hint style="info" %}
**Supported event types:** `logs`
{% endhint %}

The *Network I/O metrics* (`netif`) input plugin gathers network traffic information of the running system at regular intervals, and reports them. This plugin is available only for Linux.

The Network I/O metrics plugin creates metrics that are log-based, such as JSON payload. For Prometheus-based metrics, see the [Node Exporter metrics](https://docs.fluentbit.io/manual/4.2/data-pipeline/inputs/node-exporter-metrics) input plugin.

## Metrics reported

The following table describes the metrics generated by the plugin. Metric names are prefixed with the interface name (for example, `eth0`):

| Key                      | Description                                     |
| ------------------------ | ----------------------------------------------- |
| `{interface}.rx.bytes`   | Number of bytes received on the interface.      |
| `{interface}.rx.packets` | Number of packets received on the interface.    |
| `{interface}.rx.errors`  | Number of receive errors on the interface.      |
| `{interface}.tx.bytes`   | Number of bytes transmitted on the interface.   |
| `{interface}.tx.packets` | Number of packets transmitted on the interface. |
| `{interface}.tx.errors`  | Number of transmit errors on the interface.     |

## Configuration parameters

The plugin supports the following configuration parameters:

| Key             | Description                                                                                                                         | Default |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `interface`     | Specify the network interface to monitor. For example, `eth0`.                                                                      | *none*  |
| `interval_nsec` | Polling interval in nanoseconds.                                                                                                    | `0`     |
| `interval_sec`  | Polling interval in seconds.                                                                                                        | `1`     |
| `test_at_init`  | If true, test if the network interface is valid at initialization.                                                                  | `false` |
| `threaded`      | Indicates whether to run this input in its own [thread](https://docs.fluentbit.io/manual/4.2/administration/multithreading#inputs). | `false` |
| `verbose`       | If true, gather metrics precisely.                                                                                                  | `false` |

## Get started

To monitor network traffic from your system, you can run the plugin from the command line or through the configuration file.

### Command line

Run Fluent Bit using a command similar to the following:

```shell
fluent-bit -i netif -p interface=eth0 -o stdout
```

Which returns output similar to the following:

```
...
[0] netif.0: [1499524459.001698260, {"eth0.rx.bytes"=>89769869, "eth0.rx.packets"=>73357, "eth0.rx.errors"=>0, "eth0.tx.bytes"=>4256474, "eth0.tx.packets"=>24293, "eth0.tx.errors"=>0}]
[1] netif.0: [1499524460.002541885, {"eth0.rx.bytes"=>98, "eth0.rx.packets"=>1, "eth0.rx.errors"=>0, "eth0.tx.bytes"=>98, "eth0.tx.packets"=>1, "eth0.tx.errors"=>0}]
[2] netif.0: [1499524461.001142161, {"eth0.rx.bytes"=>98, "eth0.rx.packets"=>1, "eth0.rx.errors"=>0, "eth0.tx.bytes"=>98, "eth0.tx.packets"=>1, "eth0.tx.errors"=>0}]
[3] netif.0: [1499524462.002612971, {"eth0.rx.bytes"=>98, "eth0.rx.packets"=>1, "eth0.rx.errors"=>0, "eth0.tx.bytes"=>98, "eth0.tx.packets"=>1, "eth0.tx.errors"=>0}]
...
```

### Configuration file

In your main configuration file append the following:

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
  inputs:
    - name: netif
      tag: netif
      interface: eth0
      interval_sec: 1
      interval_nsec: 0
      verbose: false
      test_at_init: false

  outputs:
    - name: stdout
      match: '*'
```

{% endtab %}

{% tab title="fluent-bit.conf" %}

```
[INPUT]
  Name          netif
  Tag           netif
  Interface     eth0
  Interval_Sec  1
  Interval_Nsec 0
  Verbose       false
  Test_At_Init  false

[OUTPUT]
  Name   stdout
  Match  *
```

{% endtab %}
{% endtabs %}

Total interval (sec) = `interval_sec` + (`interval_nsec` / 1000000000)

For example: `1.5s` = `1s` + `500000000ns`
