Configuring sFlow

This chapter contains the following sections:

About sFlow

sFlow allows you to monitor the real-time traffic in data networks that contain switches and routers. It uses the sampling mechanism in the sFlow Agent software on switches and routers for monitoring traffic and to forward the sample data on ingress and egress ports to the central data collector, also called the sFlow Analyzer.

For more information about sFlow, see RFC 3176.

sFlow Agent

The sFlow Agent, which is embedded in the Cisco NX-OS software, periodically samples or polls the interface counters that are associated with a data source of the sampled packets. The data source can be an Ethernet interface, an EtherChannel interface, or a range of either. Ethernet or port-channel sub-interfaces are not supported. The sFlow Agent queries the Ethernet port manager for the respective EtherChannel membership information and also receives notifications from the Ethernet port manager for membership changes.

When you enable sFlow sampling in the Cisco NX-OS software, based on the sampling rate and the hardware internal random number, the ingress packets and egress packets are sent to the CPU as an sFlow-sampled packet. The sFlow Agent processes the sampled packets and sends an sFlow datagram to the sFlow Analyzer. In addition to the original sampled packet, an sFlow datagram includes the information about the ingress port, egress port, and the original packet length. An sFlow datagram can have multiple sFlow samples.

Prerequisites

You must enable the sFlow feature using the feature sflow command to configure sFlow.

Guidelines and Limitations for sFlow

The sFlow configuration guidelines and limitations are as follows:

  • When you enable sFlow for an interface, it is enabled for both ingress and egress. You cannot enable sFlow for only ingress or only egress.

  • sFlow egress sampling for multicast, broadcast, or unknown unicast packets is not supported.

  • You should configure the sampling rate based on the sFlow configuration and traffic in the system.

  • Cisco Nexus 3600 platform switches supports only one sFlow collector.

  • Ethernet or port-channel sub-interfaces are not supported as sFlow data-source ports.

  • You cannot configure individual port-channel member ports as sFlow data-sources. The port-channel bundle interface can be sFlow enabled data-source ports, such as sFlow data-source interface po1.

  • For Cisco Nexus N3K-C36180YC-R, N3K-C3636C-R, N9K-X9636C-RX, and N9K-X96136YC-R platform switches, egress sampled traffic will always have the first data-source interface in the list as Source ID index in sflow record.

Default Settings for sFlow

Table 1. Default sFlow Parameters
Parameters Default
sFlow sampling-rate 4096
sFlow sampling-size 128
sFlow max datagram-size 1400
sFlow collector-port 6343
sFlow counter-poll-interval 20

Minimum Requirements for Sampling

Without these configured, no packets will be sampled: After you enable the sFlow feature, you must explicitly configure the following configuration elements for the packet sampling to take effect on the device.

  • Sflow Agent-IP

  • Sflow Collector-IP

  • Sflow Data-source interface

If you do not configure the configuration elements, packets will not be sampled.

The default configuration elements specified as the default settings for sFlow are optional.

Configuring sFlow

Enabling the sFlow Feature

You must enable the sFlow feature before you can configure sFlow on the switch.

SUMMARY STEPS

  1. switch# configure terminal
  2. [no] feature sflow
  3. (Optional) show feature
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

[no] feature sflow

Enables the sFlow feature.

Step 3

(Optional) show feature

(Optional)

Displays enabled and disabled features.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

The following example shows how to enable the sFlow feature:

switch# configure terminal
switch(config)# feature sflow
switch(config)# copy running-config startup-config

Configuring the Sampling Rate

Before you begin

Ensure that you have enabled the sFlow feature.

SUMMARY STEPS

  1. switch# configure terminal
  2. [no] sflow sampling-rate sampling-rate
  3. (Optional) show sflow
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

[no] sflow sampling-rate sampling-rate

Configures the sFlow sampling rate for packets.

The sampling-rate can be an integer between 4096-1000000000. The default value is 4096.

Step 3

(Optional) show sflow

(Optional)

Displays sFlow information.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to set the sampling rate to 50,000:

switch# configure terminal
switch(config)# sflow sampling-rate 50000
switch(config)# copy running-config startup-config

With the above configuration, approximately 1 out of every 50,000 packets will be sampled and sent to the sFlow collector. Note that there could be a slight variance.

Configuring the Maximum Sampled Size

You can configure the maximum number of bytes that should be copied from a sampled packet.

Before you begin

Ensure that you have enabled the sFlow feature.

SUMMARY STEPS

  1. switch# configure terminal
  2. [no] sflow max-sampled-size sampling-size
  3. (Optional) show sflow
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

[no] sflow max-sampled-size sampling-size

Configures the sFlow maximum sampling size packets.

The range for the sampling-size is from 64 to 256 bytes. The default value is 128.

Step 3

(Optional) show sflow

(Optional)

Displays configured sFlow values.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configure the maximum sampling size for the sFlow Agent:

switch# configure terminal
switch(config)# sflow max-sampled-size 200
switch(config)# copy running-config startup-config

Configuring the Counter Poll Interval

You can configure the maximum number of seconds between successive samples of the counters that are associated with the data source. A sampling interval of 0 disables counter sampling.

Before you begin

Ensure that you have enabled the sFlow feature.

SUMMARY STEPS

  1. switch# configure terminal
  2. [no] sflow counter-poll-interval poll-interval
  3. (Optional) show sflow
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

[no] sflow counter-poll-interval poll-interval

Configures the sFlow poll interval for an interface. The range for the poll-interval is from 0 to 2147483647 seconds. The default value is 20. Configuring 0 disables the counter polling.

Step 3

(Optional) show sflow

(Optional)

Displays sFlow information.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configure the sFlow poll interval for an interface:

switch# configure terminal
switch(config)# sflow counter-poll-interval 100
switch(config)# copy running-config startup-config

Configuring the Maximum Datagram Size

You can configure the maximum number of data bytes that can be sent in a single sample datagram.

Before you begin

Ensure that you have enabled the sFlow feature.

SUMMARY STEPS

  1. switch# configure terminal
  2. [no] sflow max-datagram-size datagram-size
  3. (Optional) show sflow
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

[no] sflow max-datagram-size datagram-size

Configures the sFlow maximum datagram size.

The range for the datagram-size is from 200 to 9000 bytes. The default value is 1400.

Step 3

(Optional) show sflow

(Optional)

Displays configured sFlow values.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configure the sFlow maximum datagram size:

switch# configure terminal
switch(config)# sflow max-datagram-size 2000
switch(config)# copy running-config startup-config
[########################################] 100%

Configuring the sFlow Analyzer Address

Before you begin

Ensure that you have enabled the sFlow feature.

SUMMARY STEPS

  1. switch# configure terminal
  2. [no] sflow collector-ip vrf IP-address vrf-instance
  3. (Optional) show sflow
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

[no] sflow collector-ip vrf IP-address vrf-instance

Configures the IPv4 address for the sFlow Analyzer.

vrf-instance can be one of the following:

  • A user-defined VRF name—You can specify a maximum of 32 alphanumeric characters.

  • vrf management — You must use this option if the sFlow data collector is on the network connected to the management port.

  • vrf default —You must use this option if the sFlow data collector is connected to a network reachable via any front panel port residing on the default vrf.

Step 3

(Optional) show sflow

(Optional)

Purpose "Displays configured sFlow values.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configure the IPv4 address of the sFlow data collector that is connected to the management port:

switch# configure terminal
switch(config)# sflow collector-ip 192.0.2.5 vrf management
switch(config)# copy running-config startup-config

Configuring the sFlow Analyzer Port

You can configure the destination port for sFlow datagrams.

Before you begin

Ensure that you have enabled the sFlow feature.

SUMMARY STEPS

  1. switch# configure terminal
  2. [no] sflow collector-port collector-port
  3. (Optional) show sflow
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

[no] sflow collector-port collector-port

Configures the UDP port of the sFlow Analyzer.

The range for the collector-port is from 0 to 65535. The default value is 6343.

Step 3

(Optional) show sflow

(Optional)

Displays configured sFlow values.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configure the destination port for sFlow datagrams:

switch# configure terminal
switch(config)# sflow collector-port 7000
switch(config)# copy running-config startup-config
[########################################] 100%
switch(config)#

Configuring the sFlow Agent Address

Before you begin

Ensure that you have enabled the sFlow feature.

SUMMARY STEPS

  1. switch# configure terminal
  2. [no] sflow agent-ip ip-address
  3. (Optional) show sflow
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

[no] sflow agent-ip ip-address

Configures the IPv4 address of the sFlow Agent.

The default ip-address is 0.0.0.0, which means that all sampling is disabled on the switch. You must specify a valid IP address to enable sFlow functionality. The configured value can be an IP address present on the local system or any other arbitrary IP value desired for a tracking purpose.

Step 3

(Optional) show sflow

(Optional)

Displays sFlow information.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configure the IPv4 address of the sFlow Agent:

switch# configure terminal
switch(config)# sflow agent-ip 192.0.2.3
switch(config)# copy running-config startup-config

Configuring the sFlow Sampling Data Source

The sFlow sampling data source can be an Ethernet port, a range of Ethernet ports, or a port channel.

Before you begin

  • Ensure that you have enabled the sFlow feature.

  • If you want to use a port channel as the data source, ensure that you have already configured the port channel and you know the port channel number.

SUMMARY STEPS

  1. switch# configure terminal
  2. switch(config)# [no] sflow data-source interface [ethernet slot/port[-port] |port-channel channel-number]
  3. (Optional) switch(config)# show sflow
  4. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

switch(config)# [no] sflow data-source interface [ethernet slot/port[-port] |port-channel channel-number]

Configures the sFlow sampling data source.

For an Ethernet data source, slot is the slot number and port can be either a single port number or a range of ports designated as port-port .

Step 3

(Optional) switch(config)# show sflow

(Optional)

Displays configured sFlow values.

Step 4

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configure Ethernet ports 5 through 12 for the sFlow sampler:

switch# configure terminal
switch(config)# sflow data-source interface ethernet 1/5-12
switch(config)# copy running-config startup-config
[########################################] 100%
switch(config)#

This example shows how to configure port channel 100 for the sFlow sampler:

switch# configure terminal
switch(config)# sflow data-source interface port-channel 100
switch(config)# copy running-config startup-config
[########################################] 100%
switch(config)#

Verifying the sFlow Configuration

Use the following commands to verify the sFlow configuration information:

Command Purpose

show sflow

Displays the sFlow global configuration.

show sflow statistics

Displays the sFlow statistics.

clear sflow statistics

Clears the sFlow statistics.

show running-config sflow [all]

Displays the current running sFlow configuration.

Configuration Examples for sFlow

This example shows how to configure sFlow:

feature sflow
sflow sampling-rate 5000
sflow max-sampled-size 200
sflow counter-poll-interval 100
sflow max-datagram-size 2000
sflow collector-ip 192.0.2.5 vrf management
sflow collector-port 7000
sflow agent-ip 192.0.2.3
sflow data-source interface ethernet 1/5

Additional References for sFlow

Table 2. Related Documents for sFlow
Related Topic Document Title

sFlow CLI commands

Cisco Nexus 3600 NX-OS Command Reference.

RFC 3176

Defines the sFlow packet format and SNMP MIB.

http://www.sflow.org/rfc3176.txt