Sha256: e78d8cd8857ef73c6bbb41fd4a0cb8003bf05f584576c2ec86c3c2c964f8ae58

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

# Create a detection rule returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new

body = DatadogAPIClient::V2::SecurityMonitoringStandardRuleCreatePayload.new({
  name: "Example-Security-Monitoring",
  queries: [
    DatadogAPIClient::V2::SecurityMonitoringStandardRuleQuery.new({
      query: "@test:true",
      aggregation: DatadogAPIClient::V2::SecurityMonitoringRuleQueryAggregation::COUNT,
      group_by_fields: [],
      distinct_fields: [],
      metric: "",
    }),
  ],
  filters: [],
  cases: [
    DatadogAPIClient::V2::SecurityMonitoringRuleCaseCreate.new({
      name: "",
      status: DatadogAPIClient::V2::SecurityMonitoringRuleSeverity::INFO,
      condition: "a > 0",
      notifications: [],
    }),
  ],
  options: DatadogAPIClient::V2::SecurityMonitoringRuleOptions.new({
    evaluation_window: DatadogAPIClient::V2::SecurityMonitoringRuleEvaluationWindow::FIFTEEN_MINUTES,
    keep_alive: DatadogAPIClient::V2::SecurityMonitoringRuleKeepAlive::ONE_HOUR,
    max_signal_duration: DatadogAPIClient::V2::SecurityMonitoringRuleMaxSignalDuration::ONE_DAY,
  }),
  message: "Test rule",
  tags: [],
  is_enabled: true,
  type: DatadogAPIClient::V2::SecurityMonitoringRuleTypeCreate::LOG_DETECTION,
  reference_tables: [
    DatadogAPIClient::V2::SecurityMonitoringReferenceTable.new({
      table_name: "synthetics_test_reference_table_dont_delete",
      column_name: "value",
      log_field_path: "testtag",
      check_presence: true,
      rule_query_name: "a",
    }),
  ],
})
p api_instance.create_security_monitoring_rule(body)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datadog_api_client-2.29.1 examples/v2/security-monitoring/CreateSecurityMonitoringRule.rb
datadog_api_client-2.28.1 examples/v2/security-monitoring/CreateSecurityMonitoringRule.rb
datadog_api_client-2.27.1 examples/v2/security-monitoring/CreateSecurityMonitoringRule.rb