Skip to content

Commit 521308e

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
feat - Add data-jobs alert monitor type support (DataDog#3330)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent f1b941b commit 521308e

9 files changed

Lines changed: 315 additions & 0 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8069,6 +8069,36 @@ components:
80698069
- data_source
80708070
- query
80718071
type: object
8072+
MonitorFormulaAndFunctionDataJobsQueryDefinition:
8073+
description: A formula and functions data jobs query.
8074+
properties:
8075+
job_type:
8076+
description: |-
8077+
The type of job being monitored. Valid values include:
8078+
`databricks.job`, `spark.application`, `airflow.dag`,
8079+
`dbt.job`, `dbt.model`, `dbt.test`, `glue.job`.
8080+
Custom job types are supported with the `custom.ol.` prefix.
8081+
example: "databricks.job"
8082+
type: string
8083+
jobs_query:
8084+
description: Filter expression used to select the jobs to monitor.
8085+
example: "job_name:smoke*"
8086+
type: string
8087+
name:
8088+
description: Name of the query for use in formulas. Must be `run_query`.
8089+
example: "run_query"
8090+
type: string
8091+
query_dialect:
8092+
description: |-
8093+
Query dialect for data jobs queries. Currently only `metric` is supported.
8094+
example: "metric"
8095+
type: string
8096+
required:
8097+
- name
8098+
- jobs_query
8099+
- job_type
8100+
- query_dialect
8101+
type: object
80728102
MonitorFormulaAndFunctionDataQualityDataSource:
80738103
description: Data source for data quality queries.
80748104
enum:
@@ -8375,6 +8405,7 @@ components:
83758405
- $ref: "#/components/schemas/MonitorFormulaAndFunctionEventQueryDefinition"
83768406
- $ref: "#/components/schemas/MonitorFormulaAndFunctionCostQueryDefinition"
83778407
- $ref: "#/components/schemas/MonitorFormulaAndFunctionDataQualityQueryDefinition"
8408+
- $ref: "#/components/schemas/MonitorFormulaAndFunctionDataJobsQueryDefinition"
83788409
- $ref: "#/components/schemas/MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition"
83798410
- $ref: "#/components/schemas/MonitorFormulaAndFunctionAggregateFilteredQueryDefinition"
83808411
MonitorFormulaAndFunctionReferenceTableColumn:
@@ -9207,6 +9238,7 @@ components:
92079238
- "cost alert"
92089239
- "data-quality alert"
92099240
- "network-path alert"
9241+
- "data-jobs alert"
92109242
example: "query alert"
92119243
type: string
92129244
x-enum-varnames:
@@ -9231,6 +9263,7 @@ components:
92319263
- COST_ALERT
92329264
- DATA_QUALITY_ALERT
92339265
- NETWORK_PATH_ALERT
9266+
- DATA_JOBS_ALERT
92349267
MonitorUpdateRequest:
92359268
description: Object describing a monitor update request.
92369269
properties:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-05-14T10:58:54.153Z

cassettes/features/v1/monitors/Create-a-Data-Jobs-monitor-returns-OK-response.yml

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Create a Data Jobs monitor returns "OK" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::MonitorsAPI.new
5+
6+
body = DatadogAPIClient::V1::Monitor.new({
7+
name: "Example-Monitor",
8+
type: DatadogAPIClient::V1::MonitorType::DATA_JOBS_ALERT,
9+
query: 'formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0',
10+
message: "Data jobs alert triggered",
11+
tags: [
12+
"test:examplemonitor",
13+
"env:ci",
14+
],
15+
options: DatadogAPIClient::V1::MonitorOptions.new({
16+
thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
17+
critical: 0,
18+
}),
19+
variables: [
20+
DatadogAPIClient::V1::MonitorFormulaAndFunctionDataJobsQueryDefinition.new({
21+
name: "run_query",
22+
jobs_query: "job_name:*",
23+
job_type: "databricks.job",
24+
query_dialect: "metric",
25+
}),
26+
],
27+
}),
28+
})
29+
p api_instance.create_monitor(body)

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 Jobs monitor returns "OK" response
47+
Given new "CreateMonitor" request
48+
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"}]}}
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-jobs alert"
53+
4554
@team:DataDog/monitor-app
4655
Scenario: Create a Data Quality monitor returns "OK" response
4756
Given new "CreateMonitor" request

lib/datadog_api_client/inflector.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def overrides
376376
"v1.monitor_formula_and_function_cost_aggregator" => "MonitorFormulaAndFunctionCostAggregator",
377377
"v1.monitor_formula_and_function_cost_data_source" => "MonitorFormulaAndFunctionCostDataSource",
378378
"v1.monitor_formula_and_function_cost_query_definition" => "MonitorFormulaAndFunctionCostQueryDefinition",
379+
"v1.monitor_formula_and_function_data_jobs_query_definition" => "MonitorFormulaAndFunctionDataJobsQueryDefinition",
379380
"v1.monitor_formula_and_function_data_quality_data_source" => "MonitorFormulaAndFunctionDataQualityDataSource",
380381
"v1.monitor_formula_and_function_data_quality_model_type_override" => "MonitorFormulaAndFunctionDataQualityModelTypeOverride",
381382
"v1.monitor_formula_and_function_data_quality_monitor_options" => "MonitorFormulaAndFunctionDataQualityMonitorOptions",
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
=begin
2+
#Datadog API V1 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
Contact: support@datadoghq.com
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V1
20+
# A formula and functions data jobs query.
21+
class MonitorFormulaAndFunctionDataJobsQueryDefinition
22+
include BaseGenericModel
23+
24+
# The type of job being monitored. Valid values include:
25+
# `databricks.job`, `spark.application`, `airflow.dag`,
26+
# `dbt.job`, `dbt.model`, `dbt.test`, `glue.job`.
27+
# Custom job types are supported with the `custom.ol.` prefix.
28+
attr_reader :job_type
29+
30+
# Filter expression used to select the jobs to monitor.
31+
attr_reader :jobs_query
32+
33+
# Name of the query for use in formulas. Must be `run_query`.
34+
attr_reader :name
35+
36+
# Query dialect for data jobs queries. Currently only `metric` is supported.
37+
attr_reader :query_dialect
38+
39+
attr_accessor :additional_properties
40+
41+
# Attribute mapping from ruby-style variable name to JSON key.
42+
# @!visibility private
43+
def self.attribute_map
44+
{
45+
:'job_type' => :'job_type',
46+
:'jobs_query' => :'jobs_query',
47+
:'name' => :'name',
48+
:'query_dialect' => :'query_dialect'
49+
}
50+
end
51+
52+
# Attribute type mapping.
53+
# @!visibility private
54+
def self.openapi_types
55+
{
56+
:'job_type' => :'String',
57+
:'jobs_query' => :'String',
58+
:'name' => :'String',
59+
:'query_dialect' => :'String'
60+
}
61+
end
62+
63+
# Initializes the object
64+
# @param attributes [Hash] Model attributes in the form of hash
65+
# @!visibility private
66+
def initialize(attributes = {})
67+
if (!attributes.is_a?(Hash))
68+
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::MonitorFormulaAndFunctionDataJobsQueryDefinition` initialize method"
69+
end
70+
71+
self.additional_properties = {}
72+
# check to see if the attribute exists and convert string to symbol for hash key
73+
attributes = attributes.each_with_object({}) { |(k, v), h|
74+
if (!self.class.attribute_map.key?(k.to_sym))
75+
self.additional_properties[k.to_sym] = v
76+
else
77+
h[k.to_sym] = v
78+
end
79+
}
80+
81+
if attributes.key?(:'job_type')
82+
self.job_type = attributes[:'job_type']
83+
end
84+
85+
if attributes.key?(:'jobs_query')
86+
self.jobs_query = attributes[:'jobs_query']
87+
end
88+
89+
if attributes.key?(:'name')
90+
self.name = attributes[:'name']
91+
end
92+
93+
if attributes.key?(:'query_dialect')
94+
self.query_dialect = attributes[:'query_dialect']
95+
end
96+
end
97+
98+
# Check to see if the all the properties in the model are valid
99+
# @return true if the model is valid
100+
# @!visibility private
101+
def valid?
102+
return false if @job_type.nil?
103+
return false if @jobs_query.nil?
104+
return false if @name.nil?
105+
return false if @query_dialect.nil?
106+
true
107+
end
108+
109+
# Custom attribute writer method with validation
110+
# @param job_type [Object] Object to be assigned
111+
# @!visibility private
112+
def job_type=(job_type)
113+
if job_type.nil?
114+
fail ArgumentError, 'invalid value for "job_type", job_type cannot be nil.'
115+
end
116+
@job_type = job_type
117+
end
118+
119+
# Custom attribute writer method with validation
120+
# @param jobs_query [Object] Object to be assigned
121+
# @!visibility private
122+
def jobs_query=(jobs_query)
123+
if jobs_query.nil?
124+
fail ArgumentError, 'invalid value for "jobs_query", jobs_query cannot be nil.'
125+
end
126+
@jobs_query = jobs_query
127+
end
128+
129+
# Custom attribute writer method with validation
130+
# @param name [Object] Object to be assigned
131+
# @!visibility private
132+
def name=(name)
133+
if name.nil?
134+
fail ArgumentError, 'invalid value for "name", name cannot be nil.'
135+
end
136+
@name = name
137+
end
138+
139+
# Custom attribute writer method with validation
140+
# @param query_dialect [Object] Object to be assigned
141+
# @!visibility private
142+
def query_dialect=(query_dialect)
143+
if query_dialect.nil?
144+
fail ArgumentError, 'invalid value for "query_dialect", query_dialect cannot be nil.'
145+
end
146+
@query_dialect = query_dialect
147+
end
148+
149+
# Returns the object in the form of hash, with additionalProperties support.
150+
# @return [Hash] Returns the object in the form of hash
151+
# @!visibility private
152+
def to_hash
153+
hash = {}
154+
self.class.attribute_map.each_pair do |attr, param|
155+
value = self.send(attr)
156+
if value.nil?
157+
is_nullable = self.class.openapi_nullable.include?(attr)
158+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
159+
end
160+
161+
hash[param] = _to_hash(value)
162+
end
163+
self.additional_properties.each_pair do |attr, value|
164+
hash[attr] = value
165+
end
166+
hash
167+
end
168+
169+
# Checks equality by comparing each attribute.
170+
# @param o [Object] Object to be compared
171+
# @!visibility private
172+
def ==(o)
173+
return true if self.equal?(o)
174+
self.class == o.class &&
175+
job_type == o.job_type &&
176+
jobs_query == o.jobs_query &&
177+
name == o.name &&
178+
query_dialect == o.query_dialect &&
179+
additional_properties == o.additional_properties
180+
end
181+
182+
# Calculates hash code according to all attributes.
183+
# @return [Integer] Hash code
184+
# @!visibility private
185+
def hash
186+
[job_type, jobs_query, name, query_dialect, additional_properties].hash
187+
end
188+
end
189+
end

lib/datadog_api_client/v1/models/monitor_formula_and_function_query_definition.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def openapi_one_of
2929
:'MonitorFormulaAndFunctionEventQueryDefinition',
3030
:'MonitorFormulaAndFunctionCostQueryDefinition',
3131
:'MonitorFormulaAndFunctionDataQualityQueryDefinition',
32+
:'MonitorFormulaAndFunctionDataJobsQueryDefinition',
3233
:'MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition',
3334
:'MonitorFormulaAndFunctionAggregateFilteredQueryDefinition'
3435
]

lib/datadog_api_client/v1/models/monitor_type.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ class MonitorType
4242
COST_ALERT = "cost alert".freeze
4343
DATA_QUALITY_ALERT = "data-quality alert".freeze
4444
NETWORK_PATH_ALERT = "network-path alert".freeze
45+
DATA_JOBS_ALERT = "data-jobs alert".freeze
4546
end
4647
end

0 commit comments

Comments
 (0)