Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9034,6 +9034,14 @@ components:
type: array
model_type_override:
$ref: "#/components/schemas/MonitorFormulaAndFunctionDataQualityModelTypeOverride"
sensitivity:
description: |-
Sensitivity of the anomaly detection model, expressed as a multiplier on the width
of the predicted bounds. Higher values widen the bounds and produce fewer alerts;
lower values tighten them and produce more alerts. Defaults to `3.0`.
example: 3.0
format: double
type: number
type: object
MonitorFormulaAndFunctionDataQualityQueryDefinition:
description: A formula and functions data quality query.
Expand Down
57 changes: 57 additions & 0 deletions examples/v1/monitors/CreateMonitor_1532893480.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
Create a Data Quality monitor with sensitivity returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_data_source import (
MonitorFormulaAndFunctionDataQualityDataSource,
)
from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_monitor_options import (
MonitorFormulaAndFunctionDataQualityMonitorOptions,
)
from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_query_definition import (
MonitorFormulaAndFunctionDataQualityQueryDefinition,
)
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_type import MonitorType

body = Monitor(
name="Example-Monitor",
type=MonitorType.DATA_QUALITY_ALERT,
query='formula("query1").last("5m") > 100',
message="Data quality alert triggered",
tags=[
"test:examplemonitor",
"env:ci",
],
priority=3,
options=MonitorOptions(
thresholds=MonitorThresholds(
critical=100.0,
),
variables=[
MonitorFormulaAndFunctionDataQualityQueryDefinition(
name="query1",
data_source=MonitorFormulaAndFunctionDataQualityDataSource.DATA_QUALITY_METRICS,
measure="row_count",
filter="search for column where `database:production AND table:users`",
group_by=[
"entity_id",
],
monitor_options=MonitorFormulaAndFunctionDataQualityMonitorOptions(
sensitivity=2.5,
),
),
],
),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor(body=body)

print(response)
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def openapi_types(_):
"custom_where": (str,),
"group_by_columns": ([str],),
"model_type_override": (MonitorFormulaAndFunctionDataQualityModelTypeOverride,),
"sensitivity": (float,),
}

attribute_map = {
Expand All @@ -40,6 +41,7 @@ def openapi_types(_):
"custom_where": "custom_where",
"group_by_columns": "group_by_columns",
"model_type_override": "model_type_override",
"sensitivity": "sensitivity",
}

def __init__(
Expand All @@ -49,6 +51,7 @@ def __init__(
custom_where: Union[str, UnsetType] = unset,
group_by_columns: Union[List[str], UnsetType] = unset,
model_type_override: Union[MonitorFormulaAndFunctionDataQualityModelTypeOverride, UnsetType] = unset,
sensitivity: Union[float, UnsetType] = unset,
**kwargs,
):
"""
Expand All @@ -68,6 +71,11 @@ def __init__(

:param model_type_override: Override for the model type used in anomaly detection.
:type model_type_override: MonitorFormulaAndFunctionDataQualityModelTypeOverride, optional

:param sensitivity: Sensitivity of the anomaly detection model, expressed as a multiplier on the width
of the predicted bounds. Higher values widen the bounds and produce fewer alerts;
lower values tighten them and produce more alerts. Defaults to ``3.0``.
:type sensitivity: float, optional
"""
if crontab_override is not unset:
kwargs["crontab_override"] = crontab_override
Expand All @@ -79,4 +87,6 @@ def __init__(
kwargs["group_by_columns"] = group_by_columns
if model_type_override is not unset:
kwargs["model_type_override"] = model_type_override
if sensitivity is not unset:
kwargs["sensitivity"] = sensitivity
super().__init__(kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-07-31T16:36:50.561Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
interactions:
- request:
body: '{"message":"Data quality alert triggered","name":"Test-Create_a_Data_Quality_monitor_with_sensitivity_returns_OK_response-1785515810","options":{"thresholds":{"critical":100},"variables":[{"data_source":"data_quality_metrics","filter":"search
for column where `database:production AND table:users`","group_by":["entity_id"],"measure":"row_count","monitor_options":{"sensitivity":2.5},"name":"query1"}]},"priority":3,"query":"formula(\"query1\").last(\"5m\")
> 100","tags":["test:testcreateadataqualitymonitorwithsensitivityreturnsokresponse1785515810","env:ci"],"type":"data-quality
alert"}'
headers:
accept:
- application/json
content-type:
- application/json
method: POST
uri: https://api.datadoghq.com/api/v1/monitor
response:
body:
string: '{"id":310055951,"org_id":321813,"type":"data-quality alert","name":"Test-Create_a_Data_Quality_monitor_with_sensitivity_returns_OK_response-1785515810","message":"Data
quality alert triggered","tags":["test:testcreateadataqualitymonitorwithsensitivityreturnsokresponse1785515810","env:ci"],"query":"formula(\"query1\").last(\"5m\")
> 100","options":{"thresholds":{"critical":100.0},"variables":[{"data_source":"data_quality_metrics","filter":"search
for column where `database:production AND table:users`","group_by":["entity_id"],"measure":"row_count","monitor_options":{"sensitivity":2.5},"name":"query1"}],"notify_no_data":false,"notify_audit":false,"new_host_delay":300,"include_tags":true,"silenced":{}},"multi":false,"created_at":1785515810000,"created":"2026-07-31T16:36:50.914551+00:00","modified":"2026-07-31T16:36:50.914551+00:00","deleted":null,"priority":3,"restricted_roles":null,"restriction_policy":null,"draft_status":"published","assets":[],"overall_state_modified":null,"overall_state":"No
Data","creator":{"name":"CI Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"team-intg-tools-libs-spam@datadoghq.com","id":2320499}}

'
headers:
content-type:
- application/json
status:
code: 200
message: OK
- request:
body: null
headers:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/monitor/310055951
response:
body:
string: '{"deleted_monitor_id":310055951}

'
headers:
content-type:
- application/json
status:
code: 200
message: OK
version: 1
10 changes: 10 additions & 0 deletions tests/v1/features/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ Feature: Monitors
And the response "name" is equal to "{{ unique }}"
And the response "type" is equal to "data-quality alert"

@team:DataDog/monitor-app
Scenario: Create a Data Quality monitor with sensitivity returns "OK" response
Given new "CreateMonitor" request
And body with value {"name": "{{ unique }}", "type": "data-quality alert", "query": "formula(\"query1\").last(\"5m\") > 100", "message": "Data quality alert triggered", "tags": ["test:{{ unique_lower_alnum }}", "env:ci"], "priority": 3, "options": {"thresholds": {"critical": 100}, "variables": [{"name": "query1", "data_source": "data_quality_metrics", "measure": "row_count", "filter": "search for column where `database:production AND table:users`", "group_by": ["entity_id"], "monitor_options": {"sensitivity": 2.5}}]}}
When the request is sent
Then the response status is 200 OK
And the response "name" is equal to "{{ unique }}"
And the response "type" is equal to "data-quality alert"
And the response "options.variables[0].monitor_options.sensitivity" is equal to 2.5

@team:DataDog/monitor-app
Scenario: Create a RUM formula and functions monitor returns "OK" response
Given new "CreateMonitor" request
Expand Down
Loading