Sha256: 5e5e6de832ead07aacb07af15ba1defd03ac6de12f9a76bf2f0a0cf21c8f580b

Contents?: true

Size: 1.88 KB

Versions: 19

Compression:

Stored size: 1.88 KB

Contents

# Create a ci-tests formula and functions monitor returns "OK" response

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

body = DatadogAPIClient::V1::Monitor.new({
  name: "Example-Monitor",
  type: DatadogAPIClient::V1::MonitorType::CI_TESTS_ALERT,
  query: 'formula("query1 / query2 * 100").last("15m") >= 0.8',
  message: "some message Notify: @hipchat-channel",
  tags: [
    "test:examplemonitor",
    "env:ci",
  ],
  priority: 3,
  options: DatadogAPIClient::V1::MonitorOptions.new({
    thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
      critical: 0.8,
    }),
    variables: [
      DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinition.new({
        data_source: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventsDataSource::CI_TESTS,
        name: "query1",
        search: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinitionSearch.new({
          query: "@test.status:fail",
        }),
        indexes: [
          "*",
        ],
        compute: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinitionCompute.new({
          aggregation: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventAggregation::COUNT,
        }),
        group_by: [],
      }),
      DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinition.new({
        data_source: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventsDataSource::CI_TESTS,
        name: "query2",
        search: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinitionSearch.new({
          query: "",
        }),
        indexes: [
          "*",
        ],
        compute: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinitionCompute.new({
          aggregation: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventAggregation::COUNT,
        }),
        group_by: [],
      }),
    ],
  }),
})
p api_instance.create_monitor(body)

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
datadog_api_client-2.28.1 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.27.1 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.26.1 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.26.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.25.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.24.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.22.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.21.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.20.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.19.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.18.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.17.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.16.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.15.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.14.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.13.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.12.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.11.0 examples/v1/monitors/CreateMonitor_1969035628.rb
datadog_api_client-2.10.0 examples/v1/monitors/CreateMonitor_1969035628.rb