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
80 changes: 80 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7255,6 +7255,13 @@ components:
Monitor:
description: Object describing a monitor.
properties:
assets:
description: The list of monitor assets tied to a monitor which represents
key links for users to help take actions on monitor alerts (for example,
runbooks)
items:
$ref: '#/components/schemas/MonitorAsset'
type: array
created:
description: Timestamp of the monitor creation.
format: date-time
Expand Down Expand Up @@ -7338,6 +7345,64 @@ components:
- type
- query
type: object
MonitorAsset:
description: 'Represents key links tied to a monitor to help users take action
on alerts (Runbooks, Dashboards, Workflows)

This feature is in Preview and only available to users with the feature enabled.'
properties:
category:
$ref: '#/components/schemas/MonitorAssetCategory'
name:
description: Name for the monitor asset
example: Monitor Runbook
type: string
options:
description: Additional options that you can set on a monitor asset.
example:
hide_in_monitor_message: true
type: object
resource_key:
description: Represents the identifier of the internal datadog resource
that this asset represents. IDs in this field should be passed in as strings.
example: '12345'
type: string
resource_type:
$ref: '#/components/schemas/MonitorAssetResourceType'
template_variables:
description: Allows you to parameterize the url for the monitor asset.
example:
env: prod
region: us-east-1
type: object
url:
description: Url link for the asset
example: https://app.datadoghq.com
type: string
required:
- name
- url
- category
type: object
MonitorAssetCategory:
description: Indicates the type of asset this entity represents on a monitor
enum:
- dashboard
- workflow
- runbook
example: dashboard
type: string
x-enum-varnames:
- DASHBOARD
- WORKFLOW
- RUNBOOK
MonitorAssetResourceType:
description: Type of internal datadog resource associated with a monitor asset
enum:
- notebook
type: string
x-enum-varnames:
- NOTEBOOK
MonitorDeviceID:
description: ID of the device the Synthetics monitor is running on. Same as
`SyntheticsDeviceID`.
Expand Down Expand Up @@ -8452,6 +8517,14 @@ components:
MonitorUpdateRequest:
description: Object describing a monitor update request.
properties:
assets:
description: The list of monitor assets tied to a monitor, which represents
key links for users to help take actions on monitor alerts (for example,
runbooks)
items:
$ref: '#/components/schemas/MonitorAsset'
nullable: true
type: array
created:
description: Timestamp of the monitor creation.
format: date-time
Expand Down Expand Up @@ -31529,6 +31602,13 @@ paths:
required: false
schema:
type: boolean
- description: If this argument is set to `true`, then the returned data includes
all assets tied to this monitor.
in: query
name: with_assets
required: false
schema:
type: boolean
responses:
'200':
content:
Expand Down
2 changes: 1 addition & 1 deletion features/v1/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Feature: Monitors
Scenario: Edit a monitor returns "Bad Request" response
Given new "UpdateMonitor" request
And request contains "monitor_id" parameter from "REPLACE.ME"
And body with value {"draft_status": "published", "options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1, "timezone": "Europe/Paris"}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"}
And body with value {"assets": [{"category": "dashboard", "name": "Monitor Runbook", "options": {"hide_in_monitor_message": true}, "resource_key": "12345", "resource_type": "notebook", "template_variables": {"env": "prod", "region": "us-east-1"}, "url": "https://app.datadoghq.com"}], "draft_status": "published", "options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1, "timezone": "Europe/Paris"}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"}
When the request is sent
Then the response status is 400 Bad Request

Expand Down
4 changes: 4 additions & 0 deletions private/bdd_runner/src/support/scenarios_model_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,10 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = {
type: "boolean",
format: "",
},
withAssets: {
type: "boolean",
format: "",
},
operationResponseType: "Monitor",
},
"MonitorsApi.V1.UpdateMonitor": {
Expand Down
14 changes: 14 additions & 0 deletions services/monitors/src/v1/MonitorsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class MonitorsApiRequestFactory extends BaseAPIRequestFactory {
monitorId: number,
groupStates?: string,
withDowntimes?: boolean,
withAssets?: boolean,
_options?: Configuration,
): Promise<RequestContext> {
const _config = _options || this.configuration;
Expand Down Expand Up @@ -249,6 +250,13 @@ export class MonitorsApiRequestFactory extends BaseAPIRequestFactory {
"",
);
}
if (withAssets !== undefined) {
requestContext.setQueryParam(
"with_assets",
serialize(withAssets, TypingInfo, "boolean", ""),
"",
);
}

// Apply auth methods
applySecurityAuthentication(_config, requestContext, [
Expand Down Expand Up @@ -1318,6 +1326,11 @@ export interface MonitorsApiGetMonitorRequest {
* @type boolean
*/
withDowntimes?: boolean;
/**
* If this argument is set to `true`, then the returned data includes all assets tied to this monitor.
* @type boolean
*/
withAssets?: boolean;
}

export interface MonitorsApiListMonitorsRequest {
Expand Down Expand Up @@ -1779,6 +1792,7 @@ export class MonitorsApi {
param.monitorId,
param.groupStates,
param.withDowntimes,
param.withAssets,
options,
);
return requestContextPromise.then((requestContext) => {
Expand Down
3 changes: 3 additions & 0 deletions services/monitors/src/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export { Creator } from "./models/Creator";
export { DeletedMonitor } from "./models/DeletedMonitor";
export { MatchingDowntime } from "./models/MatchingDowntime";
export { Monitor } from "./models/Monitor";
export { MonitorAsset } from "./models/MonitorAsset";
export { MonitorAssetCategory } from "./models/MonitorAssetCategory";
export { MonitorAssetResourceType } from "./models/MonitorAssetResourceType";
export { MonitorDeviceID } from "./models/MonitorDeviceID";
export { MonitorDraftStatus } from "./models/MonitorDraftStatus";
export { MonitorFormulaAndFunctionCostAggregator } from "./models/MonitorFormulaAndFunctionCostAggregator";
Expand Down
9 changes: 9 additions & 0 deletions services/monitors/src/v1/models/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AttributeTypeMap } from "@datadog/datadog-api-client";

import { Creator } from "./Creator";
import { MatchingDowntime } from "./MatchingDowntime";
import { MonitorAsset } from "./MonitorAsset";
import { MonitorDraftStatus } from "./MonitorDraftStatus";
import { MonitorOptions } from "./MonitorOptions";
import { MonitorOverallStates } from "./MonitorOverallStates";
Expand All @@ -12,6 +13,10 @@ import { MonitorType } from "./MonitorType";
* Object describing a monitor.
*/
export class Monitor {
/**
* The list of monitor assets tied to a monitor which represents key links for users to help take actions on monitor alerts (for example, runbooks)
*/
"assets"?: Array<MonitorAsset>;
/**
* Timestamp of the monitor creation.
*/
Expand Down Expand Up @@ -104,6 +109,10 @@ export class Monitor {
* @ignore
*/
static readonly attributeTypeMap: AttributeTypeMap = {
assets: {
baseName: "assets",
type: "Array<MonitorAsset>",
},
created: {
baseName: "created",
type: "Date",
Expand Down
99 changes: 99 additions & 0 deletions services/monitors/src/v1/models/MonitorAsset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { AttributeTypeMap } from "@datadog/datadog-api-client";

import { MonitorAssetCategory } from "./MonitorAssetCategory";
import { MonitorAssetResourceType } from "./MonitorAssetResourceType";

/**
* Represents key links tied to a monitor to help users take action on alerts (Runbooks, Dashboards, Workflows)
* This feature is in Preview and only available to users with the feature enabled.
*/
export class MonitorAsset {
/**
* Indicates the type of asset this entity represents on a monitor
*/
"category": MonitorAssetCategory;
/**
* Name for the monitor asset
*/
"name": string;
/**
* Additional options that you can set on a monitor asset.
*/
"options"?: any;
/**
* Represents the identifier of the internal datadog resource that this asset represents. IDs in this field should be passed in as strings.
*/
"resourceKey"?: string;
/**
* Type of internal datadog resource associated with a monitor asset
*/
"resourceType"?: MonitorAssetResourceType;
/**
* Allows you to parameterize the url for the monitor asset.
*/
"templateVariables"?: any;
/**
* Url link for the asset
*/
"url": string;
/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
"additionalProperties"?: { [key: string]: any };
/**
* @ignore
*/
"_unparsed"?: boolean;

/**
* @ignore
*/
static readonly attributeTypeMap: AttributeTypeMap = {
category: {
baseName: "category",
type: "MonitorAssetCategory",
required: true,
},
name: {
baseName: "name",
type: "string",
required: true,
},
options: {
baseName: "options",
type: "any",
},
resourceKey: {
baseName: "resource_key",
type: "string",
},
resourceType: {
baseName: "resource_type",
type: "MonitorAssetResourceType",
},
templateVariables: {
baseName: "template_variables",
type: "any",
},
url: {
baseName: "url",
type: "string",
required: true,
},
additionalProperties: {
baseName: "additionalProperties",
type: "{ [key: string]: any; }",
},
};

/**
* @ignore
*/
static getAttributeTypeMap(): AttributeTypeMap {
return MonitorAsset.attributeTypeMap;
}

public constructor() {}
}
13 changes: 13 additions & 0 deletions services/monitors/src/v1/models/MonitorAssetCategory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { UnparsedObject } from "@datadog/datadog-api-client";

/**
* Indicates the type of asset this entity represents on a monitor
*/
export type MonitorAssetCategory =
| typeof DASHBOARD
| typeof WORKFLOW
| typeof RUNBOOK
| UnparsedObject;
export const DASHBOARD = "dashboard";
export const WORKFLOW = "workflow";
export const RUNBOOK = "runbook";
7 changes: 7 additions & 0 deletions services/monitors/src/v1/models/MonitorAssetResourceType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { UnparsedObject } from "@datadog/datadog-api-client";

/**
* Type of internal datadog resource associated with a monitor asset
*/
export type MonitorAssetResourceType = typeof NOTEBOOK | UnparsedObject;
export const NOTEBOOK = "notebook";
9 changes: 9 additions & 0 deletions services/monitors/src/v1/models/MonitorUpdateRequest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AttributeTypeMap } from "@datadog/datadog-api-client";

import { Creator } from "./Creator";
import { MonitorAsset } from "./MonitorAsset";
import { MonitorDraftStatus } from "./MonitorDraftStatus";
import { MonitorOptions } from "./MonitorOptions";
import { MonitorOverallStates } from "./MonitorOverallStates";
Expand All @@ -11,6 +12,10 @@ import { MonitorType } from "./MonitorType";
* Object describing a monitor update request.
*/
export class MonitorUpdateRequest {
/**
* The list of monitor assets tied to a monitor, which represents key links for users to help take actions on monitor alerts (for example, runbooks)
*/
"assets"?: Array<MonitorAsset>;
/**
* Timestamp of the monitor creation.
*/
Expand Down Expand Up @@ -99,6 +104,10 @@ export class MonitorUpdateRequest {
* @ignore
*/
static readonly attributeTypeMap: AttributeTypeMap = {
assets: {
baseName: "assets",
type: "Array<MonitorAsset>",
},
created: {
baseName: "created",
type: "Date",
Expand Down
4 changes: 4 additions & 0 deletions services/monitors/src/v1/models/TypingInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Creator } from "./Creator";
import { DeletedMonitor } from "./DeletedMonitor";
import { MatchingDowntime } from "./MatchingDowntime";
import { Monitor } from "./Monitor";
import { MonitorAsset } from "./MonitorAsset";
import { MonitorFormulaAndFunctionCostQueryDefinition } from "./MonitorFormulaAndFunctionCostQueryDefinition";
import { MonitorFormulaAndFunctionEventQueryDefinition } from "./MonitorFormulaAndFunctionEventQueryDefinition";
import { MonitorFormulaAndFunctionEventQueryDefinitionCompute } from "./MonitorFormulaAndFunctionEventQueryDefinitionCompute";
Expand Down Expand Up @@ -36,6 +37,8 @@ import { MonitorUpdateRequest } from "./MonitorUpdateRequest";

export const TypingInfo: ModelTypingInfo = {
enumsMap: {
MonitorAssetCategory: ["dashboard", "workflow", "runbook"],
MonitorAssetResourceType: ["notebook"],
MonitorDeviceID: [
"laptop_large",
"tablet",
Expand Down Expand Up @@ -148,6 +151,7 @@ export const TypingInfo: ModelTypingInfo = {
DeletedMonitor: DeletedMonitor,
MatchingDowntime: MatchingDowntime,
Monitor: Monitor,
MonitorAsset: MonitorAsset,
MonitorFormulaAndFunctionCostQueryDefinition:
MonitorFormulaAndFunctionCostQueryDefinition,
MonitorFormulaAndFunctionEventQueryDefinition:
Expand Down