On routing platforms containing a Monitoring Services Physical Interface Card (PIC) or an Adaptive Services PIC, you can configure traffic sampling for traffic passing through the routing platform.
To configure traffic sampling on a logical interface, include the input statement at the [edit forwarding-options sampling] hierarchy level:
- [edit forwarding-options sampling]
-
input {
-
-
family (inet | mpls) {
- max-packets-per-second number;
- rate number;
- run-length number;
- }
- }
Beginning with JUNOS Release 8.3, you can also configure traffic sampling of MPLS traffic.
Specify the threshold traffic value by using the max-packets-per-second statement. The value is the maximum number of packets to be sampled, beyond which the sampling mechanism begins dropping packets. The range is 0 through 65,535. A value of 0 instructs the Packet Forwarding Engine not to sample any packets. The default value is 1000.
![]() |
Note: This statement is not valid for port mirroring. |
Specify the sampling rate by setting the values for rate and run-length (see Figure 13).
Figure 13: Configure Sampling Rate

The rate statement specifies the ratio of packets to be sampled. For example, if you configure a rate of 10, x number of packets out of every 10 is sampled, where x=run-length+1. By default, the rate is 0, which means that no traffic is sampled.
The run-length statement specifies the number of matching packets to sample following the initial one-packet trigger event. Configuring a run length greater than 0 allows you to sample packets following those already being sampled.
If you do not include the input statement, sampling is disabled.
To collect the sampled packets in a file, include the file statement at the [edit forwarding-options sampling output] hierarchy level. For more information about the output file formats, see Configuring Traffic Sampling Output.
You can also send the sampled packets to a specified host using the cflowd version 5 and 8 formats or the version 9 format as defined in RFC 3954. For more information, see Configuring Flow Aggregation (cflowd) and Configuring Active Flow Monitoring Using Version 9.
The JUNOS software does not sample packets originating from the router. If you configure a sampling filter and apply it to the output side of an interface, then only the transit packets going through that interface are sampled. Packets that are sent from the Routing Engine to the Packet Forwarding Engine are not sampled.
When you apply a firewall filter to a loopback interface, the filter might block responses from the Monitoring Services PIC. To allow responses from the Monitoring Services PIC to pass through for sampling purposes, configure a term in the firewall filter to include the Monitoring Services PIC’s IP address. For more detailed information about configuring firewall filters, see Firewall Filter Configuration.