cisco.ios.ios_flow_monitor_global module – Resource module to configure Flexible NetFlow on Cisco IOS XE.
Note
This module is part of the cisco.ios collection (version 11.7.1).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install cisco.ios.
To use it in a playbook, specify: cisco.ios.ios_flow_monitor_global.
New in cisco.ios 11.7.0
Synopsis
This module manages the Flexible NetFlow global configuration on Cisco IOS XE devices.
It manages flow records, flow exporters, samplers, and flow monitors as named entities.
Aliases: flow_monitor_global
Parameters
Parameter |
Comments |
|---|---|
Flexible NetFlow global configuration. |
|
Flow exporter definitions. |
|
Human-readable description of the exporter. |
|
Destination IP address for the exporter. |
|
DSCP value for exported packets. |
|
Export protocol (ipfix or netflow-v9). Choices:
|
|
Name of the flow exporter. |
|
Exporter option records to send. |
|
Timeout for application-table option export (seconds, NBAR). |
|
Timeout for exporter-stats option export (seconds). |
|
Timeout for interface-table option export (seconds). |
|
Timeout for sampler-table option export (seconds). |
|
Timeout for template data option export (seconds). |
|
Timeout for vrf-table option export (seconds). |
|
Source interface for exported packets. |
|
Interval to re-send template records (seconds). |
|
Transport protocol and port. |
|
Destination port number. |
|
Transport protocol (tcp is router-only). Choices:
|
|
Time-to-live for exported packets. |
|
VRF for the destination. |
|
Flow monitor definitions. |
|
Cache settings. |
|
Maximum number of cache entries. Catalyst 9300 accepts this without an error but does not keep it in the running configuration, so it is reported as changed on every run there. |
|
Active flow cache timeout (seconds). |
|
Inactive flow cache timeout (seconds). |
|
Update/sync cache timeout for permanent caches (seconds). |
|
Cache type (permanent is router-only). Choices:
|
|
Human-readable description of the monitor. |
|
List of exporter names to use (supports multiple exporters). |
|
Name of the flow monitor. |
|
Name of the flow record to use. |
|
Flow record definitions. |
|
Flow record collect fields. |
|
Collect byte counter ( Accepted by Catalyst 9600 and routers. Rejected by Catalyst 9300 as an incomplete command, use counter_bytes_long or counter_bytes_layer2_long there. Choices:
|
|
Collect Layer 2 byte counter ( Rejected by Catalyst 9300 and 9600 as an incomplete command, use counter_bytes_layer2_long there. Choices:
|
|
Collect 64-bit Layer 2 byte counter ( This is the byte counter recommended for Catalyst 9300. Accepted on Catalyst 9300 and 9600. Choices:
|
|
Collect 64-bit byte counter. Accepted on Catalyst 9300 and 9600. Choices:
|
|
Collect packet counter ( Accepted by Catalyst 9600 and routers. Rejected by Catalyst 9300 as an incomplete command, use counter_packets_long there. Choices:
|
|
Collect 64-bit packet counter. Accepted on Catalyst 9300 and 9600. Choices:
|
|
Collect ingress 802.1Q VLAN. Choices:
|
|
Collect egress 802.1Q VLAN. Choices:
|
|
Collect ingress destination MAC. Choices:
|
|
Collect egress destination MAC. Choices:
|
|
Collect ingress source MAC. Choices:
|
|
Collect egress source MAC. Choices:
|
|
Collect flow sampler ID. Choices:
|
|
Collect input interface. Choices:
|
|
Collect output interface. Choices:
|
|
Collect IPv4 destination address. Choices:
|
|
Collect IPv4 destination mask. Choices:
|
|
Collect IPv4 destination prefix. Choices:
|
|
Collect IPv4 protocol. Choices:
|
|
Collect IPv4 source address. Choices:
|
|
Collect IPv4 source mask. Choices:
|
|
Collect IPv4 source prefix. Choices:
|
|
Collect IPv4 version. Choices:
|
|
Collect IPv6 destination address. Choices:
|
|
Collect IPv6 destination mask. Choices:
|
|
Collect IPv6 destination prefix. Choices:
|
|
Collect IPv6 protocol. Choices:
|
|
Collect IPv6 source address. Choices:
|
|
Collect IPv6 source mask. Choices:
|
|
Collect IPv6 source prefix. Choices:
|
|
Collect IPv6 version. Choices:
|
|
Collect destination AS number ( Rejected by Catalyst 9300 and 9600 as an incomplete command, use routing_destination_as_4octet there. Choices:
|
|
Collect 4-octet destination AS number. Accepted on Catalyst 9300 and 9600. Choices:
|
|
Collect peer destination AS number. Rejected by Catalyst 9300 and 9600 as an incomplete command. Choices:
|
|
Collect IPv4 next-hop address. Choices:
|
|
Collect IPv6 next-hop address. Choices:
|
|
Collect source AS number ( Rejected by Catalyst 9300 and 9600 as an incomplete command, use routing_source_as_4octet there. Choices:
|
|
Collect 4-octet source AS number. Accepted on Catalyst 9300 and 9600. Choices:
|
|
Collect peer source AS number. Rejected by Catalyst 9300 and 9600 as an incomplete command. Choices:
|
|
Collect absolute timestamp at flow start. Accepted on Catalyst 9300 and 9600. Choices:
|
|
Collect absolute timestamp at last packet. Accepted on Catalyst 9300 and 9600. Choices:
|
|
Collect system uptime at flow start. Accepted by Catalyst 9600 and routers. Rejected by Catalyst 9300, use timestamp_absolute_first there. Choices:
|
|
Collect system uptime at last packet. Accepted by Catalyst 9600 and routers. Rejected by Catalyst 9300, use timestamp_absolute_last there. Choices:
|
|
Collect transport destination port. Choices:
|
|
Collect transport source port. Choices:
|
|
Collect TCP flags. Choices:
|
|
Flow record match fields. |
|
Match application name (NBAR). Choices:
|
|
Match 802.1Q priority. Choices:
|
|
Match ingress 802.1Q VLAN. Choices:
|
|
Match egress 802.1Q VLAN. Choices:
|
|
Match EtherType. Choices:
|
|
Match ingress destination MAC address. Choices:
|
|
Match egress destination MAC address. Choices:
|
|
Match ingress source MAC address. Choices:
|
|
Match egress source MAC address. Choices:
|
|
Match ingress VLAN. Choices:
|
|
Match egress VLAN. Choices:
|
|
Match flow direction (ingress/egress). Choices:
|
|
Match input interface. Choices:
|
|
Match output interface. Choices:
|
|
Match IPv4 destination address. Choices:
|
|
Match IPv4 protocol field. Choices:
|
|
Match IPv4 source address. Choices:
|
|
Match IPv4 ToS/DSCP field. Choices:
|
|
Match IPv4 TTL. Choices:
|
|
Match IPv4 version. Choices:
|
|
Match IPv6 destination address. Choices:
|
|
Match IPv6 hop-limit. Choices:
|
|
Match IPv6 protocol. Choices:
|
|
Match IPv6 source address. Choices:
|
|
Match IPv6 traffic class. Choices:
|
|
Match IPv6 version. Choices:
|
|
Match input routing VRF. Choices:
|
|
Match transport layer destination port. Choices:
|
|
Match ICMP IPv4 code. Choices:
|
|
Match ICMP IPv4 type. Choices:
|
|
Match ICMP IPv6 code. Choices:
|
|
Match ICMP IPv6 type. Choices:
|
|
Match transport layer source port. Choices:
|
|
Name of the flow record. |
|
Sampler definitions. |
|
Human-readable description of the sampler. |
|
Sampling mode. Choices:
|
|
Name of the sampler. |
|
Sampling rate expressed as N in “1 out-of N”. |
|
This option is used only with state parsed. The value of this option should be the output of the command show running-config | section ^(flow|sampler) on the device. The state parsed reads the configuration from |
|
The state the configuration should be left in. State merged merges the provided config into the existing device config. State replaced converges only the records, exporters, samplers and monitors named in State overridden additionally removes every record, exporter, sampler and monitor that is not named in State deleted removes the specified (or all) flow monitor entities. Deletion order is monitors → exporters → samplers → records to respect dependencies. State rendered, gathered and parsed do not perform any change on the device. Choices:
|
Notes
Note
Tested against Cisco IOS XE.
This module works with connection
network_cli. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.htmlThe module examples use callback plugin (stdout_callback = yaml) to generate task output in yaml format.
Some options (
cache type permanent,transport tcp) are only supported on router platforms.Catalyst 9300 accepts
cache entrieswithout an error but does not keep it in the running configuration. A monitor that setscache.entriesis therefore reported as changed on every run on that platform, so leave it out there. Thecachetimeouts are kept.The platforms accept different
collectoptions. The module does not check the platform, the device rejects an option it does not support when the commands are applied. Commands sent before the rejected one stay applied.Tested on a Catalyst 9300 (IOS XE 17.12.4 and 17.18.4) and a Catalyst 9600 (C9606R, IOS XE 17.12.5 and 17.12.6), all with Network Advantage and DNA Advantage licenses. The license does not change which options are accepted, and IOS XE 17.12.5 and 17.12.6 gave the same results.
Catalyst 9600 accepts
counter_bytesandcounter_packets(collect counter bytes,collect counter packets) andtimestamp_sys_uptime_firstandtimestamp_sys_uptime_last. Existing flow records on these devices use them.Catalyst 9300 rejects
counter_bytesandcounter_packetswith% Incomplete command, and rejectstimestamp_sys_uptime_firstandtimestamp_sys_uptime_lastas invalid input. Usecounter_bytes_long,counter_bytes_layer2_long,counter_packets_long,timestamp_absolute_firstandtimestamp_absolute_lastthere.Both Catalyst 9300 and Catalyst 9600 reject
counter_bytes_layer2(it needslong, usecounter_bytes_layer2_long),routing_source_asandrouting_destination_aswithout qualifier, and therouting_source_as_peerandrouting_destination_as_peervariants, all with% Incomplete command. These options are for other platforms.Accepted on both Catalyst 9300 and Catalyst 9600, so these are the safe choice on both,
counter_bytes_long,counter_bytes_layer2_long,counter_packets_long,timestamp_absolute_first,timestamp_absolute_last,routing_source_as_4octet,routing_destination_as_4octet,routing_next_hop_ipv4,transport_tcp_flags,interface_inputandinterface_output.IOS XE (Catalyst 9300 and 9600) does not show values that are the default in the running configuration, for example
cache timeout inactive 15,cache timeout active 1800and the exporterexport-protocol netflow-v9,template data timeout 600,ttl 255anddscp 0. The module treats these as equal to an unset value, so specifying them does not cause a change on every run.IOS XE ignores changes to a flow record, without reporting an error, while a flow monitor that uses it exists. To change a record, delete the flow monitors using it first, or use a new record name.
Examples
# Using state: merged
# Before state:
# router# show running-config | section ^(flow|sampler)
# (empty)
- name: Configure Flexible NetFlow (Catalyst 9600 and routers, see the notes for Catalyst 9300)
cisco.ios.ios_flow_monitor_global:
config:
records:
- name: FLOW_RECORD_IPV4
match:
ipv4_tos: true
ipv4_protocol: true
ipv4_source_address: true
ipv4_destination_address: true
transport_source_port: true
transport_destination_port: true
flow_direction: true
interface_output: true
collect:
routing_source_as_4octet: true
routing_destination_as_4octet: true
routing_next_hop_ipv4: true
transport_tcp_flags: true
counter_bytes: true
counter_packets: true
timestamp_sys_uptime_first: true
timestamp_sys_uptime_last: true
interface_input: true
exporters:
- name: FLOW_EXPORTER_1
destination: 192.0.2.1
vrf: MGMT
source: Loopback0
transport:
protocol: udp
port: 2055
options:
sampler_table_timeout: 10
samplers:
- name: FLOW_SAMPLER
mode: random
window_size: 1000
monitors:
- name: FLOW_MONITOR_OUT
exporters:
- FLOW_EXPORTER_1
cache:
timeout_inactive: 10
timeout_active: 60
record: FLOW_RECORD_IPV4
state: merged
# Commands fired:
# flow record FLOW_RECORD_IPV4
# match ipv4 tos
# match ipv4 protocol
# match ipv4 source address
# match ipv4 destination address
# match transport source-port
# match transport destination-port
# match flow direction
# match interface output
# collect routing source as 4-octet
# collect routing destination as 4-octet
# collect routing next-hop address ipv4
# collect transport tcp flags
# collect counter bytes
# collect counter packets
# collect timestamp sys-uptime first
# collect timestamp sys-uptime last
# collect interface input
# flow exporter FLOW_EXPORTER_1
# destination 192.0.2.1 vrf MGMT
# source Loopback0
# transport udp 2055
# option sampler-table timeout 10
# sampler FLOW_SAMPLER
# mode random 1 out-of 1000
# flow monitor FLOW_MONITOR_OUT
# exporter FLOW_EXPORTER_1
# cache timeout inactive 10
# cache timeout active 60
# record FLOW_RECORD_IPV4
# Using state: merged — Catalyst 9300 flow record
#
# Catalyst 9300 rejects the counter_bytes, counter_packets and timestamp_sys_uptime options
# used in the first example, it needs the long counters and absolute timestamps.
- name: Configure a flow record on a Catalyst 9300
cisco.ios.ios_flow_monitor_global:
config:
records:
- name: FLOW_RECORD_IPV4
match:
ipv4_tos: true
ipv4_protocol: true
ipv4_source_address: true
ipv4_destination_address: true
transport_source_port: true
transport_destination_port: true
flow_direction: true
interface_output: true
collect:
routing_source_as_4octet: true
routing_destination_as_4octet: true
routing_next_hop_ipv4: true
transport_tcp_flags: true
counter_bytes_layer2_long: true
counter_packets_long: true
timestamp_absolute_first: true
timestamp_absolute_last: true
interface_input: true
state: merged
# Commands fired:
# flow record FLOW_RECORD_IPV4
# match ipv4 tos
# match ipv4 protocol
# match ipv4 source address
# match ipv4 destination address
# match transport source-port
# match transport destination-port
# match flow direction
# match interface output
# collect routing source as 4-octet
# collect routing destination as 4-octet
# collect routing next-hop address ipv4
# collect transport tcp flags
# collect counter bytes layer2 long
# collect counter packets long
# collect timestamp absolute first
# collect timestamp absolute last
# collect interface input
# Using state: merged — dual exporter (two collectors)
- name: Configure flow monitor with dual exporters
cisco.ios.ios_flow_monitor_global:
config:
exporters:
- name: FLOW_EXPORTER_1
destination: 192.0.2.1
vrf: MGMT
source: Loopback0
transport:
protocol: udp
port: 9996
options:
sampler_table_timeout: 2000
template_data_timeout: 10000
- name: FLOW_EXPORTER_2
destination: 192.0.2.2
vrf: MGMT
source: Loopback0
transport:
protocol: udp
port: 9996
options:
sampler_table_timeout: 2000
template_data_timeout: 10000
monitors:
- name: FLOW_MONITOR_IN
exporters:
- FLOW_EXPORTER_1
- FLOW_EXPORTER_2
record: FLOW_RECORD_IPV4
state: merged
# Using state: deleted
- name: Remove all flow monitor configuration
cisco.ios.ios_flow_monitor_global:
state: deleted
# Using state: gathered
- name: Gather existing flow monitor configuration
cisco.ios.ios_flow_monitor_global:
state: gathered
# Using state: rendered
- name: Render commands without connecting to device
cisco.ios.ios_flow_monitor_global:
config:
samplers:
- name: FLOW_SAMPLER
mode: random
window_size: 1000
state: rendered
# Using state: parsed
- name: Parse device config into structured data
cisco.ios.ios_flow_monitor_global:
running_config: |
flow record FLOW_RECORD_IPV4
match ipv4 source address
match ipv4 destination address
collect counter bytes
collect counter packets
sampler FLOW_SAMPLER
mode random 1 out-of 1000
flow monitor FLOW_MONITOR_OUT
record FLOW_RECORD_IPV4
state: parsed
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The resulting configuration module invocation. Returned: when changed Sample: |
|
The configuration prior to the module invocation. Returned: always Sample: |
|
The set of commands pushed to the remote device. Returned: always Sample: |
|
Facts about the network resource gathered from the remote device as structured data. Returned: when state is Sample: |
|
The device native config provided in running_config option, parsed into structured data. Returned: when state is Sample: |
|
The set of CLI commands generated from the value of state=rendered option. Returned: when state is Sample: |