Sha256: d4016d810b9c27e1e1356c0663cab767d36a12b1aa33c8153174c1728675ac71

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# Create a metric monitor with a custom schedule returns "OK" response

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

body = DatadogAPIClient::V1::Monitor.new({
  message: "some message Notify: @hipchat-channel",
  name: "Example-Monitor",
  query: "avg(current_1mo):avg:system.load.5{*} > 0.5",
  tags: [],
  options: DatadogAPIClient::V1::MonitorOptions.new({
    thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
      critical: 0.5,
    }),
    notify_audit: false,
    on_missing_data: DatadogAPIClient::V1::OnMissingDataOption::DEFAULT,
    include_tags: false,
    scheduling_options: DatadogAPIClient::V1::MonitorOptionsSchedulingOptions.new({
      evaluation_window: DatadogAPIClient::V1::MonitorOptionsSchedulingOptionsEvaluationWindow.new({
        day_starts: "04:00",
        month_starts: 1,
      }),
      custom_schedule: DatadogAPIClient::V1::MonitorOptionsCustomSchedule.new({
        recurrences: [
          DatadogAPIClient::V1::MonitorOptionsCustomScheduleRecurrence.new({
            rrule: "FREQ=DAILY;INTERVAL=1",
            timezone: "America/Los_Angeles",
            start: "2024-10-26T09:13:00",
          }),
        ],
      }),
    }),
  }),
  type: DatadogAPIClient::V1::MonitorType::QUERY_ALERT,
})
p api_instance.create_monitor(body)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datadog_api_client-2.16.0 examples/v1/monitors/CreateMonitor_1539578087.rb