Skip to main content

rules

Creates, updates, deletes, gets or lists a rules resource.

Overview

Namerules
TypeResource
Idcloudflare.magic_network_monitoring.rules

Fields

The following fields are returned by SELECT queries:

Get rule response

NameDatatypeDescription
idstringThe id of the rule. Must be unique. (example: 2890e6fa406311ed9b5a23f70f6fb8cf)
namestringThe name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. (example: my_rule_1)
automatic_advertisementbooleanToggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit.
bandwidth_thresholdnumberThe number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum.
durationstringThe amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. (1m, 5m, 10m, 15m, 20m, 30m, 45m, 60m) (default: 1m)
packet_thresholdnumberThe number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum.
prefix_matchstringPrefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. (exact, subnet, supernet) (example: exact)
prefixesarray
typestringMNM rule type. (threshold, zscore, advanced_ddos) (example: zscore)
zscore_sensitivitystringLevel of sensitivity set for zscore rules. (low, medium, high) (example: high)
zscore_targetstringTarget of the zscore rule analysis. (bits, packets) (example: bits)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectrule_id, account_idList a single network monitoring rule for account.
listselectaccount_idLists network monitoring rules for account.
createinsertaccount_id, name, prefixes, automatic_advertisement, typeCreate network monitoring rules for account. Currently only supports creating a single rule per API request.
editupdaterule_id, account_id, name, prefixes, automatic_advertisement, typeUpdate a network monitoring rule for account.
updatereplaceaccount_id, name, prefixes, automatic_advertisement, typeUpdate network monitoring rules for account.
deletedeleterule_id, account_idDelete a network monitoring rule for account.
update_advertisementexecrule_id, account_idUpdate advertisement for rule.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
rule_idstringThe rule ID.

SELECT examples

List a single network monitoring rule for account.

SELECT
id,
name,
automatic_advertisement,
bandwidth_threshold,
duration,
packet_threshold,
prefix_match,
prefixes,
type,
zscore_sensitivity,
zscore_target
FROM cloudflare.magic_network_monitoring.rules
WHERE rule_id = '{{ rule_id }}' -- required
AND account_id = '{{ account_id }}' -- required
;

INSERT examples

Create network monitoring rules for account. Currently only supports creating a single rule per API request.

INSERT INTO cloudflare.magic_network_monitoring.rules (
automatic_advertisement,
bandwidth_threshold,
duration,
name,
packet_threshold,
prefix_match,
prefixes,
type,
zscore_sensitivity,
zscore_target,
account_id
)
SELECT
{{ automatic_advertisement }} /* required */,
{{ bandwidth_threshold }},
'{{ duration }}',
'{{ name }}' /* required */,
{{ packet_threshold }},
'{{ prefix_match }}',
'{{ prefixes }}' /* required */,
'{{ type }}' /* required */,
'{{ zscore_sensitivity }}',
'{{ zscore_target }}',
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;

UPDATE examples

Update a network monitoring rule for account.

UPDATE cloudflare.magic_network_monitoring.rules
SET
automatic_advertisement = {{ automatic_advertisement }},
bandwidth_threshold = {{ bandwidth_threshold }},
duration = '{{ duration }}',
name = '{{ name }}',
packet_threshold = {{ packet_threshold }},
prefix_match = '{{ prefix_match }}',
prefixes = '{{ prefixes }}',
type = '{{ type }}',
zscore_sensitivity = '{{ zscore_sensitivity }}',
zscore_target = '{{ zscore_target }}'
WHERE
rule_id = '{{ rule_id }}' --required
AND account_id = '{{ account_id }}' --required
AND name = '{{ name }}' --required
AND prefixes = '{{ prefixes }}' --required
AND automatic_advertisement = {{ automatic_advertisement }} --required
AND type = '{{ type }}' --required
RETURNING
errors,
messages,
result,
success;

REPLACE examples

Update network monitoring rules for account.

REPLACE cloudflare.magic_network_monitoring.rules
SET
automatic_advertisement = {{ automatic_advertisement }},
bandwidth_threshold = {{ bandwidth_threshold }},
duration = '{{ duration }}',
name = '{{ name }}',
packet_threshold = {{ packet_threshold }},
prefix_match = '{{ prefix_match }}',
prefixes = '{{ prefixes }}',
type = '{{ type }}',
zscore_sensitivity = '{{ zscore_sensitivity }}',
zscore_target = '{{ zscore_target }}'
WHERE
account_id = '{{ account_id }}' --required
AND name = '{{ name }}' --required
AND prefixes = '{{ prefixes }}' --required
AND automatic_advertisement = {{ automatic_advertisement }} --required
AND type = '{{ type }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Delete a network monitoring rule for account.

DELETE FROM cloudflare.magic_network_monitoring.rules
WHERE rule_id = '{{ rule_id }}' --required
AND account_id = '{{ account_id }}' --required
;

Lifecycle Methods

Update advertisement for rule.

EXEC cloudflare.magic_network_monitoring.rules.update_advertisement
@rule_id='{{ rule_id }}' --required,
@account_id='{{ account_id }}' --required
;