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
66 changes: 66 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7255,6 +7255,12 @@ 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 take action 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 +7344,52 @@ components:
- type
- query
type: object
MonitorAsset:
description: 'Represents key links tied to a monitor to help users take action
on alerts.

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
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'
url:
description: URL link for the asset. For links with an internal resource
type set, this should be the relative path to where the Datadog domain
is appended internally. For external links, this should be the full URL
path.
example: /notebooks/12345
type: string
required:
- name
- url
- category
type: object
MonitorAssetCategory:
description: Indicates the type of asset this entity represents on a monitor.
enum:
- runbook
example: runbook
type: string
x-enum-varnames:
- 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 +8504,13 @@ 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 take action 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 @@ -31584,6 +31643,13 @@ paths:
required: false
schema:
type: boolean
- description: If this argument is set to `true`, 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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-10-10T16:41:03.364Z
2025-11-21T18:03:25.715Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025-11-21T19:04:55.769Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions examples/v1/monitors/CreateMonitor_3541766733.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Create a monitor with assets returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MonitorsAPI.new

body = DatadogAPIClient::V1::Monitor.new({
assets: [
DatadogAPIClient::V1::MonitorAsset.new({
category: DatadogAPIClient::V1::MonitorAssetCategory::RUNBOOK,
name: "Monitor Runbook",
resource_key: "12345",
resource_type: DatadogAPIClient::V1::MonitorAssetResourceType::NOTEBOOK,
url: "/notebooks/12345",
}),
],
name: "Example-Monitor",
type: DatadogAPIClient::V1::MonitorType::METRIC_ALERT,
query: "avg(current_1mo):avg:system.load.5{*} > 0.5",
message: "some message Notify: @hipchat-channel",
options: DatadogAPIClient::V1::MonitorOptions.new({
thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
critical: 0.5,
}),
scheduling_options: DatadogAPIClient::V1::MonitorOptionsSchedulingOptions.new({
evaluation_window: DatadogAPIClient::V1::MonitorOptionsSchedulingOptionsEvaluationWindow.new({
day_starts: "04:00",
month_starts: 1,
}),
}),
}),
})
p api_instance.create_monitor(body)
1 change: 1 addition & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@
"monitor_id" => "Integer",
"group_states" => "String",
"with_downtimes" => "Boolean",
"with_assets" => "Boolean",
},
"v1.UpdateMonitor" => {
"monitor_id" => "Integer",
Expand Down
14 changes: 13 additions & 1 deletion features/v1/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ Feature: Monitors
And the response "type" is equal to "log alert"
And the response "query" is equal to "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\") > 2"

@team:DataDog/monitor-app
Scenario: Create a monitor with assets returns "OK" response
Given new "CreateMonitor" request
And body with value {"assets": [{"category": "runbook", "name": "Monitor Runbook", "resource_key": "12345", "resource_type": "notebook", "url": "/notebooks/12345"}], "name": "{{ unique }}", "type": "metric alert", "query": "avg(current_1mo):avg:system.load.5{*} > 0.5", "message": "some message Notify: @hipchat-channel", "options":{"thresholds":{"critical":0.5}, "scheduling_options":{"evaluation_window":{"day_starts":"04:00", "month_starts":1}}}}
When the request is sent
Then the response status is 200 OK
And the response "assets[0].category" is equal to "runbook"
And the response "assets[0].name" is equal to "Monitor Runbook"
And the response "assets[0].resource_key" is equal to "12345"
And the response "assets[0].resource_type" is equal to "notebook"
And the response "assets[0].url" is equal to "/notebooks/12345"

@team:DataDog/monitor-app
Scenario: Create an Error Tracking monitor returns "OK" response
Given new "CreateMonitor" request
Expand Down Expand Up @@ -169,7 +181,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": "runbook", "name": "Monitor Runbook", "resource_key": "12345", "resource_type": "notebook", "url": "/notebooks/12345"}], "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
3 changes: 3 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ def overrides
"v1.metrics_query_response" => "MetricsQueryResponse",
"v1.metrics_query_unit" => "MetricsQueryUnit",
"v1.monitor" => "Monitor",
"v1.monitor_asset" => "MonitorAsset",
"v1.monitor_asset_category" => "MonitorAssetCategory",
"v1.monitor_asset_resource_type" => "MonitorAssetResourceType",
"v1.monitor_device_id" => "MonitorDeviceID",
"v1.monitor_draft_status" => "MonitorDraftStatus",
"v1.monitor_formula_and_function_cost_aggregator" => "MonitorFormulaAndFunctionCostAggregator",
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog_api_client/v1/api/monitors_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ def get_monitor(monitor_id, opts = {})
# @param opts [Hash] the optional parameters
# @option opts [String] :group_states When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`.
# @option opts [Boolean] :with_downtimes If this argument is set to true, then the returned data includes all current active downtimes for the monitor.
# @option opts [Boolean] :with_assets If this argument is set to `true`, the returned data includes all assets tied to this monitor.
# @return [Array<(Monitor, Integer, Hash)>] Monitor data, response status code and response headers
def get_monitor_with_http_info(monitor_id, opts = {})

Expand All @@ -473,6 +474,7 @@ def get_monitor_with_http_info(monitor_id, opts = {})
query_params = opts[:query_params] || {}
query_params[:'group_states'] = opts[:'group_states'] if !opts[:'group_states'].nil?
query_params[:'with_downtimes'] = opts[:'with_downtimes'] if !opts[:'with_downtimes'].nil?
query_params[:'with_assets'] = opts[:'with_assets'] if !opts[:'with_assets'].nil?

# header parameters
header_params = opts[:header_params] || {}
Expand Down
Loading
Loading