Configuring Flow-Based Statistics Collection
To configure J-Flow on a virtual router:
- Enable J-Flow statistics.
- Enable J-Flow statistics on the desired interfaces.
- (Optional) Define the sampling interval at which you want to collect statistics.
- (Optional) Customize the size of the main flow cache.
- (Optional) Define flow cache aging timers.
- (Optional) Specify to where you want to export J-Flow statistics.
Enabling Flow-Based Statistics
Use the ip flow statistics command to explicitly enable J-Flow.
NOTE: Issuing any configuration level commands implicitly enables J-Flow.
ip flow statistics
host1(config)#ip flow statisticsUse the no version to disable J-Flow on the virtual router. Enabling Flow-Based Statistics on an Interface
Use the ip route-cache flow sampled command to enable J-Flow on an interface.
NOTE: Issuing an interface-level flow command does not enable J-Flow on the virtual router. To enable J-Flow, issue the ip flow statistics command.
ip route-cache flow sampled
host1(config-if)#ip route-cache flow sampledUse the no version to disable J-Flow statistics on the interface. Defining a Sampling Interval
Use the ip flow-sampling-mode command to define the packet-sampling interval for the virtual router. The sampling interval specifies the rate at which the virtual router samples J-Flow information. This rate is used for all interfaces that have J-Flow enabled. Once you enable an interface, the virtual router samples 1 packet at the specified packet interval. The possible interval range is from 10 packets to 4 billion packets (the default).
ip flow-sampling-mode packet-interval
host1(config)#ip flow-sampling-mode packet-interval 50Use the no version to return the sampling interval to its default value. Setting Cache Size
Use the ip flow-cache entries command to limit the number of main flow cache entries for the virtual router (as collected across all line modules that are running J-Flow). Once the cache size exceeds the flow-cache entry limit, the least recently used flow is removed.
The possible flow-cache range is 1,024 to 524,288 entries. The default is 65,536 entries.
ip flow-cache entries
host1(config)#ip flow-cache entries 80000Use the no version to return the cache size to its default value, 65535. Defining Aging Timers
Once the virtual router creates a flow in the cache, the flow can be removed at the expiration of either the active or the inactive timer.
Specifying the Activity Timer
Use the ip flow-cache timeout active command to specify a value for the activity timer. The activity timer measures the amount of time that the virtual router has been recording a datagram for a given flow. When this timer expires, the virtual router exports the flow cache entry from the cache and removes the entry. This process prevents active flows from remaining in the flow cache and allows collected data to appear in a timely manner. The possible range for the activity timer is 1 to 60 minutes. The default value is 30 minutes.
ip flow-cache timeout active
host1(config)#ip flow-cache timeout active 50Use the no version to return the activity timer to its default value. Specifying the Inactivity Timer
Use the ip flow-cache timeout inactive command to specify a value for the inactivity timer. The inactivity timer measures the length of time expired since the virtual router recorded the last datagram for a given flow. When this timer expires, the virtual router exports the flow cache entry from the cache and removes it. When, at a later time, another datagram begins that uses the same flow characteristics, the virtual router allocates a new flow cache entry, and the inactivity timer begins again. The possible range for the inactivity timer is from 10 to 600 seconds. The default value is 15 seconds.
ip flow-cache timeout inactive
host1(config)#ip flow-cache timeout inactive 80Use the no version to return the inactivity timer to its default value. Specifying Flow Export
Use the ip flow-export command to specify the location to which you want to export the J-Flow datagrams.
ip flow-export
- Use to specify the location to which you want to export J-Flow datagrams or specify an alternate source address for outbound export J-Flow datagrams.
- Example 1—Specifies the destination address for J-Flow datagrams
host1(config)#ip flow-export 192.168.2.73 2055 version 5 peer-asExample 2—Specifies the source address for outbound export J-Flow datagrams host1(config)#ip flow-export source fastEthernet 5/0Use the no version to remove the export setting.