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
78 changes: 73 additions & 5 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9793,30 +9793,53 @@ components:
- data_source
- query
type: object
MonitorFormulaAndFunctionDataJobsMonitorOptions:
description: Monitor configuration options for data jobs queries.
properties:
alert_on_every_failure:
description: |-
Alert separately for each failed run instead of on the count of trailing failures.
Only supported for `failed_runs` monitors with the `aastra` query dialect. It requires
a `> 0` threshold with no warning threshold, an evaluation window of at most two days,
and renotification disabled.
example: true
type: boolean
type: object
MonitorFormulaAndFunctionDataJobsQueryDefinition:
description: A formula and functions data jobs query.
properties:
job_type:
description: |-
The type of job being monitored. Valid values include:
`databricks.job`, `spark.application`, `airflow.dag`,
`dbt.job`, `dbt.model`, `dbt.test`, `glue.job`.
`databricks.job`, `spark.application`, `airflow.dag`, `dbt.job`, `glue.job`, `adf.pipeline`.
The `aastra` dialect also accepts `airflow.job`, `dbt.model`, and `dbt.test`.
Custom job types are supported with the `custom.ol.` prefix.
example: "databricks.job"
type: string
jobs_query:
description: Filter expression used to select the jobs to monitor.
description: |-
Filter expression used to select the jobs to monitor. Its syntax depends on `query_dialect`:
a metric tag filter such as `job_name:smoke*` for `metric`, or an Aastra entity search
such as ``search for databricks_job where `@team:data-eng` `` for `aastra`.
example: "job_name:smoke*"
type: string
monitor_options:
$ref: "#/components/schemas/MonitorFormulaAndFunctionDataJobsMonitorOptions"
name:
description: Name of the query for use in formulas. Must be `run_query`.
example: "run_query"
type: string
query_dialect:
description: |-
Query dialect for data jobs queries. Currently only `metric` is supported.
Query dialect for data jobs queries. Valid values are `metric` and `aastra`.
example: "metric"
type: string
run_filter:
description: |-
Optional filter on individual runs, using metrics filter syntax.
Only supported with the `aastra` query dialect.
example: "env:prod"
type: string
required:
- name
- jobs_query
Expand All @@ -9831,6 +9854,18 @@ components:
type: string
x-enum-varnames:
- DATA_QUALITY_METRICS
MonitorFormulaAndFunctionDataQualityDetectionType:
description: |-
How a `data-jobs alert` job duration monitor detects a breach. Must match the
`.detection()` call in the monitor query. Required for job duration monitors.
enum:
- static
- anomaly
example: "anomaly"
type: string
x-enum-varnames:
- STATIC
- ANOMALY
MonitorFormulaAndFunctionDataQualityDiffFunction:
description: |-
Function applied to the measure before it is compared against the predicted bounds.
Expand Down Expand Up @@ -9891,7 +9926,8 @@ components:
The data quality measure to query. Common values include:
`bytes`, `cardinality`, `custom`, `freshness`, `max`, `mean`, `min`,
`nullness`, `percent_negative`, `percent_zero`, `row_count`, `stddev`,
`sum`, `uniqueness`. Additional values may be supported.
`sum`, `uniqueness`. `data-jobs alert` job duration monitors use `duration`.
Additional values may be supported.
example: "row_count"
type: string
MonitorFormulaAndFunctionDataQualityModelBoundsOverride:
Expand Down Expand Up @@ -9961,6 +9997,14 @@ components:
MonitorFormulaAndFunctionDataQualityMonitorOptions:
description: Monitor configuration options for data quality queries.
properties:
consecutive_runs:
description: |-
Number of consecutive runs that must breach before the monitor alerts.
Only supported by `data-jobs alert` job duration monitors. Defaults to `1`.
example: 1
format: int64
minimum: 1
type: integer
crontab_override:
description: Crontab expression to override the default schedule.
example: "* * * 10"
Expand All @@ -9973,6 +10017,8 @@ components:
description: Custom WHERE clause for the query.
example: "USER_ID = 123"
type: string
detection_type:
$ref: "#/components/schemas/MonitorFormulaAndFunctionDataQualityDetectionType"
group_by_columns:
description: Columns to group results by.
example: ["col1", "col2"]
Expand Down Expand Up @@ -10020,6 +10066,12 @@ components:
description: Name of the query for use in formulas.
example: "query1"
type: string
run_filter:
description: |-
Optional filter on individual runs, using metrics filter syntax.
Only supported by `data-jobs alert` job duration monitors.
example: "env:prod"
type: string
schema_version:
description: Schema version for the data quality query.
example: "0.0.1"
Expand Down Expand Up @@ -37279,6 +37331,22 @@ paths:
- `time_window` #m (between 1 and 2880), #h (between 1 and 48).
- `operator` `<`, `<=`, `>`, `>=`, `==`, or `!=`.
- `#` an integer or decimal number used to set the threshold.

**Data Jobs Alert Query**

Job status example: `formula("failed_runs(run_query)").by(group_keys).last(time_window) > #`

Job duration examples: `formula("job_duration(run_query)").detection(static).by(group_keys) > duration`
and `formula("job_duration(run_query)").detection(anomaly).by(group_keys) > 0`

- `run_query`: The name of the single query variable in `options.variables`. Job status monitors
use a data jobs query; job duration monitors use a data quality query with the `duration` measure.
- `group_keys`: The tags to group by, such as `entity_id,name,workspace_name`.
- `time_window`: Number of minutes (#m), hours (#h), or days (#d), up to `10d`.
- `#`: The number of trailing failed runs to alert above, as a non-negative integer.
- `duration`: The duration to alert above, such as `2h`, `30m`, or a number of seconds.
- `options.thresholds.critical`: Must equal the query threshold, in seconds for job duration.
Anomaly job duration monitors omit `options.thresholds`.
operationId: CreateMonitor
requestBody:
content:
Expand Down
40 changes: 40 additions & 0 deletions examples/v1/monitors/CreateMonitor_1267012748.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Create a Data Jobs duration monitor returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::MonitorsAPI.new

body = DatadogAPIClient::V1::Monitor.new({
name: "Example-Monitor",
type: DatadogAPIClient::V1::MonitorType::DATA_JOBS_ALERT,
query: 'formula("job_duration(run_query)").detection(anomaly).by(name,workspace_name,entity_id) > 0',
message: "Data jobs duration alert triggered",
tags: [
"test:examplemonitor",
"env:ci",
],
options: DatadogAPIClient::V1::MonitorOptions.new({
variables: [
DatadogAPIClient::V1::MonitorFormulaAndFunctionDataQualityQueryDefinition.new({
name: "run_query",
data_source: DatadogAPIClient::V1::MonitorFormulaAndFunctionDataQualityDataSource::DATA_QUALITY_METRICS,
schema_version: "0.0.1",
measure: "duration",
filter: "search for databricks_job",
run_filter: "env:prod",
group_by: [
"name",
"workspace_name",
"entity_id",
],
monitor_options: DatadogAPIClient::V1::MonitorFormulaAndFunctionDataQualityMonitorOptions.new({
detection_type: DatadogAPIClient::V1::MonitorFormulaAndFunctionDataQualityDetectionType::ANOMALY,
consecutive_runs: 2,
}),
}),
],
}),
})
p api_instance.create_monitor(body)
36 changes: 36 additions & 0 deletions examples/v1/monitors/CreateMonitor_1302731819.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Create a Data Jobs monitor with the aastra query dialect returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::MonitorsAPI.new

body = DatadogAPIClient::V1::Monitor.new({
name: "Example-Monitor",
type: DatadogAPIClient::V1::MonitorType::DATA_JOBS_ALERT,
query: 'formula("failed_runs(run_query)").by(name,workspace_name,entity_id).last(1d) > 0',
message: "Data jobs alert triggered",
tags: [
"test:examplemonitor",
"env:ci",
],
options: DatadogAPIClient::V1::MonitorOptions.new({
thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
critical: 0,
}),
variables: [
DatadogAPIClient::V1::MonitorFormulaAndFunctionDataJobsQueryDefinition.new({
name: "run_query",
jobs_query: "search for databricks_job",
job_type: "databricks.job",
query_dialect: "aastra",
run_filter: "env:prod",
monitor_options: DatadogAPIClient::V1::MonitorFormulaAndFunctionDataJobsMonitorOptions.new({
alert_on_every_failure: true,
}),
}),
],
}),
})
p api_instance.create_monitor(body)
24 changes: 24 additions & 0 deletions features/v1/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ Feature: Monitors
When the request is sent
Then the response status is 200 OK

@team:ddoghq/monitor-app
Scenario: Create a Data Jobs duration monitor returns "OK" response
Given new "CreateMonitor" request
And body with value {"name": "{{ unique }}", "type": "data-jobs alert", "query": "formula(\"job_duration(run_query)\").detection(anomaly).by(name,workspace_name,entity_id) > 0", "message": "Data jobs duration alert triggered", "tags": ["test:{{ unique_lower_alnum }}", "env:ci"], "options": {"variables": [{"name": "run_query", "data_source": "data_quality_metrics", "schema_version": "0.0.1", "measure": "duration", "filter": "search for databricks_job", "run_filter": "env:prod", "group_by": ["name", "workspace_name", "entity_id"], "monitor_options": {"detection_type": "anomaly", "consecutive_runs": 2}}]}}
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-jobs alert"
And the response "options.variables[0].run_filter" is equal to "env:prod"
And the response "options.variables[0].monitor_options.detection_type" is equal to "anomaly"
And the response "options.variables[0].monitor_options.consecutive_runs" is equal to 2

@team:ddoghq/monitor-app
Scenario: Create a Data Jobs monitor returns "OK" response
Given new "CreateMonitor" request
Expand All @@ -51,6 +63,18 @@ Feature: Monitors
And the response "name" is equal to "{{ unique }}"
And the response "type" is equal to "data-jobs alert"

@team:ddoghq/monitor-app
Scenario: Create a Data Jobs monitor with the aastra query dialect returns "OK" response
Given new "CreateMonitor" request
And body with value {"name": "{{ unique }}", "type": "data-jobs alert", "query": "formula(\"failed_runs(run_query)\").by(name,workspace_name,entity_id).last(1d) > 0", "message": "Data jobs alert triggered", "tags": ["test:{{ unique_lower_alnum }}", "env:ci"], "options": {"thresholds": {"critical": 0}, "variables": [{"name": "run_query", "jobs_query": "search for databricks_job", "job_type": "databricks.job", "query_dialect": "aastra", "run_filter": "env:prod", "monitor_options": {"alert_on_every_failure": true}}]}}
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-jobs alert"
And the response "options.variables[0].query_dialect" is equal to "aastra"
And the response "options.variables[0].run_filter" is equal to "env:prod"
And the response "options.variables[0].monitor_options.alert_on_every_failure" is equal to true

@team:ddoghq/monitor-app
Scenario: Create a Data Quality monitor returns "OK" response
Given new "CreateMonitor" request
Expand Down
14 changes: 14 additions & 0 deletions generated-test/test-runner-data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1435,13 +1435,27 @@
"scenario": "Create a Cost Monitor returns \"OK\" response",
"version": "v1"
},
{
"feature": "Monitors",
"feature_file": "../../features/v1/monitors.feature",
"file": "v1/monitors/create-a-data-jobs-duration-monitor-returns-ok-response.json",
"scenario": "Create a Data Jobs duration monitor returns \"OK\" response",
"version": "v1"
},
{
"feature": "Monitors",
"feature_file": "../../features/v1/monitors.feature",
"file": "v1/monitors/create-a-data-jobs-monitor-returns-ok-response.json",
"scenario": "Create a Data Jobs monitor returns \"OK\" response",
"version": "v1"
},
{
"feature": "Monitors",
"feature_file": "../../features/v1/monitors.feature",
"file": "v1/monitors/create-a-data-jobs-monitor-with-the-aastra-query-dialect-returns-ok-response.json",
"scenario": "Create a Data Jobs monitor with the aastra query dialect returns \"OK\" response",
"version": "v1"
},
{
"feature": "Monitors",
"feature_file": "../../features/v1/monitors.feature",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"api": "Monitors",
"expected_status": 200,
"feature": "Monitors",
"id": "v1/Monitors/Create a Data Jobs duration monitor returns \"OK\" response",
"operation_id": "CreateMonitor",
"request": {
"body": {
"schema": {
"format": null,
"ref": "Monitor",
"type": "object"
},
"source": "inline",
"value": {
"message": "Data jobs duration alert triggered",
"name": "{{ unique }}",
"options": {
"variables": [
{
"data_source": "data_quality_metrics",
"filter": "search for databricks_job",
"group_by": [
"name",
"workspace_name",
"entity_id"
],
"measure": "duration",
"monitor_options": {
"consecutive_runs": 2,
"detection_type": "anomaly"
},
"name": "run_query",
"run_filter": "env:prod",
"schema_version": "0.0.1"
}
]
},
"query": "formula(\"job_duration(run_query)\").detection(anomaly).by(name,workspace_name,entity_id) > 0",
"tags": [
"test:{{ unique_lower_alnum }}",
"env:ci"
],
"type": "data-jobs alert"
}
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/api/v1/monitor"
},
"scenario": "Create a Data Jobs duration monitor returns \"OK\" response",
"schema_version": 1,
"version": "v1"
}
Loading
Loading