Skip to content

Commit 73528b1

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
feat - Add data-quality alert monitor type support (#3266)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent bce1eaf commit 73528b1

13 files changed

Lines changed: 528 additions & 0 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7534,6 +7534,104 @@ components:
75347534
- data_source
75357535
- query
75367536
type: object
7537+
MonitorFormulaAndFunctionDataQualityDataSource:
7538+
description: Data source for data quality queries.
7539+
enum:
7540+
- data_quality_metrics
7541+
example: data_quality_metrics
7542+
type: string
7543+
x-enum-varnames:
7544+
- DATA_QUALITY_METRICS
7545+
MonitorFormulaAndFunctionDataQualityMeasure:
7546+
description: 'The data quality measure to query. Common values include:
7547+
7548+
`bytes`, `cardinality`, `custom`, `freshness`, `max`, `mean`, `min`,
7549+
7550+
`nullness`, `percent_negative`, `percent_zero`, `row_count`, `stddev`,
7551+
7552+
`sum`, `uniqueness`. Additional values may be supported.'
7553+
example: row_count
7554+
type: string
7555+
MonitorFormulaAndFunctionDataQualityModelTypeOverride:
7556+
description: Override for the model type used in anomaly detection.
7557+
enum:
7558+
- freshness
7559+
- percentage
7560+
- any
7561+
type: string
7562+
x-enum-varnames:
7563+
- FRESHNESS
7564+
- PERCENTAGE
7565+
- ANY
7566+
MonitorFormulaAndFunctionDataQualityMonitorOptions:
7567+
description: Monitor configuration options for data quality queries.
7568+
properties:
7569+
crontab_override:
7570+
description: Crontab expression to override the default schedule.
7571+
example: '* * * 10'
7572+
type: string
7573+
custom_sql:
7574+
description: Custom SQL query for the monitor.
7575+
example: SELECT COUNT(*) FROM users AS dd_value
7576+
type: string
7577+
custom_where:
7578+
description: Custom WHERE clause for the query.
7579+
example: USER_ID = 123
7580+
type: string
7581+
group_by_columns:
7582+
description: Columns to group results by.
7583+
example:
7584+
- col1
7585+
- col2
7586+
items:
7587+
type: string
7588+
type: array
7589+
model_type_override:
7590+
$ref: '#/components/schemas/MonitorFormulaAndFunctionDataQualityModelTypeOverride'
7591+
type: object
7592+
MonitorFormulaAndFunctionDataQualityQueryDefinition:
7593+
description: A formula and functions data quality query.
7594+
properties:
7595+
data_source:
7596+
$ref: '#/components/schemas/MonitorFormulaAndFunctionDataQualityDataSource'
7597+
filter:
7598+
description: Filter expression used to match on data entities. Uses Aastra
7599+
query syntax.
7600+
example: search for column where `database:production AND table:users`
7601+
type: string
7602+
group_by:
7603+
description: Optional grouping fields for aggregation.
7604+
example:
7605+
- entity_id
7606+
items:
7607+
type: string
7608+
type: array
7609+
measure:
7610+
$ref: '#/components/schemas/MonitorFormulaAndFunctionDataQualityMeasure'
7611+
monitor_options:
7612+
$ref: '#/components/schemas/MonitorFormulaAndFunctionDataQualityMonitorOptions'
7613+
name:
7614+
description: Name of the query for use in formulas.
7615+
example: query1
7616+
type: string
7617+
schema_version:
7618+
description: Schema version for the data quality query.
7619+
example: 0.0.1
7620+
type: string
7621+
scope:
7622+
description: 'Optional scoping expression to further filter metrics. Uses
7623+
metrics filter syntax.
7624+
7625+
This is useful when an entity has been configured to emit metrics with
7626+
additional tags.'
7627+
example: env:production
7628+
type: string
7629+
required:
7630+
- name
7631+
- data_source
7632+
- measure
7633+
- filter
7634+
type: object
75377635
MonitorFormulaAndFunctionEventAggregation:
75387636
description: Aggregation methods for event platform queries.
75397637
enum:
@@ -7685,6 +7783,7 @@ components:
76857783
oneOf:
76867784
- $ref: '#/components/schemas/MonitorFormulaAndFunctionEventQueryDefinition'
76877785
- $ref: '#/components/schemas/MonitorFormulaAndFunctionCostQueryDefinition'
7786+
- $ref: '#/components/schemas/MonitorFormulaAndFunctionDataQualityQueryDefinition'
76887787
MonitorGroupSearchResponse:
76897788
description: The response of a monitor group search.
76907789
example:
@@ -8523,6 +8622,7 @@ components:
85238622
- database-monitoring alert
85248623
- network-performance alert
85258624
- cost alert
8625+
- data-quality alert
85268626
example: query alert
85278627
type: string
85288628
x-enum-varnames:
@@ -8545,6 +8645,7 @@ components:
85458645
- DATABASE_MONITORING_ALERT
85468646
- NETWORK_PERFORMANCE_ALERT
85478647
- COST_ALERT
8648+
- DATA_QUALITY_ALERT
85488649
MonitorUpdateRequest:
85498650
description: Object describing a monitor update request.
85508651
properties:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2026-01-12T17:23:49.629Z"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Monitors/Create a Data Quality monitor returns \"OK\" response",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "09dbbe87ffa480b059d2f4f4bb6a2d62",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 520,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 555,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"message\":\"Data quality alert triggered\",\"name\":\"Test-Create_a_Data_Quality_monitor_returns_OK_response-1768238629\",\"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\",\"name\":\"query1\"}]},\"priority\":3,\"query\":\"formula(\\\"query1\\\").last(\\\"5m\\\") > 100\",\"tags\":[\"test:testcreateadataqualitymonitorreturnsokresponse1768238629\",\"env:ci\"],\"type\":\"data-quality alert\"}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/monitor"
39+
},
40+
"response": {
41+
"bodySize": 1088,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 1088,
45+
"text": "{\"id\":250323411,\"org_id\":321813,\"type\":\"data-quality alert\",\"name\":\"Test-Create_a_Data_Quality_monitor_returns_OK_response-1768238629\",\"message\":\"Data quality alert triggered\",\"tags\":[\"test:testcreateadataqualitymonitorreturnsokresponse1768238629\",\"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\",\"name\":\"query1\"}],\"notify_no_data\":false,\"notify_audit\":false,\"new_host_delay\":300,\"include_tags\":true,\"silenced\":{}},\"multi\":false,\"created_at\":1768238629000,\"created\":\"2026-01-12T17:23:49.782143+00:00\",\"modified\":\"2026-01-12T17:23:49.782143+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}}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 680,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2026-01-12T17:23:49.637Z",
61+
"time": 205
62+
},
63+
{
64+
"_id": "8aa5bcb8a1681f4e66bc94bc158d0c77",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 513,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/monitor/250323411"
82+
},
83+
"response": {
84+
"bodySize": 33,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 33,
88+
"text": "{\"deleted_monitor_id\":250323411}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 547,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2026-01-12T17:23:49.850Z",
104+
"time": 279
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Create a Data Quality monitor returns "OK" response
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.MonitorsApi(configuration);
9+
10+
const params: v1.MonitorsApiCreateMonitorRequest = {
11+
body: {
12+
name: "Example-Monitor",
13+
type: "data-quality alert",
14+
query: `formula("query1").last("5m") > 100`,
15+
message: "Data quality alert triggered",
16+
tags: ["test:examplemonitor", "env:ci"],
17+
priority: 3,
18+
options: {
19+
thresholds: {
20+
critical: 100,
21+
},
22+
variables: [
23+
{
24+
name: "query1",
25+
dataSource: "data_quality_metrics",
26+
measure: "row_count",
27+
filter:
28+
`search for column where ` +
29+
"`" +
30+
`database:production AND table:users` +
31+
"`",
32+
groupBy: ["entity_id"],
33+
},
34+
],
35+
},
36+
},
37+
};
38+
39+
apiInstance
40+
.createMonitor(params)
41+
.then((data: v1.Monitor) => {
42+
console.log(
43+
"API called successfully. Returned data: " + JSON.stringify(data)
44+
);
45+
})
46+
.catch((error: any) => console.error(error));

features/v1/monitors.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ Feature: Monitors
4242
When the request is sent
4343
Then the response status is 200 OK
4444

45+
@team:DataDog/monitor-app
46+
Scenario: Create a Data Quality monitor returns "OK" response
47+
Given new "CreateMonitor" request
48+
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"]}]}}
49+
When the request is sent
50+
Then the response status is 200 OK
51+
And the response "name" is equal to "{{ unique }}"
52+
And the response "type" is equal to "data-quality alert"
53+
4554
@team:DataDog/monitor-app
4655
Scenario: Create a RUM formula and functions monitor returns "OK" response
4756
Given new "CreateMonitor" request

packages/datadog-api-client-v1/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,10 @@ export { MonitorDraftStatus } from "./models/MonitorDraftStatus";
653653
export { MonitorFormulaAndFunctionCostAggregator } from "./models/MonitorFormulaAndFunctionCostAggregator";
654654
export { MonitorFormulaAndFunctionCostDataSource } from "./models/MonitorFormulaAndFunctionCostDataSource";
655655
export { MonitorFormulaAndFunctionCostQueryDefinition } from "./models/MonitorFormulaAndFunctionCostQueryDefinition";
656+
export { MonitorFormulaAndFunctionDataQualityDataSource } from "./models/MonitorFormulaAndFunctionDataQualityDataSource";
657+
export { MonitorFormulaAndFunctionDataQualityModelTypeOverride } from "./models/MonitorFormulaAndFunctionDataQualityModelTypeOverride";
658+
export { MonitorFormulaAndFunctionDataQualityMonitorOptions } from "./models/MonitorFormulaAndFunctionDataQualityMonitorOptions";
659+
export { MonitorFormulaAndFunctionDataQualityQueryDefinition } from "./models/MonitorFormulaAndFunctionDataQualityQueryDefinition";
656660
export { MonitorFormulaAndFunctionEventAggregation } from "./models/MonitorFormulaAndFunctionEventAggregation";
657661
export { MonitorFormulaAndFunctionEventQueryDefinition } from "./models/MonitorFormulaAndFunctionEventQueryDefinition";
658662
export { MonitorFormulaAndFunctionEventQueryDefinitionCompute } from "./models/MonitorFormulaAndFunctionEventQueryDefinitionCompute";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
7+
import { UnparsedObject } from "../../datadog-api-client-common/util";
8+
9+
/**
10+
* Data source for data quality queries.
11+
*/
12+
13+
export type MonitorFormulaAndFunctionDataQualityDataSource =
14+
| typeof DATA_QUALITY_METRICS
15+
| UnparsedObject;
16+
export const DATA_QUALITY_METRICS = "data_quality_metrics";
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
7+
import { UnparsedObject } from "../../datadog-api-client-common/util";
8+
9+
/**
10+
* Override for the model type used in anomaly detection.
11+
*/
12+
13+
export type MonitorFormulaAndFunctionDataQualityModelTypeOverride =
14+
| typeof FRESHNESS
15+
| typeof PERCENTAGE
16+
| typeof ANY
17+
| UnparsedObject;
18+
export const FRESHNESS = "freshness";
19+
export const PERCENTAGE = "percentage";
20+
export const ANY = "any";

0 commit comments

Comments
 (0)