Skip to content

Commit ffcb7ba

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

8 files changed

Lines changed: 484 additions & 1 deletion

File tree

.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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Create a Data Jobs monitor returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v1.api.MonitorsApi;
6+
import com.datadog.api.client.v1.model.Monitor;
7+
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionDataJobsQueryDefinition;
8+
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionQueryDefinition;
9+
import com.datadog.api.client.v1.model.MonitorOptions;
10+
import com.datadog.api.client.v1.model.MonitorThresholds;
11+
import com.datadog.api.client.v1.model.MonitorType;
12+
import java.util.Arrays;
13+
import java.util.Collections;
14+
15+
public class Example {
16+
public static void main(String[] args) {
17+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
18+
MonitorsApi apiInstance = new MonitorsApi(defaultClient);
19+
20+
Monitor body =
21+
new Monitor()
22+
.name("Example-Monitor")
23+
.type(MonitorType.DATA_JOBS_ALERT)
24+
.query(
25+
"""
26+
formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0
27+
""")
28+
.message("Data jobs alert triggered")
29+
.tags(Arrays.asList("test:examplemonitor", "env:ci"))
30+
.options(
31+
new MonitorOptions()
32+
.thresholds(new MonitorThresholds())
33+
.variables(
34+
Collections.singletonList(
35+
new MonitorFormulaAndFunctionQueryDefinition(
36+
new MonitorFormulaAndFunctionDataJobsQueryDefinition()
37+
.name("run_query")
38+
.jobsQuery("job_name:*")
39+
.jobType("databricks.job")
40+
.queryDialect("metric")))));
41+
42+
try {
43+
Monitor result = apiInstance.createMonitor(body);
44+
System.out.println(result);
45+
} catch (ApiException e) {
46+
System.err.println("Exception when calling MonitorsApi#createMonitor");
47+
System.err.println("Status code: " + e.getCode());
48+
System.err.println("Reason: " + e.getResponseBody());
49+
System.err.println("Response headers: " + e.getResponseHeaders());
50+
e.printStackTrace();
51+
}
52+
}
53+
}
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
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 2019-Present Datadog, Inc.
5+
*/
6+
7+
package com.datadog.api.client.v1.model;
8+
9+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
10+
import com.fasterxml.jackson.annotation.JsonAnySetter;
11+
import com.fasterxml.jackson.annotation.JsonCreator;
12+
import com.fasterxml.jackson.annotation.JsonIgnore;
13+
import com.fasterxml.jackson.annotation.JsonInclude;
14+
import com.fasterxml.jackson.annotation.JsonProperty;
15+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
16+
import java.util.HashMap;
17+
import java.util.Map;
18+
import java.util.Objects;
19+
20+
/** A formula and functions data jobs query. */
21+
@JsonPropertyOrder({
22+
MonitorFormulaAndFunctionDataJobsQueryDefinition.JSON_PROPERTY_JOB_TYPE,
23+
MonitorFormulaAndFunctionDataJobsQueryDefinition.JSON_PROPERTY_JOBS_QUERY,
24+
MonitorFormulaAndFunctionDataJobsQueryDefinition.JSON_PROPERTY_NAME,
25+
MonitorFormulaAndFunctionDataJobsQueryDefinition.JSON_PROPERTY_QUERY_DIALECT
26+
})
27+
@jakarta.annotation.Generated(
28+
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
29+
public class MonitorFormulaAndFunctionDataJobsQueryDefinition {
30+
@JsonIgnore public boolean unparsed = false;
31+
public static final String JSON_PROPERTY_JOB_TYPE = "job_type";
32+
private String jobType;
33+
34+
public static final String JSON_PROPERTY_JOBS_QUERY = "jobs_query";
35+
private String jobsQuery;
36+
37+
public static final String JSON_PROPERTY_NAME = "name";
38+
private String name;
39+
40+
public static final String JSON_PROPERTY_QUERY_DIALECT = "query_dialect";
41+
private String queryDialect;
42+
43+
public MonitorFormulaAndFunctionDataJobsQueryDefinition() {}
44+
45+
@JsonCreator
46+
public MonitorFormulaAndFunctionDataJobsQueryDefinition(
47+
@JsonProperty(required = true, value = JSON_PROPERTY_JOB_TYPE) String jobType,
48+
@JsonProperty(required = true, value = JSON_PROPERTY_JOBS_QUERY) String jobsQuery,
49+
@JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name,
50+
@JsonProperty(required = true, value = JSON_PROPERTY_QUERY_DIALECT) String queryDialect) {
51+
this.jobType = jobType;
52+
this.jobsQuery = jobsQuery;
53+
this.name = name;
54+
this.queryDialect = queryDialect;
55+
}
56+
57+
public MonitorFormulaAndFunctionDataJobsQueryDefinition jobType(String jobType) {
58+
this.jobType = jobType;
59+
return this;
60+
}
61+
62+
/**
63+
* The type of job being monitored. Valid values include: <code>databricks.job</code>, <code>
64+
* spark.application</code>, <code>airflow.dag</code>, <code>dbt.job</code>, <code>dbt.model
65+
* </code>, <code>dbt.test</code>, <code>glue.job</code>. Custom job types are supported with the
66+
* <code>custom.ol.</code> prefix.
67+
*
68+
* @return jobType
69+
*/
70+
@JsonProperty(JSON_PROPERTY_JOB_TYPE)
71+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
72+
public String getJobType() {
73+
return jobType;
74+
}
75+
76+
public void setJobType(String jobType) {
77+
this.jobType = jobType;
78+
}
79+
80+
public MonitorFormulaAndFunctionDataJobsQueryDefinition jobsQuery(String jobsQuery) {
81+
this.jobsQuery = jobsQuery;
82+
return this;
83+
}
84+
85+
/**
86+
* Filter expression used to select the jobs to monitor.
87+
*
88+
* @return jobsQuery
89+
*/
90+
@JsonProperty(JSON_PROPERTY_JOBS_QUERY)
91+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
92+
public String getJobsQuery() {
93+
return jobsQuery;
94+
}
95+
96+
public void setJobsQuery(String jobsQuery) {
97+
this.jobsQuery = jobsQuery;
98+
}
99+
100+
public MonitorFormulaAndFunctionDataJobsQueryDefinition name(String name) {
101+
this.name = name;
102+
return this;
103+
}
104+
105+
/**
106+
* Name of the query for use in formulas. Must be <code>run_query</code>.
107+
*
108+
* @return name
109+
*/
110+
@JsonProperty(JSON_PROPERTY_NAME)
111+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
112+
public String getName() {
113+
return name;
114+
}
115+
116+
public void setName(String name) {
117+
this.name = name;
118+
}
119+
120+
public MonitorFormulaAndFunctionDataJobsQueryDefinition queryDialect(String queryDialect) {
121+
this.queryDialect = queryDialect;
122+
return this;
123+
}
124+
125+
/**
126+
* Query dialect for data jobs queries. Currently only <code>metric</code> is supported.
127+
*
128+
* @return queryDialect
129+
*/
130+
@JsonProperty(JSON_PROPERTY_QUERY_DIALECT)
131+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
132+
public String getQueryDialect() {
133+
return queryDialect;
134+
}
135+
136+
public void setQueryDialect(String queryDialect) {
137+
this.queryDialect = queryDialect;
138+
}
139+
140+
/**
141+
* A container for additional, undeclared properties. This is a holder for any undeclared
142+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
143+
*/
144+
private Map<String, Object> additionalProperties;
145+
146+
/**
147+
* Set the additional (undeclared) property with the specified name and value. If the property
148+
* does not already exist, create it otherwise replace it.
149+
*
150+
* @param key The arbitrary key to set
151+
* @param value The associated value
152+
* @return MonitorFormulaAndFunctionDataJobsQueryDefinition
153+
*/
154+
@JsonAnySetter
155+
public MonitorFormulaAndFunctionDataJobsQueryDefinition putAdditionalProperty(
156+
String key, Object value) {
157+
if (this.additionalProperties == null) {
158+
this.additionalProperties = new HashMap<String, Object>();
159+
}
160+
this.additionalProperties.put(key, value);
161+
return this;
162+
}
163+
164+
/**
165+
* Return the additional (undeclared) property.
166+
*
167+
* @return The additional properties
168+
*/
169+
@JsonAnyGetter
170+
public Map<String, Object> getAdditionalProperties() {
171+
return additionalProperties;
172+
}
173+
174+
/**
175+
* Return the additional (undeclared) property with the specified name.
176+
*
177+
* @param key The arbitrary key to get
178+
* @return The specific additional property for the given key
179+
*/
180+
public Object getAdditionalProperty(String key) {
181+
if (this.additionalProperties == null) {
182+
return null;
183+
}
184+
return this.additionalProperties.get(key);
185+
}
186+
187+
/** Return true if this MonitorFormulaAndFunctionDataJobsQueryDefinition object is equal to o. */
188+
@Override
189+
public boolean equals(Object o) {
190+
if (this == o) {
191+
return true;
192+
}
193+
if (o == null || getClass() != o.getClass()) {
194+
return false;
195+
}
196+
MonitorFormulaAndFunctionDataJobsQueryDefinition
197+
monitorFormulaAndFunctionDataJobsQueryDefinition =
198+
(MonitorFormulaAndFunctionDataJobsQueryDefinition) o;
199+
return Objects.equals(this.jobType, monitorFormulaAndFunctionDataJobsQueryDefinition.jobType)
200+
&& Objects.equals(
201+
this.jobsQuery, monitorFormulaAndFunctionDataJobsQueryDefinition.jobsQuery)
202+
&& Objects.equals(this.name, monitorFormulaAndFunctionDataJobsQueryDefinition.name)
203+
&& Objects.equals(
204+
this.queryDialect, monitorFormulaAndFunctionDataJobsQueryDefinition.queryDialect)
205+
&& Objects.equals(
206+
this.additionalProperties,
207+
monitorFormulaAndFunctionDataJobsQueryDefinition.additionalProperties);
208+
}
209+
210+
@Override
211+
public int hashCode() {
212+
return Objects.hash(jobType, jobsQuery, name, queryDialect, additionalProperties);
213+
}
214+
215+
@Override
216+
public String toString() {
217+
StringBuilder sb = new StringBuilder();
218+
sb.append("class MonitorFormulaAndFunctionDataJobsQueryDefinition {\n");
219+
sb.append(" jobType: ").append(toIndentedString(jobType)).append("\n");
220+
sb.append(" jobsQuery: ").append(toIndentedString(jobsQuery)).append("\n");
221+
sb.append(" name: ").append(toIndentedString(name)).append("\n");
222+
sb.append(" queryDialect: ").append(toIndentedString(queryDialect)).append("\n");
223+
sb.append(" additionalProperties: ")
224+
.append(toIndentedString(additionalProperties))
225+
.append("\n");
226+
sb.append('}');
227+
return sb.toString();
228+
}
229+
230+
/**
231+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
232+
*/
233+
private String toIndentedString(Object o) {
234+
if (o == null) {
235+
return "null";
236+
}
237+
return o.toString().replace("\n", "\n ");
238+
}
239+
}

0 commit comments

Comments
 (0)