rules
Creates, updates, deletes, gets or lists a rules resource.
Overview
| Name | rules |
| Type | Resource |
| Id | cloudflare.magic_network_monitoring.rules |
Fields
The following fields are returned by SELECT queries:
- get
- list
Get rule response
| Name | Datatype | Description |
|---|---|---|
id | string | The id of the rule. Must be unique. (example: 2890e6fa406311ed9b5a23f70f6fb8cf) |
name | string | The 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_advertisement | boolean | Toggle 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_threshold | number | The 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. |
duration | string | The 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_threshold | number | The 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_match | string | Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. (exact, subnet, supernet) (example: exact) |
prefixes | array | |
type | string | MNM rule type. (threshold, zscore, advanced_ddos) (example: zscore) |
zscore_sensitivity | string | Level of sensitivity set for zscore rules. (low, medium, high) (example: high) |
zscore_target | string | Target of the zscore rule analysis. (bits, packets) (example: bits) |
List rules response
| Name | Datatype | Description |
|---|---|---|
id | string | The id of the rule. Must be unique. (example: 2890e6fa406311ed9b5a23f70f6fb8cf) |
name | string | The 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_advertisement | boolean | Toggle 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_threshold | number | The 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. |
duration | string | The 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_threshold | number | The 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_match | string | Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. (exact, subnet, supernet) (example: exact) |
prefixes | array | |
type | string | MNM rule type. (threshold, zscore, advanced_ddos) (example: zscore) |
zscore_sensitivity | string | Level of sensitivity set for zscore rules. (low, medium, high) (example: high) |
zscore_target | string | Target of the zscore rule analysis. (bits, packets) (example: bits) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | rule_id, account_id | List a single network monitoring rule for account. | |
list | select | account_id | Lists network monitoring rules for account. | |
create | insert | account_id, name, prefixes, automatic_advertisement, type | Create network monitoring rules for account. Currently only supports creating a single rule per API request. | |
edit | update | rule_id, account_id, name, prefixes, automatic_advertisement, type | Update a network monitoring rule for account. | |
update | replace | account_id, name, prefixes, automatic_advertisement, type | Update network monitoring rules for account. | |
delete | delete | rule_id, account_id | Delete a network monitoring rule for account. | |
update_advertisement | exec | rule_id, account_id | Update 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.
| Name | Datatype | Description |
|---|---|---|
account_id | string | The Cloudflare account ID. |
rule_id | string | The rule ID. |
SELECT examples
- get
- list
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
;
Lists network monitoring rules 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 account_id = '{{ account_id }}' -- required
;
INSERT examples
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: rules
props:
- name: account_id
value: "{{ account_id }}"
description: Required parameter for the rules resource.
- name: automatic_advertisement
value: {{ automatic_advertisement }}
description: |
Toggle 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.
- name: bandwidth_threshold
value: {{ bandwidth_threshold }}
description: |
The 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.
- name: duration
value: "{{ duration }}"
description: |
The 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"].
valid_values: ['1m', '5m', '10m', '15m', '20m', '30m', '45m', '60m']
default: 1m
- name: name
value: "{{ name }}"
description: |
The 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.
- name: packet_threshold
value: {{ packet_threshold }}
description: |
The 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.
- name: prefix_match
value: "{{ prefix_match }}"
description: |
Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule.
valid_values: ['exact', 'subnet', 'supernet']
- name: prefixes
value:
- "{{ prefixes }}"
- name: type
value: "{{ type }}"
description: |
MNM rule type.
valid_values: ['threshold', 'zscore', 'advanced_ddos']
- name: zscore_sensitivity
value: "{{ zscore_sensitivity }}"
description: |
Level of sensitivity set for zscore rules.
valid_values: ['low', 'medium', 'high']
- name: zscore_target
value: "{{ zscore_target }}"
description: |
Target of the zscore rule analysis.
valid_values: ['bits', 'packets']
UPDATE examples
- edit
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
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
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
Update advertisement for rule.
EXEC cloudflare.magic_network_monitoring.rules.update_advertisement
@rule_id='{{ rule_id }}' --required,
@account_id='{{ account_id }}' --required
;