Skip to content
Cloudflare Docs

Rules

Magic Network Monitoring rules allow you to monitor your network traffic for DDoS attacks on specific IP addresses or IP prefixes within your network. If the network traffic that is monitored by a rule exceeds the rule's threshold or contains a DDoS attack fingerprint, then you will receive an alert.

Rule types

There are three different types of rules that can be configured within Magic Network Monitoring. You can refer to the linked documentation page for each rule type to learn more.

Rule TypeRule DescriptionRule Availability
Dynamic threshold (recommended)A dynamic threshold rule will analyze a network's traffic patterns over time and automatically adjust the rule's DDoS threshold, in terms of bits or packets, based on traffic history.API configuration only
Static thresholdA static threshold rule allows you to define a constant numeric threshold, in terms of bits or packets, for DDoS traffic monitoring.API configuration and dashboard configuration
sFlow DDoS attackMagic Network Monitoring customers that send sFlow data to Cloudflare can receive alerts when a specific type of distributed denial-of-service (DDoS) attack is detected within their network traffic.API configuration only. Only applicable to sFlow data sets

Create rules in the dashboard

You can only configure static traffic threshold rules in the Cloudflare dashboard.

To create a new rule:

  1. Log in to the Cloudflare dashboard, and select your account.
  2. Go to Analytics & Logs > Magic Monitoring.
  3. Select Configure Magic Network Monitoring > Add new rule.
  4. Create a new static traffic threshold rule according to your needs. Refer to the documentation on static threshold rules for more information on each field in the static threshold rule's configuration.
  5. Select Create a new rule when you are finished.

Edit rules in the dashboard

  1. Log in to the Cloudflare dashboard, and select your account.
  2. Go to Analytics & Logs > Magic Monitoring.
  3. Select Configure Magic Network Monitoring.
  4. Find the static threshold rule you want to edit, and select Edit.
  5. Edit the appropriate fields. Refer to Rule configuration fields for more information on what each field does.
  6. Select Save when you are finished.

Delete rules in the dashboard

  1. Log in to the Cloudflare dashboard, and select your account.
  2. Go to Analytics & Logs > Magic Monitoring.
  3. Select Configure Magic Network Monitoring.
  4. Find the static threshold rule you want to delete, and select Delete.
  5. Select I understand that deleting a rule is permanent, and select Delete again.

Common settings that apply to all rule types

Rule Auto-Advertisement

If you are an Enterprise customer using Magic Transit On Demand, you can enable Auto-Advertisement for any dynamic threshold, static threshold, and sFlow DDoS attack rule. The Auto-Advertisement feature will automatically activate Magic Transit when a static or dynamic rule threshold is exceeded or a DDoS attack fingerprint is identified in sFlow traffic logs.

Follow the previous steps to create or edit a rule. Then, enable Auto-Advertisement.

Rule IP prefixes

Each rule must include a group of IP prefixes in its definition. All IP prefixes inside a rule are evaluated as a whole, and you should set up a rule with multiple IP prefixes when you want the IP prefixes' aggregated traffic to trigger an alert or advertisement. For thresholds on singular IP prefixes or IP addresses, you can create an individual rule with one prefix and the desired rule parameters.

Rule IP prefixes example

For a rule with two prefix CIDRs and a packet_threshold of 10000 as shown below, the rule will be flagged if the joint packet traffic of 192.168.0.0/24 and 172.118.0.0/24 is greater than 10000. This also means that Cloudflare attempts to auto advertise both CIDRs if the rule has the auto advertisement flag enabled. Customers can also configure Rule IP prefixes at scale via Cloudflare's API.

"rules":[
"name": "Too many packets",
"prefixes": ["192.168.0.0/24", "172.118.0.0/24"],
"packet_threshold": 10000,
"automatic_advertisement": true,
"duration": "1m0s",
"type": "threshold"
]

For more granular thresholds, create a more focused rule as shown below.

"rules":[
"name": "Too many packets",
"prefixes": ["172.118.0.0/24"],
"packet_threshold": 1000,
"automatic_advertisement": true,
"duration": "1m0s",
"type": "threshold"
]