class DatadogAPIClient::V1::MonitorOptions

List of options associated with your monitor.

Attributes

aggregation[RW]
device_ids[RW]

IDs of the device the Synthetics monitor is running on.

enable_logs_sample[RW]

Whether or not to send a log sample when the log monitor triggers.

escalation_message[RW]

We recommend using the [is_renotify](docs.datadoghq.com/monitors/notifications/?tab=is_alert#renotify), block in the original message instead. A message to include with a re-notification. Supports the `@username` notification we allow elsewhere. Not applicable if `renotify_interval` is `None`.

evaluation_delay[RW]

Time (in seconds) to delay evaluation, as a non-negative integer. For example, if the value is set to `300` (5min), the timeframe is set to `last_5m` and the time is 7:00, the monitor evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.

groupby_simple_monitor[RW]

Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.

include_tags[RW]

A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title. Examples - If `True`, `[Triggered on {host:h1}] Monitor Title` - If `False`, `[Triggered] Monitor Title`

locked[RW]

Whether or not the monitor is locked (only editable by creator and admins).

min_failure_duration[RW]

How long the test should be in failure before alerting (integer, number of seconds, max 7200).

min_location_failed[RW]

The minimum number of locations in failure at the same time during at least one moment in the `min_failure_duration` period (`min_location_failed` and `min_failure_duration` are part of the advanced alerting rules - integer, >= 1).

new_host_delay[RW]

Time (in seconds) to allow a host to boot and applications to fully start before starting the evaluation of monitor results. Should be a non negative integer.

no_data_timeframe[RW]

The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for metric alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for metric alerts, and 24 hours is used for service checks.

notify_audit[RW]

A Boolean indicating whether tagged users is notified on changes to this monitor.

notify_no_data[RW]

A Boolean indicating whether this monitor notifies when data stops reporting.

renotify_interval[RW]

The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.

require_full_window[RW]

A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to `false` for sparse metrics, otherwise some evaluations are skipped. Default is false.

silenced[RW]

Information about the downtime applied to the monitor.

synthetics_check_id[RW]

ID of the corresponding Synthetic check.

threshold_windows[RW]
thresholds[RW]
timeout_h[RW]

The number of hours of the monitor not reporting data before it automatically resolves from a triggered state.

Public Class Methods

acceptable_attributes() click to toggle source

Returns all the JSON keys this model knows about

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 110
def self.acceptable_attributes
  attribute_map.values
end
attribute_map() click to toggle source

Attribute mapping from ruby-style variable name to JSON key.

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 83
def self.attribute_map
  {
    :'aggregation' => :'aggregation',
    :'device_ids' => :'device_ids',
    :'enable_logs_sample' => :'enable_logs_sample',
    :'escalation_message' => :'escalation_message',
    :'evaluation_delay' => :'evaluation_delay',
    :'groupby_simple_monitor' => :'groupby_simple_monitor',
    :'include_tags' => :'include_tags',
    :'locked' => :'locked',
    :'min_failure_duration' => :'min_failure_duration',
    :'min_location_failed' => :'min_location_failed',
    :'new_host_delay' => :'new_host_delay',
    :'no_data_timeframe' => :'no_data_timeframe',
    :'notify_audit' => :'notify_audit',
    :'notify_no_data' => :'notify_no_data',
    :'renotify_interval' => :'renotify_interval',
    :'require_full_window' => :'require_full_window',
    :'silenced' => :'silenced',
    :'synthetics_check_id' => :'synthetics_check_id',
    :'threshold_windows' => :'threshold_windows',
    :'thresholds' => :'thresholds',
    :'timeout_h' => :'timeout_h'
  }
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 353
def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 157
def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::MonitorOptions` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::MonitorOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'aggregation')
    self.aggregation = attributes[:'aggregation']
  end

  if attributes.key?(:'device_ids')
    if (value = attributes[:'device_ids']).is_a?(Array)
      self.device_ids = value
    end
  end

  if attributes.key?(:'enable_logs_sample')
    self.enable_logs_sample = attributes[:'enable_logs_sample']
  end

  if attributes.key?(:'escalation_message')
    self.escalation_message = attributes[:'escalation_message']
  else
    self.escalation_message = 'none'
  end

  if attributes.key?(:'evaluation_delay')
    self.evaluation_delay = attributes[:'evaluation_delay']
  end

  if attributes.key?(:'groupby_simple_monitor')
    self.groupby_simple_monitor = attributes[:'groupby_simple_monitor']
  end

  if attributes.key?(:'include_tags')
    self.include_tags = attributes[:'include_tags']
  else
    self.include_tags = true
  end

  if attributes.key?(:'locked')
    self.locked = attributes[:'locked']
  end

  if attributes.key?(:'min_failure_duration')
    self.min_failure_duration = attributes[:'min_failure_duration']
  else
    self.min_failure_duration = 0
  end

  if attributes.key?(:'min_location_failed')
    self.min_location_failed = attributes[:'min_location_failed']
  else
    self.min_location_failed = 1
  end

  if attributes.key?(:'new_host_delay')
    self.new_host_delay = attributes[:'new_host_delay']
  else
    self.new_host_delay = 300
  end

  if attributes.key?(:'no_data_timeframe')
    self.no_data_timeframe = attributes[:'no_data_timeframe']
  end

  if attributes.key?(:'notify_audit')
    self.notify_audit = attributes[:'notify_audit']
  else
    self.notify_audit = false
  end

  if attributes.key?(:'notify_no_data')
    self.notify_no_data = attributes[:'notify_no_data']
  else
    self.notify_no_data = false
  end

  if attributes.key?(:'renotify_interval')
    self.renotify_interval = attributes[:'renotify_interval']
  end

  if attributes.key?(:'require_full_window')
    self.require_full_window = attributes[:'require_full_window']
  end

  if attributes.key?(:'silenced')
    if (value = attributes[:'silenced']).is_a?(Hash)
      self.silenced = value
    end
  end

  if attributes.key?(:'synthetics_check_id')
    self.synthetics_check_id = attributes[:'synthetics_check_id']
  end

  if attributes.key?(:'threshold_windows')
    self.threshold_windows = attributes[:'threshold_windows']
  end

  if attributes.key?(:'thresholds')
    self.thresholds = attributes[:'thresholds']
  end

  if attributes.key?(:'timeout_h')
    self.timeout_h = attributes[:'timeout_h']
  end
end
openapi_nullable() click to toggle source

List of attributes with nullable: true

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 142
def self.openapi_nullable
  Set.new([
    :'evaluation_delay',
    :'min_failure_duration',
    :'min_location_failed',
    :'new_host_delay',
    :'no_data_timeframe',
    :'renotify_interval',
    :'synthetics_check_id',
    :'timeout_h'
  ])
end
openapi_types() click to toggle source

Attribute type mapping.

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 115
def self.openapi_types
  {
    :'aggregation' => :'MonitorOptionsAggregation',
    :'device_ids' => :'Array<MonitorDeviceID>',
    :'enable_logs_sample' => :'Boolean',
    :'escalation_message' => :'String',
    :'evaluation_delay' => :'Integer',
    :'groupby_simple_monitor' => :'Boolean',
    :'include_tags' => :'Boolean',
    :'locked' => :'Boolean',
    :'min_failure_duration' => :'Integer',
    :'min_location_failed' => :'Integer',
    :'new_host_delay' => :'Integer',
    :'no_data_timeframe' => :'Integer',
    :'notify_audit' => :'Boolean',
    :'notify_no_data' => :'Boolean',
    :'renotify_interval' => :'Integer',
    :'require_full_window' => :'Boolean',
    :'silenced' => :'Hash<String, Integer>',
    :'synthetics_check_id' => :'String',
    :'threshold_windows' => :'MonitorThresholdWindowOptions',
    :'thresholds' => :'MonitorThresholds',
    :'timeout_h' => :'Integer'
  }
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 312
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      aggregation == o.aggregation &&
      device_ids == o.device_ids &&
      enable_logs_sample == o.enable_logs_sample &&
      escalation_message == o.escalation_message &&
      evaluation_delay == o.evaluation_delay &&
      groupby_simple_monitor == o.groupby_simple_monitor &&
      include_tags == o.include_tags &&
      locked == o.locked &&
      min_failure_duration == o.min_failure_duration &&
      min_location_failed == o.min_location_failed &&
      new_host_delay == o.new_host_delay &&
      no_data_timeframe == o.no_data_timeframe &&
      notify_audit == o.notify_audit &&
      notify_no_data == o.notify_no_data &&
      renotify_interval == o.renotify_interval &&
      require_full_window == o.require_full_window &&
      silenced == o.silenced &&
      synthetics_check_id == o.synthetics_check_id &&
      threshold_windows == o.threshold_windows &&
      thresholds == o.thresholds &&
      timeout_h == o.timeout_h
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 383
def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when :Array
    # generic array, return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = DatadogAPIClient::V1.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end
_to_hash(value) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 457
def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 360
def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end
eql?(o) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 340
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Integer] Hash code

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 346
def hash
  [aggregation, device_ids, enable_logs_sample, escalation_message, evaluation_delay, groupby_simple_monitor, include_tags, locked, min_failure_duration, min_location_failed, new_host_delay, no_data_timeframe, notify_audit, notify_no_data, renotify_interval, require_full_window, silenced, synthetics_check_id, threshold_windows, thresholds, timeout_h].hash
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 275
def list_invalid_properties
  invalid_properties = Array.new
  if !@min_failure_duration.nil? && @min_failure_duration > 7200
    invalid_properties.push('invalid value for "min_failure_duration", must be smaller than or equal to 7200.')
  end

  if !@min_failure_duration.nil? && @min_failure_duration < 0
    invalid_properties.push('invalid value for "min_failure_duration", must be greater than or equal to 0.')
  end

  invalid_properties
end
min_failure_duration=(min_failure_duration) click to toggle source

Custom attribute writer method with validation @param [Object] min_failure_duration Value to be assigned

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 298
def min_failure_duration=(min_failure_duration)
  if !min_failure_duration.nil? && min_failure_duration > 7200
    fail ArgumentError, 'invalid value for "min_failure_duration", must be smaller than or equal to 7200.'
  end

  if !min_failure_duration.nil? && min_failure_duration < 0
    fail ArgumentError, 'invalid value for "min_failure_duration", must be greater than or equal to 0.'
  end

  @min_failure_duration = min_failure_duration
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 433
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 439
def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end
to_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 427
def to_s
  to_hash.to_s
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/datadog_api_client/v1/models/monitor_options.rb, line 290
def valid?
  return false if !@min_failure_duration.nil? && @min_failure_duration > 7200
  return false if !@min_failure_duration.nil? && @min_failure_duration < 0
  true
end