Skip to content
Open
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
33 changes: 33 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8067,6 +8067,36 @@ components:
- data_source
- query
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`.
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.
example: "job_name:smoke*"
type: string
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.
example: "metric"
type: string
required:
- name
- jobs_query
- job_type
- query_dialect
type: object
MonitorFormulaAndFunctionDataQualityDataSource:
description: Data source for data quality queries.
enum:
Expand Down Expand Up @@ -8373,6 +8403,7 @@ components:
- $ref: "#/components/schemas/MonitorFormulaAndFunctionEventQueryDefinition"
- $ref: "#/components/schemas/MonitorFormulaAndFunctionCostQueryDefinition"
- $ref: "#/components/schemas/MonitorFormulaAndFunctionDataQualityQueryDefinition"
- $ref: "#/components/schemas/MonitorFormulaAndFunctionDataJobsQueryDefinition"
- $ref: "#/components/schemas/MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition"
- $ref: "#/components/schemas/MonitorFormulaAndFunctionAggregateFilteredQueryDefinition"
MonitorFormulaAndFunctionReferenceTableColumn:
Expand Down Expand Up @@ -9205,6 +9236,7 @@ components:
- "cost alert"
- "data-quality alert"
- "network-path alert"
- "data-jobs alert"
example: "query alert"
type: string
x-enum-varnames:
Expand All @@ -9229,6 +9261,7 @@ components:
- COST_ALERT
- DATA_QUALITY_ALERT
- NETWORK_PATH_ALERT
- DATA_JOBS_ALERT
MonitorUpdateRequest:
description: Object describing a monitor update request.
properties:
Expand Down
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v1.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2608,6 +2608,13 @@ datadog\_api\_client.v1.model.monitor\_formula\_and\_function\_cost\_query\_defi
:members:
:show-inheritance:

datadog\_api\_client.v1.model.monitor\_formula\_and\_function\_data\_jobs\_query\_definition module
---------------------------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_query_definition
:members:
:show-inheritance:

datadog\_api\_client.v1.model.monitor\_formula\_and\_function\_data\_quality\_data\_source module
-------------------------------------------------------------------------------------------------

Expand Down
44 changes: 44 additions & 0 deletions examples/v1/monitors/CreateMonitor_2589528326.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
Create a Data Jobs monitor 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_jobs_query_definition import (
MonitorFormulaAndFunctionDataJobsQueryDefinition,
)
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_JOBS_ALERT,
query='formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0',
message="Data jobs alert triggered",
tags=[
"test:examplemonitor",
"env:ci",
],
options=MonitorOptions(
thresholds=MonitorThresholds(
critical=0.0,
),
variables=[
MonitorFormulaAndFunctionDataJobsQueryDefinition(
name="run_query",
jobs_query="job_name:*",
job_type="databricks.job",
query_dialect="metric",
),
],
),
)

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
@@ -0,0 +1,54 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


class MonitorFormulaAndFunctionDataJobsQueryDefinition(ModelNormal):
@cached_property
def openapi_types(_):
return {
"job_type": (str,),
"jobs_query": (str,),
"name": (str,),
"query_dialect": (str,),
}

attribute_map = {
"job_type": "job_type",
"jobs_query": "jobs_query",
"name": "name",
"query_dialect": "query_dialect",
}

def __init__(self_, job_type: str, jobs_query: str, name: str, query_dialect: str, **kwargs):
"""
A formula and functions data jobs query.

:param job_type: The type of job being monitored. Valid values include:
``databricks.job`` , ``spark.application`` , ``airflow.dag`` ,
``dbt.job`` , ``dbt.model`` , ``dbt.test`` , ``glue.job``.
Custom job types are supported with the ``custom.ol.`` prefix.
:type job_type: str

:param jobs_query: Filter expression used to select the jobs to monitor.
:type jobs_query: str

:param name: Name of the query for use in formulas. Must be ``run_query``.
:type name: str

:param query_dialect: Query dialect for data jobs queries. Currently only ``metric`` is supported.
:type query_dialect: str
"""
super().__init__(kwargs)

self_.job_type = job_type
self_.jobs_query = jobs_query
self_.name = name
self_.query_dialect = query_dialect
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ def __init__(self, **kwargs):
This is useful when an entity has been configured to emit metrics with additional tags.
:type scope: str, optional

:param job_type: The type of job being monitored. Valid values include:
`databricks.job`, `spark.application`, `airflow.dag`,
`dbt.job`, `dbt.model`, `dbt.test`, `glue.job`.
Custom job types are supported with the `custom.ol.` prefix.
:type job_type: str

:param jobs_query: Filter expression used to select the jobs to monitor.
:type jobs_query: str

:param query_dialect: Query dialect for data jobs queries. Currently only `metric` is supported.
:type query_dialect: str

:param augment_query: Augment query for aggregate augmented queries. Can be an events query or a reference table query.
:type augment_query: MonitorFormulaAndFunctionAggregateAugmentQuery

Expand Down Expand Up @@ -93,6 +105,9 @@ def _composed_schemas(_):
from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_query_definition import (
MonitorFormulaAndFunctionDataQualityQueryDefinition,
)
from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_query_definition import (
MonitorFormulaAndFunctionDataJobsQueryDefinition,
)
from datadog_api_client.v1.model.monitor_formula_and_function_aggregate_augmented_query_definition import (
MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition,
)
Expand All @@ -105,6 +120,7 @@ def _composed_schemas(_):
MonitorFormulaAndFunctionEventQueryDefinition,
MonitorFormulaAndFunctionCostQueryDefinition,
MonitorFormulaAndFunctionDataQualityQueryDefinition,
MonitorFormulaAndFunctionDataJobsQueryDefinition,
MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition,
MonitorFormulaAndFunctionAggregateFilteredQueryDefinition,
],
Expand Down
4 changes: 4 additions & 0 deletions src/datadog_api_client/v1/model/monitor_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_query_definition import (
MonitorFormulaAndFunctionDataQualityQueryDefinition,
)
from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_query_definition import (
MonitorFormulaAndFunctionDataJobsQueryDefinition,
)
from datadog_api_client.v1.model.monitor_formula_and_function_aggregate_augmented_query_definition import (
MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition,
)
Expand Down Expand Up @@ -183,6 +186,7 @@ def __init__(
MonitorFormulaAndFunctionEventQueryDefinition,
MonitorFormulaAndFunctionCostQueryDefinition,
MonitorFormulaAndFunctionDataQualityQueryDefinition,
MonitorFormulaAndFunctionDataJobsQueryDefinition,
MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition,
MonitorFormulaAndFunctionAggregateFilteredQueryDefinition,
]
Expand Down
5 changes: 4 additions & 1 deletion src/datadog_api_client/v1/model/monitor_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MonitorType(ModelSimple):
"""
The type of the monitor. For more information about `type`, see the [monitor options](https://docs.datadoghq.com/monitors/guide/monitor_api_options/) docs.

:param value: Must be one of ["composite", "event alert", "log alert", "metric alert", "process alert", "query alert", "rum alert", "service check", "synthetics alert", "trace-analytics alert", "slo alert", "event-v2 alert", "audit alert", "ci-pipelines alert", "ci-tests alert", "error-tracking alert", "database-monitoring alert", "network-performance alert", "cost alert", "data-quality alert", "network-path alert"].
:param value: Must be one of ["composite", "event alert", "log alert", "metric alert", "process alert", "query alert", "rum alert", "service check", "synthetics alert", "trace-analytics alert", "slo alert", "event-v2 alert", "audit alert", "ci-pipelines alert", "ci-tests alert", "error-tracking alert", "database-monitoring alert", "network-performance alert", "cost alert", "data-quality alert", "network-path alert", "data-jobs alert"].
:type value: str
"""

Expand All @@ -42,6 +42,7 @@ class MonitorType(ModelSimple):
"cost alert",
"data-quality alert",
"network-path alert",
"data-jobs alert",
}
COMPOSITE: ClassVar["MonitorType"]
EVENT_ALERT: ClassVar["MonitorType"]
Expand All @@ -64,6 +65,7 @@ class MonitorType(ModelSimple):
COST_ALERT: ClassVar["MonitorType"]
DATA_QUALITY_ALERT: ClassVar["MonitorType"]
NETWORK_PATH_ALERT: ClassVar["MonitorType"]
DATA_JOBS_ALERT: ClassVar["MonitorType"]

@cached_property
def openapi_types(_):
Expand Down Expand Up @@ -93,3 +95,4 @@ def openapi_types(_):
MonitorType.COST_ALERT = MonitorType("cost alert")
MonitorType.DATA_QUALITY_ALERT = MonitorType("data-quality alert")
MonitorType.NETWORK_PATH_ALERT = MonitorType("network-path alert")
MonitorType.DATA_JOBS_ALERT = MonitorType("data-jobs alert")
4 changes: 4 additions & 0 deletions src/datadog_api_client/v1/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@
from datadog_api_client.v1.model.monitor_formula_and_function_cost_query_definition import (
MonitorFormulaAndFunctionCostQueryDefinition,
)
from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_query_definition import (
MonitorFormulaAndFunctionDataJobsQueryDefinition,
)
from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_data_source import (
MonitorFormulaAndFunctionDataQualityDataSource,
)
Expand Down Expand Up @@ -1718,6 +1721,7 @@
"MonitorFormulaAndFunctionCostAggregator",
"MonitorFormulaAndFunctionCostDataSource",
"MonitorFormulaAndFunctionCostQueryDefinition",
"MonitorFormulaAndFunctionDataJobsQueryDefinition",
"MonitorFormulaAndFunctionDataQualityDataSource",
"MonitorFormulaAndFunctionDataQualityModelTypeOverride",
"MonitorFormulaAndFunctionDataQualityMonitorOptions",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-05-14T10:58:54.153Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
interactions:
- request:
body: '{"message":"Data jobs alert triggered","name":"Test-Create_a_Data_Jobs_monitor_returns_OK_response-1778756334","options":{"thresholds":{"critical":0},"variables":[{"job_type":"databricks.job","jobs_query":"job_name:*","name":"run_query","query_dialect":"metric"}]},"query":"formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d)
> 0","tags":["test:testcreateadatajobsmonitorreturnsokresponse1778756334","env:ci"],"type":"data-jobs
alert"}'
headers:
accept:
- application/json
content-type:
- application/json
method: POST
uri: https://api.datadoghq.com/api/v1/monitor
response:
body:
string: '{"id":283063470,"org_id":321813,"type":"data-jobs alert","name":"Test-Create_a_Data_Jobs_monitor_returns_OK_response-1778756334","message":"Data
jobs alert triggered","tags":["test:testcreateadatajobsmonitorreturnsokresponse1778756334","env:ci"],"query":"formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d)
> 0","options":{"thresholds":{"critical":0.0},"variables":[{"job_type":"databricks.job","jobs_query":"job_name:*","name":"run_query","query_dialect":"metric"}],"notify_no_data":false,"notify_audit":false,"new_host_delay":300,"include_tags":true,"silenced":{}},"multi":true,"created_at":1778756334000,"created":"2026-05-14T10:58:54.236230+00:00","modified":"2026-05-14T10:58:54.236230+00:00","deleted":null,"priority":null,"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/283063470
response:
body:
string: '{"deleted_monitor_id":283063470}

'
headers:
content-type:
- application/json
status:
code: 200
message: OK
version: 1
9 changes: 9 additions & 0 deletions tests/v1/features/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ Feature: Monitors
When the request is sent
Then the response status is 200 OK

@team:DataDog/monitor-app
Scenario: Create a Data Jobs monitor returns "OK" response
Given new "CreateMonitor" request
And body with value {"name": "{{ unique }}", "type": "data-jobs alert", "query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0", "message": "Data jobs alert triggered", "tags": ["test:{{ unique_lower_alnum }}", "env:ci"], "options": {"thresholds": {"critical": 0}, "variables": [{"name": "run_query", "jobs_query": "job_name:*", "job_type": "databricks.job", "query_dialect": "metric"}]}}
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"

@team:DataDog/monitor-app
Scenario: Create a Data Quality monitor returns "OK" response
Given new "CreateMonitor" request
Expand Down
Loading