Set up flows to monitor network trafficedit

You can configure Packetbeat to collect and report statistics on network flows. A flow is a group of packets sent over the same time period that share common properties, such as the same source and destination address and protocol. You can use this feature to analyze network traffic over specific protocols on your network.

For each flow, Packetbeat reports the number of packets and the total number of bytes sent from the source to the destination. Each flow event also contains information about the source and destination hosts, such as their IP address. For bi-directional flows, Packetbeat reports statistics for the reverse flow.

Packetbeat collects and reports statistics up to and including the transport layer. See Flow Event fields for more info about the exported data.

Here’s an example of flow events visualized in the Flows dashboard:

./images/flows.png

To configure flows, use the packetbeat.flows option in the packetbeat.yml config file. Flows are enabled by default. If this section is missing from the configuration file, network flows are disabled.

packetbeat.flows:
  timeout: 30s
  period: 10s

Here’s an example of a flow information sent by Packetbeat. See Flow Event fields for a description of each field.

{
  "@timestamp": "2017-05-03T19:42:40.003Z",
  "beat": {
    "hostname": "host.example.com",
    "name": "host.example.com",
    "version": "6.5.0"
  },
  "connection_id": "AQAAAAAAAAA=",
  "dest": {
    "ip": "192.0.2.0",
    "mac": "fe:ff:20:00:01:00",
    "port": 80,
    "stats": {
      "net_bytes_total": 19236,
      "net_packets_total": 16
    }
  },
  "final": false, 
  "flow_id": "EQwA////DP//////FBgBAAEAAAEAAAD+/yAAAQCR/qDtQdDk3ywNUAABAAAAAAAAAA",
  "last_time": "2017-05-03T19:42:24.151Z",
  "source": {
    "ip": "203.0.113.0",
    "mac": "00:00:01:00:00:00",
    "port": 3372,
    "stats": {
      "net_bytes_total": 1243,
      "net_packets_total": 14
    }
  },
  "start_time": "2017-05-03T19:42:24.151Z",
  "transport": "tcp",
  "type": "flow"
}

Packetbeat sets the final flag to false to indicate that the event contains an intermediate report about a flow that it’s tracking. When the flow completes, Packetbeat sends one last event with final set to true. If you want to aggregate sums of traffic, you need to filter on final:true, or use some other technique, so that you get only the latest update from each flow. You can disable intermediate reports by setting period: -1s.

Configuration optionsedit

You can specify the following options in the packetbeat.flows section of the packetbeat.yml config file:

enablededit

Enables flows support if set to true. Set to false to disable network flows support without having to delete or comment out the flows section. The default value is true.

timeoutedit

Timeout configures the lifetime of a flow. If no packets have been received for a flow within the timeout time window, the flow is killed and reported. The default value is 30s.

periodedit

Configure the reporting interval. All flows are reported at the very same point in time. Periodical reporting can be disabled by setting the value to -1. If disabled, flows are still reported once being timed out. The default value is 10s.

fieldsedit

Optional fields that you can specify to add additional information to the output. For example, you might add fields that you can use for filtering log data. Fields can be scalar values, arrays, dictionaries, or any nested combination of these. By default, the fields that you specify here will be grouped under a fields sub-dictionary in the output document. To store the custom fields as top-level fields, set the fields_under_root option to true. If a duplicate field is declared in the general configuration, then its value will be overwritten by the value declared here.

fields_under_rootedit

If this option is set to true, the custom fields are stored as top-level fields in the output document instead of being grouped under a fields sub-dictionary. If the custom field names conflict with other field names added by Packetbeat, then the custom fields overwrite the other fields.

tagsedit

A list of tags that will be sent with the protocol event. This setting is optional.

processorsedit

A list of processors to apply to the data generated by the protocol.

See Filter and enhance the exported data for information about specifying processors in your config.