Skip to main content

monitoring_rules

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

Overview

Namemonitoring_rules
TypeResource
Iddatadog.security.monitoring_rules

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe ID of the rule.
namestringThe name of the rule.
creation_author_idinteger (int64)User ID of the user who created the rule. (wire: creationAuthorId)
update_author_idinteger (int64)User ID of the user who updated the rule. (wire: updateAuthorId)
custom_namestringCustom/Overridden name of the rule (used in case of Default rule update). (wire: customName)
calculated_fieldsarrayCalculated fields. Only allowed for scheduled rules - in other words, when schedulingOptions is also defined. (wire: calculatedFields)
casesarrayCases for generating signals.
compliance_signal_optionsobjectHow to generate compliance signals. Useful for cloud_configuration rules only. (wire: complianceSignalOptions)
created_atinteger (int64)When the rule was created, timestamp in milliseconds. (wire: createdAt)
custom_messagestringCustom/Overridden message for generated signals (used in case of Default rule update). (wire: customMessage)
default_tagsarrayDefault Tags for default rules (included in tags) (wire: defaultTags)
deprecation_dateinteger (int64)When the rule will be deprecated, timestamp in milliseconds. (wire: deprecationDate)
filtersarrayAdditional queries to filter matched events before they are processed. This field is deprecated for log detection, signal correlation, and workload security rules.
group_signals_byarrayAdditional grouping to perform on top of the existing groups in the query section. Must be a subset of the existing groups. (wire: groupSignalsBy)
has_extended_titlebooleanWhether the notifications include the triggering group-by values in their title. (wire: hasExtendedTitle)
is_defaultbooleanWhether the rule is included by default. (wire: isDefault)
is_deletedbooleanWhether the rule has been deleted. (wire: isDeleted)
is_enabledbooleanWhether the rule is enabled. (wire: isEnabled)
messagestringMessage for generated signals.
optionsobjectOptions.
queriesarrayQueries for selecting logs which are part of the rule.
reference_tablesarrayReference tables for the rule. (wire: referenceTables)
scheduling_optionsobjectOptions for scheduled rules. When this field is present, the rule runs based on the schedule. When absent, it runs real-time on ingested logs. (wire: schedulingOptions)
tagsarrayTags for generated signals.
third_party_casesarrayCases for generating signals from third-party rules. Only available for third-party rules. (wire: thirdPartyCases)
typestringThe rule type. (log_detection, infrastructure_configuration, workload_security, cloud_configuration, application_security, api_security, workload_activity)
updated_atinteger (int64)The date the rule was last updated, in milliseconds. (wire: updatedAt)
versioninteger (int64)The version of the rule.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_security_monitoring_ruleselectrule_idGet a rule's details.
list_security_monitoring_rulesselectpage[size], page[number], query, sortList rules.
create_security_monitoring_ruleinsertname, is_enabled, queries, options, cases, message, compliance_signal_optionsCreate a detection rule.
update_security_monitoring_rulereplacerule_idUpdate an existing rule. When updating cases, queries or options, the whole field<br />must be included. For example, when modifying a query all queries must be included.<br />Default rules can only be updated to be enabled, to change notifications, or to update<br />the tags (default tags cannot be removed).
delete_security_monitoring_ruledeleterule_idDelete an existing rule. Default rules cannot be deleted.
bulk_delete_security_monitoring_rulesdeleteDelete multiple security monitoring rules in a single request. Default rules cannot be deleted.
convert_security_monitoring_rule_from_jsonto_terraformexecname, isEnabled, queries, options, cases, messageConvert a rule that doesn't (yet) exist from JSON to Terraform for Datadog provider<br />resource datadog_security_monitoring_rule. You can do so for the following rule types:<br />- App and API Protection<br />- Cloud SIEM (log detection and signal correlation)<br />- Workload Protection<br /><br />You can convert Cloud Security configuration rules using Terraform's [Datadog Cloud Configuration Rule resource](https:​//registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/cloud_configuration_rule).
test_security_monitoring_ruleexecTest a rule.
validate_security_monitoring_ruleexecname, isEnabled, queries, options, cases, message, complianceSignalOptionsValidate a detection rule.
convert_existing_security_monitoring_ruleexecrule_idConvert an existing rule from JSON to Terraform for Datadog provider<br />resource datadog_security_monitoring_rule. You can do so for the following rule types:<br />- App and API Protection<br />- Cloud SIEM (log detection and signal correlation)<br />- Workload Protection<br /><br />You can convert Cloud Security configuration rules using Terraform's [Datadog Cloud Configuration Rule resource](https:​//registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/cloud_configuration_rule).
restore_security_monitoring_ruleexecrule_id, versionRestores a custom detection rule to a previously saved historical version.<br />Only custom rules can be restored. Default and partner rules return 400.<br />The restore creates a new version entry; it does not overwrite history.
test_existing_security_monitoring_ruleexecrule_idTest an existing 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
rule_idstringThe ID of the rule.
sitestringThe Datadog site (region) for your organization, for example datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, ap2.datadoghq.com, datadoghq.eu, ddog-gov.com. Resolved from the DD_SITE environment variable when set. Optional: defaults to datadoghq.com, or the value of the DD_SITE environment variable when set; a WHERE value overrides both.
versioninteger (int64)The historical version number of the rule.
page[number]integer (int64)Specific page number to return.
page[size]integer (int64)Number of items to return per page. The maximum allowed value is 100.
querystringA search query to filter security rules. You can filter by attributes such as type, source, tags. (example: type:signal_correlation source:cloudtrail)
sortstringAttribute used to sort rules. Prefix with - to sort in descending order.

SELECT examples

Get a rule's details.

SELECT
id,
name,
creation_author_id,
update_author_id,
custom_name,
calculated_fields,
cases,
compliance_signal_options,
created_at,
custom_message,
default_tags,
deprecation_date,
filters,
group_signals_by,
has_extended_title,
is_default,
is_deleted,
is_enabled,
message,
options,
queries,
reference_tables,
scheduling_options,
tags,
third_party_cases,
type,
updated_at,
version
FROM datadog.security.monitoring_rules
WHERE rule_id = '{{ rule_id }}' -- required
;

INSERT examples

Create a detection rule.

INSERT INTO datadog.security.monitoring_rules (
calculated_fields,
cases,
filters,
group_signals_by,
has_extended_title,
is_enabled,
message,
name,
options,
queries,
reference_tables,
scheduling_options,
tags,
third_party_cases,
type,
compliance_signal_options
)
SELECT
'{{ calculated_fields }}',
'{{ cases }}' /* required */,
'{{ filters }}',
'{{ group_signals_by }}',
{{ has_extended_title }},
{{ is_enabled }} /* required */,
'{{ message }}' /* required */,
'{{ name }}' /* required */,
'{{ options }}' /* required */,
'{{ queries }}' /* required */,
'{{ reference_tables }}',
'{{ scheduling_options }}',
'{{ tags }}',
'{{ third_party_cases }}',
'{{ type }}',
'{{ compliance_signal_options }}' /* required */
RETURNING
id,
name,
creation_author_id,
update_author_id,
custom_name,
calculated_fields,
cases,
compliance_signal_options,
created_at,
custom_message,
default_tags,
deprecation_date,
filters,
group_signals_by,
has_extended_title,
is_default,
is_deleted,
is_enabled,
message,
options,
queries,
reference_tables,
scheduling_options,
tags,
third_party_cases,
type,
updated_at,
version
;

REPLACE examples

Update an existing rule. When updating cases, queries or options, the whole field<br />must be included. For example, when modifying a query all queries must be included.<br />Default rules can only be updated to be enabled, to change notifications, or to update<br />the tags (default tags cannot be removed).

REPLACE datadog.security.monitoring_rules
SET
calculated_fields = '{{ calculated_fields }}',
cases = '{{ cases }}',
compliance_signal_options = '{{ compliance_signal_options }}',
custom_message = '{{ custom_message }}',
custom_name = '{{ custom_name }}',
filters = '{{ filters }}',
group_signals_by = '{{ group_signals_by }}',
has_extended_title = {{ has_extended_title }},
is_enabled = {{ is_enabled }},
message = '{{ message }}',
name = '{{ name }}',
options = '{{ options }}',
queries = '{{ queries }}',
reference_tables = '{{ reference_tables }}',
scheduling_options = '{{ scheduling_options }}',
tags = '{{ tags }}',
third_party_cases = '{{ third_party_cases }}',
version = {{ version }}
WHERE
rule_id = '{{ rule_id }}' --required
RETURNING
id,
name,
creation_author_id,
update_author_id,
custom_name,
calculated_fields,
cases,
compliance_signal_options,
created_at,
custom_message,
default_tags,
deprecation_date,
filters,
group_signals_by,
has_extended_title,
is_default,
is_deleted,
is_enabled,
message,
options,
queries,
reference_tables,
scheduling_options,
tags,
third_party_cases,
type,
updated_at,
version;

DELETE examples

Delete an existing rule. Default rules cannot be deleted.

DELETE FROM datadog.security.monitoring_rules
WHERE rule_id = '{{ rule_id }}' --required
;

Lifecycle Methods

EXEC variables use wire (API) names.

Convert a rule that doesn't (yet) exist from JSON to Terraform for Datadog provider<br />resource datadog_security_monitoring_rule. You can do so for the following rule types:<br />- App and API Protection<br />- Cloud SIEM (log detection and signal correlation)<br />- Workload Protection<br /><br />You can convert Cloud Security configuration rules using Terraform's [Datadog Cloud Configuration Rule resource](https:​//registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/cloud_configuration_rule).

EXEC datadog.security.monitoring_rules.convert_security_monitoring_rule_from_jsonto_terraform
@@json=
'{
"calculatedFields": "{{ calculatedFields }}",
"cases": "{{ cases }}",
"customMessage": "{{ customMessage }}",
"customName": "{{ customName }}",
"filters": "{{ filters }}",
"groupSignalsBy": "{{ groupSignalsBy }}",
"hasExtendedTitle": {{ hasExtendedTitle }},
"isEnabled": {{ isEnabled }},
"message": "{{ message }}",
"name": "{{ name }}",
"options": "{{ options }}",
"queries": "{{ queries }}",
"referenceTables": "{{ referenceTables }}",
"schedulingOptions": "{{ schedulingOptions }}",
"tags": "{{ tags }}",
"thirdPartyCases": "{{ thirdPartyCases }}",
"type": "{{ type }}"
}'
;