Sha256: 8a1cb41544414fcf7be547e23a6f26682336de0505a2e7a18cda374b702500eb

Contents?: true

Size: 1.86 KB

Versions: 6

Compression:

Stored size: 1.86 KB

Contents

# Create a detection rule with detection method 'third_party' returns "OK" response

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

body = DatadogAPIClient::V2::SecurityMonitoringStandardRuleCreatePayload.new({
  name: "Example-Security-Monitoring",
  type: DatadogAPIClient::V2::SecurityMonitoringRuleTypeCreate::LOG_DETECTION,
  is_enabled: true,
  third_party_cases: [
    DatadogAPIClient::V2::SecurityMonitoringThirdPartyRuleCaseCreate.new({
      query: "status:error",
      name: "high",
      status: DatadogAPIClient::V2::SecurityMonitoringRuleSeverity::HIGH,
    }),
    DatadogAPIClient::V2::SecurityMonitoringThirdPartyRuleCaseCreate.new({
      query: "status:info",
      name: "low",
      status: DatadogAPIClient::V2::SecurityMonitoringRuleSeverity::LOW,
    }),
  ],
  queries: [],
  cases: [],
  message: "This is a third party rule",
  options: DatadogAPIClient::V2::SecurityMonitoringRuleOptions.new({
    detection_method: DatadogAPIClient::V2::SecurityMonitoringRuleDetectionMethod::THIRD_PARTY,
    keep_alive: DatadogAPIClient::V2::SecurityMonitoringRuleKeepAlive::ZERO_MINUTES,
    max_signal_duration: DatadogAPIClient::V2::SecurityMonitoringRuleMaxSignalDuration::ZERO_MINUTES,
    third_party_rule_options: DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions.new({
      default_status: DatadogAPIClient::V2::SecurityMonitoringRuleSeverity::INFO,
      root_queries: [
        DatadogAPIClient::V2::SecurityMonitoringThirdPartyRootQuery.new({
          query: "source:guardduty @details.alertType:*EC2*",
          group_by_fields: [
            "instance-id",
          ],
        }),
        DatadogAPIClient::V2::SecurityMonitoringThirdPartyRootQuery.new({
          query: "source:guardduty",
          group_by_fields: [],
        }),
      ],
    }),
  }),
})
p api_instance.create_security_monitoring_rule(body)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datadog_api_client-2.25.0 examples/v2/security-monitoring/CreateSecurityMonitoringRule_3367706049.rb
datadog_api_client-2.24.0 examples/v2/security-monitoring/CreateSecurityMonitoringRule_3367706049.rb
datadog_api_client-2.22.0 examples/v2/security-monitoring/CreateSecurityMonitoringRule_3367706049.rb
datadog_api_client-2.21.0 examples/v2/security-monitoring/CreateSecurityMonitoringRule_3367706049.rb
datadog_api_client-2.20.0 examples/v2/security-monitoring/CreateSecurityMonitoringRule_3367706049.rb
datadog_api_client-2.19.0 examples/v2/security-monitoring/CreateSecurityMonitoringRule_3367706049.rb