Class: DatadogAPIClient::V1::MonitorsAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_api_client/v1/api/monitors_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = DatadogAPIClient::APIClient.default) ⇒ MonitorsAPI

Returns a new instance of MonitorsAPI.



22
23
24
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 22

def initialize(api_client = DatadogAPIClient::APIClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



20
21
22
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#check_can_delete_monitor(monitor_ids, opts = {}) ⇒ Object

Check if a monitor can be deleted.



29
30
31
32
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 29

def check_can_delete_monitor(monitor_ids, opts = {})
  data, _status_code, _headers = check_can_delete_monitor_with_http_info(monitor_ids, opts)
  data
end

#check_can_delete_monitor_with_http_info(monitor_ids, opts = {}) ⇒ Array<(CheckCanDeleteMonitorResponse, Integer, Hash)>

Check if a monitor can be deleted.

Check if the given monitors can be deleted.

Parameters:

  • monitor_ids (Array<Integer>)

    The IDs of the monitor to check.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 41

def check_can_delete_monitor_with_http_info(monitor_ids, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.check_can_delete_monitor ...'
  end
  # verify the required parameter 'monitor_ids' is set
  if @api_client.config.client_side_validation && monitor_ids.nil?
    fail ArgumentError, "Missing the required parameter 'monitor_ids' when calling MonitorsAPI.check_can_delete_monitor"
  end
  # resource path
  local_var_path = '/api/v1/monitor/can_delete'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'monitor_ids'] = @api_client.build_collection_param(monitor_ids, :csv)

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'CheckCanDeleteMonitorResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :check_can_delete_monitor,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#check_can_delete_monitor\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_monitor(body, opts = {}) ⇒ Object

Create a monitor.



95
96
97
98
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 95

def create_monitor(body, opts = {})
  data, _status_code, _headers = create_monitor_with_http_info(body, opts)
  data
end

#create_monitor_with_http_info(body, opts = {}) ⇒ Array<(Monitor, Integer, Hash)>

Create a monitor.

Create a monitor using the specified options.

#### Monitor Types

The type of monitor chosen from:

  • anomaly: ‘query alert`

  • APM: ‘query alert` or `trace-analytics alert`

  • composite: composite

  • custom: ‘service check`

  • event: ‘event alert`

  • forecast: ‘query alert`

  • host: ‘service check`

  • integration: ‘query alert` or `service check`

  • live process: ‘process alert`

  • logs: ‘log alert`

  • metric: ‘query alert`

  • network: ‘service check`

  • outlier: ‘query alert`

  • process: ‘service check`

  • rum: ‘rum alert`

  • SLO: ‘slo alert`

  • watchdog: ‘event alert`

  • event-v2: ‘event-v2 alert`

  • audit: ‘audit alert`

  • error-tracking: ‘error-tracking alert`

Note: Synthetic monitors are created through the Synthetics API. See the [Synthetics API] (docs.datadoghq.com/api/latest/synthetics/) documentation for more information.

#### Query Types

**Metric Alert Query**

Example: ‘time_aggr(time_window):space_aggr:metrictags [by key] operator #`

  • time_aggr: avg, sum, max, min, change, or pct_change

  • time_window: ‘last_#m` (with `#` between 1 and 10080 depending on the monitor type) or `last_#h`(with `#` between 1 and 168 depending on the monitor type) or last_1d, or last_1w

  • space_aggr: avg, sum, min, or max

  • tags: one or more tags (comma-separated), or *

  • key: a ‘key’ in key:value tag syntax; defines a separate alert for each tag in the group (multi-alert)

  • operator: <, <=, >, >=, ==, or !=

  • ‘#`: an integer or decimal number used to set the threshold

If you are using the change or pct_change time aggregator, instead use ‘change_aggr(time_aggr(time_window), timeshift):space_aggr:metrictags [by key] operator #` with:

  • change_aggr change, pct_change

  • time_aggr avg, sum, max, min [Learn more](docs.datadoghq.com/monitors/create/types/#define-the-conditions)

  • time_window last_#m (between 1 and 2880 depending on the monitor type), last_#h (between 1 and 48 depending on the monitor type), or last_#d (1 or 2)

  • timeshift #m_ago (5, 10, 15, or 30), #h_ago (1, 2, or 4), or 1d_ago

Use this to create an outlier monitor using the following query: ‘avg(last_30m):outliers(avg:system.cpu.userrole:es-events-data by host, ’dbscan’, 7) > 0`

**Service Check Query**

Example: ‘“check”.over(tags).last(count).by(group).count_by_status()`

  • check name of the check, for example datadog.agent.up

  • tags one or more quoted tags (comma-separated), or “*”. for example: ‘.over(“env:prod”, “role:db”)`; over cannot be blank.

  • count must be at greater than or equal to your max threshold (defined in the options). It is limited to 100.

For example, if you’ve specified to notify on 1 critical, 3 ok, and 2 warn statuses, count should be at least 3.

  • group must be specified for check monitors. Per-check grouping is already explicitly known for some service checks.

For example, Postgres integration monitors are tagged by db, host, and port, and Network monitors by host, instance, and url. See [Service Checks](docs.datadoghq.com/api/latest/service-checks/) documentation for more information.

**Event Alert Query**

Example: ‘events(’sources:nagios status:error,warning priority:normal tags: “string query”‘).rollup(“count”).last(“1h”)“`

  • event, the event query string:

  • string_query free text query to match against event title and text.

  • sources event sources (comma-separated).

  • status event statuses (comma-separated). Valid options: error, warn, and info.

  • priority event priorities (comma-separated). Valid options: low, normal, all.

  • host event reporting host (comma-separated).

  • tags event tags (comma-separated).

  • excluded_tags excluded event tags (comma-separated).

  • rollup the stats roll-up method. count is the only supported method now.

  • last the timeframe to roll up the counts. Examples: 45m, 4h. Supported timeframes: m, h and d. This value should not exceed 48 hours.

NOTE The Event Alert Query is being deprecated and replaced by the Event V2 Alert Query. For more information, see the [Event Migration guide](docs.datadoghq.com/events/guides/migrating_to_new_events_features/).

**Event V2 Alert Query**

Example: ‘events(query).rollup(rollup_method[, measure]).last(time_window) operator #`

  • query The search query - following the [Log search syntax](docs.datadoghq.com/logs/search_syntax/).

  • rollup_method The stats roll-up method - supports count, avg and cardinality.

  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.

  • time_window #m (between 1 and 2880), #h (between 1 and 48).

  • operator ‘<`, `<=`, `>`, `>=`, `==`, or `!=`.

  • ‘#` an integer or decimal number used to set the threshold.

**Process Alert Query**

Example: ‘processes(search).over(tags).rollup(’count’).last(timeframe) operator #‘

  • search free text search string for querying processes.

Matching processes match results on the [Live Processes](docs.datadoghq.com/infrastructure/process/?tab=linuxwindows) page.

  • tags one or more tags (comma-separated)

  • timeframe the timeframe to roll up the counts. Examples: 10m, 4h. Supported timeframes: s, m, h and d

  • operator <, <=, >, >=, ==, or !=

  • ‘#` an integer or decimal number used to set the threshold

**Logs Alert Query**

Example: ‘logs(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #`

  • query The search query - following the [Log search syntax](docs.datadoghq.com/logs/search_syntax/).

  • index_name For multi-index organizations, the log index in which the request is performed.

  • rollup_method The stats roll-up method - supports count, avg and cardinality.

  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.

  • time_window #m (between 1 and 2880), #h (between 1 and 48).

  • operator ‘<`, `<=`, `>`, `>=`, `==`, or `!=`.

  • ‘#` an integer or decimal number used to set the threshold.

**Composite Query**

Example: ‘12345 && 67890`, where 12345 and 67890 are the IDs of non-composite monitors

  • name [required, default = **dynamic, based on query**]: The name of the alert.

  • message [required, default = **dynamic, based on query**]: A message to include with notifications for this monitor.

Email notifications can be sent to specific users by using the same ‘@username’ notation as events.

  • tags [optional, default = **empty list**]: A list of tags to associate with your monitor.

When getting all monitor details via the API, use the monitor_tags argument to filter results by these tags. It is only available via the API and isn’t visible or editable in the Datadog UI.

**SLO Alert Query**

Example: ‘error_budget(“slo_id”).over(“time_window”) operator #`

  • slo_id: The alphanumeric SLO ID of the SLO you are configuring the alert for.

  • time_window: The time window of the SLO target you wish to alert on. Valid options: 7d, 30d, 90d.

  • operator: ‘>=` or `>`

**Audit Alert Query**

Example: ‘audits(query).rollup(rollup_method[, measure]).last(time_window) operator #`

  • query The search query - following the [Log search syntax](docs.datadoghq.com/logs/search_syntax/).

  • rollup_method The stats roll-up method - supports count, avg and cardinality.

  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.

  • time_window #m (between 1 and 2880), #h (between 1 and 48).

  • operator ‘<`, `<=`, `>`, `>=`, `==`, or `!=`.

  • ‘#` an integer or decimal number used to set the threshold.

NOTE Only available on US1-FED and in closed beta on US1, EU, US3, and US5.

**CI Pipelines Alert Query**

Example: ‘ci-pipelines(query).rollup(rollup_method[, measure]).last(time_window) operator #`

  • query The search query - following the [Log search syntax](docs.datadoghq.com/logs/search_syntax/).

  • rollup_method The stats roll-up method - supports count, avg, and cardinality.

  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.

  • time_window #m (between 1 and 2880), #h (between 1 and 48).

  • operator ‘<`, `<=`, `>`, `>=`, `==`, or `!=`.

  • ‘#` an integer or decimal number used to set the threshold.

NOTE CI Pipeline monitors are in alpha on US1, EU, US3 and US5.

**CI Tests Alert Query**

Example: ‘ci-tests(query).rollup(rollup_method[, measure]).last(time_window) operator #`

  • query The search query - following the [Log search syntax](docs.datadoghq.com/logs/search_syntax/).

  • rollup_method The stats roll-up method - supports count, avg, and cardinality.

  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.

  • time_window #m (between 1 and 2880), #h (between 1 and 48).

  • operator ‘<`, `<=`, `>`, `>=`, `==`, or `!=`.

  • ‘#` an integer or decimal number used to set the threshold.

NOTE CI Test monitors are available only in closed beta on US1, EU, US3 and US5.

**Error Tracking Alert Query**

Example(RUM): ‘error-tracking-rum(query).rollup(rollup_method[, measure]).last(time_window) operator #` Example(APM Traces): `error-tracking-traces(query).rollup(rollup_method[, measure]).last(time_window) operator #`

  • query The search query - following the [Log search syntax](docs.datadoghq.com/logs/search_syntax/).

  • rollup_method The stats roll-up method - supports count, avg, and cardinality.

  • measure For avg and cardinality rollup_method - specify the measure or the facet name you want to use.

  • time_window #m (between 1 and 2880), #h (between 1 and 48).

  • operator ‘<`, `<=`, `>`, `>=`, `==`, or `!=`.

  • ‘#` an integer or decimal number used to set the threshold.

Parameters:

  • body (Monitor)

    Create a monitor request body.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Monitor, Integer, Hash)>)

    Monitor data, response status code and response headers



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 291

def create_monitor_with_http_info(body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.create_monitor ...'
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling MonitorsAPI.create_monitor"
  end
  # resource path
  local_var_path = '/api/v1/monitor'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'Monitor'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :create_monitor,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#create_monitor\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_monitor(monitor_id, opts = {}) ⇒ Object

Delete a monitor.



346
347
348
349
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 346

def delete_monitor(monitor_id, opts = {})
  data, _status_code, _headers = delete_monitor_with_http_info(monitor_id, opts)
  data
end

#delete_monitor_with_http_info(monitor_id, opts = {}) ⇒ Array<(DeletedMonitor, Integer, Hash)>

Delete a monitor.

Delete the specified monitor

Parameters:

  • monitor_id (Integer)

    The ID of the monitor.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :force (String)

    Delete the monitor even if it’s referenced by other resources (for example SLO, composite monitor).

Returns:

  • (Array<(DeletedMonitor, Integer, Hash)>)

    DeletedMonitor data, response status code and response headers



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 359

def delete_monitor_with_http_info(monitor_id, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.delete_monitor ...'
  end
  # verify the required parameter 'monitor_id' is set
  if @api_client.config.client_side_validation && monitor_id.nil?
    fail ArgumentError, "Missing the required parameter 'monitor_id' when calling MonitorsAPI.delete_monitor"
  end
  # resource path
  local_var_path = '/api/v1/monitor/{monitor_id}'.sub('{monitor_id}', CGI.escape(monitor_id.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'force'] = opts[:'force'] if !opts[:'force'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DeletedMonitor'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :delete_monitor,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#delete_monitor\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_monitor(monitor_id, opts = {}) ⇒ Object

Get a monitor’s details.



413
414
415
416
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 413

def get_monitor(monitor_id, opts = {})
  data, _status_code, _headers = get_monitor_with_http_info(monitor_id, opts)
  data
end

#get_monitor_with_http_info(monitor_id, opts = {}) ⇒ Array<(Monitor, Integer, Hash)>

Get a monitor’s details.

Get details about the specified monitor from your organization.

Parameters:

  • monitor_id (Integer)

    The ID of the monitor

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :group_states (String)

    When specified, shows additional information about the group states. Choose one or more from all, alert, warn, and ‘no data`.

Returns:

  • (Array<(Monitor, Integer, Hash)>)

    Monitor data, response status code and response headers



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 426

def get_monitor_with_http_info(monitor_id, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.get_monitor ...'
  end
  # verify the required parameter 'monitor_id' is set
  if @api_client.config.client_side_validation && monitor_id.nil?
    fail ArgumentError, "Missing the required parameter 'monitor_id' when calling MonitorsAPI.get_monitor"
  end
  # resource path
  local_var_path = '/api/v1/monitor/{monitor_id}'.sub('{monitor_id}', CGI.escape(monitor_id.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'group_states'] = opts[:'group_states'] if !opts[:'group_states'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Monitor'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :get_monitor,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#get_monitor\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_monitors(opts = {}) ⇒ Object

Get all monitor details.



480
481
482
483
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 480

def list_monitors(opts = {})
  data, _status_code, _headers = list_monitors_with_http_info(opts)
  data
end

#list_monitors_with_http_info(opts = {}) ⇒ Array<(Array<Monitor>, Integer, Hash)>

Get all monitor details.

Get details about the specified monitor from your organization.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :group_states (String)

    When specified, shows additional information about the group states. Choose one or more from all, alert, warn, and ‘no data`.

  • :name (String)

    A string to filter monitors by name.

  • :tags (String)

    A comma separated list indicating what tags, if any, should be used to filter the list of monitors by scope. For example, host:host0.

  • :monitor_tags (String)

    A comma separated list indicating what service and/or custom tags, if any, should be used to filter the list of monitors. Tags created in the Datadog UI automatically have the service key prepended. For example, service:my-app.

  • :with_downtimes (Boolean)

    If this argument is set to true, then the returned data includes all current active downtimes for each monitor.

  • :id_offset (Integer)

    Use this parameter for paginating through large sets of monitors. Start with a value of zero, make a request, set the value to the last ID of result set, and then repeat until the response is empty.

  • :page (Integer)

    The page to start paginating from. If this argument is not specified, the request returns all monitors without pagination.

  • :page_size (Integer)

    The number of monitors to return per page. If the page argument is not specified, the default behavior returns all monitors without a page_size limit. However, if page is specified and page_size is not, the argument defaults to 100.

Returns:

  • (Array<(Array<Monitor>, Integer, Hash)>)

    Array<Monitor> data, response status code and response headers



499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 499

def list_monitors_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.list_monitors ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling MonitorsAPI.list_monitors, must be smaller than or equal to 1000.'
  end
  # resource path
  local_var_path = '/api/v1/monitor'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'group_states'] = opts[:'group_states'] if !opts[:'group_states'].nil?
  query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'monitor_tags'] = opts[:'monitor_tags'] if !opts[:'monitor_tags'].nil?
  query_params[:'with_downtimes'] = opts[:'with_downtimes'] if !opts[:'with_downtimes'].nil?
  query_params[:'id_offset'] = opts[:'id_offset'] if !opts[:'id_offset'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<Monitor>'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :list_monitors,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#list_monitors\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_monitor_groups(opts = {}) ⇒ Object

Monitors group search.



559
560
561
562
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 559

def search_monitor_groups(opts = {})
  data, _status_code, _headers = search_monitor_groups_with_http_info(opts)
  data
end

#search_monitor_groups_with_http_info(opts = {}) ⇒ Array<(MonitorGroupSearchResponse, Integer, Hash)>

Monitors group search.

Search and filter your monitor groups details.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :query (String)

    After entering a search query in your [Manage Monitor page] use the query parameter value in the URL of the page as value for this parameter. Consult the dedicated [manage monitor documentation] page to learn more. The query can contain any number of space-separated monitor attributes, for instance ‘query=“type:metric status:alert”`. [1]: app.datadoghq.com/monitors/manage [2]: /monitors/manage/#find-the-monitors

  • :page (Integer)

    Page to start paginating from.

  • :per_page (Integer)

    Number of monitors to return per page.

  • :sort (String)

    String for sort order, composed of field and sort order separate by a comma, for example ‘name,asc`. Supported sort directions: asc, desc. Supported fields: * name * status * tags

Returns:

  • (Array<(MonitorGroupSearchResponse, Integer, Hash)>)

    MonitorGroupSearchResponse data, response status code and response headers



574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 574

def search_monitor_groups_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.search_monitor_groups ...'
  end
  # resource path
  local_var_path = '/api/v1/monitor/groups/search'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'MonitorGroupSearchResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :search_monitor_groups,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#search_monitor_groups\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_monitors(opts = {}) ⇒ Object

Monitors search.



627
628
629
630
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 627

def search_monitors(opts = {})
  data, _status_code, _headers = search_monitors_with_http_info(opts)
  data
end

#search_monitors_with_http_info(opts = {}) ⇒ Array<(MonitorSearchResponse, Integer, Hash)>

Monitors search.

Search and filter your monitors details.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :query (String)

    After entering a search query in your [Manage Monitor page] use the query parameter value in the URL of the page as value for this parameter. Consult the dedicated [manage monitor documentation] page to learn more. The query can contain any number of space-separated monitor attributes, for instance ‘query=“type:metric status:alert”`. [1]: app.datadoghq.com/monitors/manage [2]: /monitors/manage/#find-the-monitors

  • :page (Integer)

    Page to start paginating from.

  • :per_page (Integer)

    Number of monitors to return per page.

  • :sort (String)

    String for sort order, composed of field and sort order separate by a comma, for example ‘name,asc`. Supported sort directions: asc, desc. Supported fields: * name * status * tags

Returns:

  • (Array<(MonitorSearchResponse, Integer, Hash)>)

    MonitorSearchResponse data, response status code and response headers



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 642

def search_monitors_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.search_monitors ...'
  end
  # resource path
  local_var_path = '/api/v1/monitor/search'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'MonitorSearchResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :search_monitors,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#search_monitors\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_monitor(monitor_id, body, opts = {}) ⇒ Object

Edit a monitor.



695
696
697
698
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 695

def update_monitor(monitor_id, body, opts = {})
  data, _status_code, _headers = update_monitor_with_http_info(monitor_id, body, opts)
  data
end

#update_monitor_with_http_info(monitor_id, body, opts = {}) ⇒ Array<(Monitor, Integer, Hash)>

Edit a monitor.

Edit the specified monitor.

Parameters:

  • monitor_id (Integer)

    The ID of the monitor.

  • body (MonitorUpdateRequest)

    Edit a monitor request body.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Monitor, Integer, Hash)>)

    Monitor data, response status code and response headers



708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 708

def update_monitor_with_http_info(monitor_id, body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.update_monitor ...'
  end
  # verify the required parameter 'monitor_id' is set
  if @api_client.config.client_side_validation && monitor_id.nil?
    fail ArgumentError, "Missing the required parameter 'monitor_id' when calling MonitorsAPI.update_monitor"
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling MonitorsAPI.update_monitor"
  end
  # resource path
  local_var_path = '/api/v1/monitor/{monitor_id}'.sub('{monitor_id}', CGI.escape(monitor_id.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'Monitor'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :update_monitor,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#update_monitor\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#validate_existing_monitor(monitor_id, body, opts = {}) ⇒ Object

Validate an existing monitor.



767
768
769
770
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 767

def validate_existing_monitor(monitor_id, body, opts = {})
  data, _status_code, _headers = validate_existing_monitor_with_http_info(monitor_id, body, opts)
  data
end

#validate_existing_monitor_with_http_info(monitor_id, body, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Validate an existing monitor.

Validate the monitor provided in the request.

Parameters:

  • monitor_id (Integer)

    The ID of the monitor

  • body (Monitor)

    Monitor request object

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 780

def validate_existing_monitor_with_http_info(monitor_id, body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.validate_existing_monitor ...'
  end
  # verify the required parameter 'monitor_id' is set
  if @api_client.config.client_side_validation && monitor_id.nil?
    fail ArgumentError, "Missing the required parameter 'monitor_id' when calling MonitorsAPI.validate_existing_monitor"
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling MonitorsAPI.validate_existing_monitor"
  end
  # resource path
  local_var_path = '/api/v1/monitor/{monitor_id}/validate'.sub('{monitor_id}', CGI.escape(monitor_id.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :validate_existing_monitor,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#validate_existing_monitor\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#validate_monitor(body, opts = {}) ⇒ Object

Validate a monitor.



839
840
841
842
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 839

def validate_monitor(body, opts = {})
  data, _status_code, _headers = validate_monitor_with_http_info(body, opts)
  data
end

#validate_monitor_with_http_info(body, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Validate a monitor.

Validate the monitor provided in the request.

Parameters:

  • body (Monitor)

    Monitor request object

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
# File 'lib/datadog_api_client/v1/api/monitors_api.rb', line 851

def validate_monitor_with_http_info(body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MonitorsAPI.validate_monitor ...'
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling MonitorsAPI.validate_monitor"
  end
  # resource path
  local_var_path = '/api/v1/monitor/validate'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  new_options = opts.merge(
    :operation => :validate_monitor,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MonitorsAPI#validate_monitor\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end