Updated on 2024-05-20 GMT+08:00

Creating a killOp Rule

API Description

This API is used to create a killOp rule.

Restrictions

  • This API applies only to replica set and cluster instances.
  • This API is available only for DDS 3.4 or later.
  • This API is available only for an instance node with 4 or more vCPUs.
  • A maximum of 10 killOp rules can be created for a DB instance.
  • The rule is disabled after being created.

URI

  • URI format

    POST https://{Endpoint}/v3/{project_id}/instances/{instance_id}/kill-op-rule

  • URI example

    https://dds.ap-southeast-1.myhuaweicloud.com/v3/2900b7b8d03e4619b8db8d43bc6234ee/instances/6390733773d64a748f3a7bc88df22384in02/kill-op-rule

    Table 1 Request parameters

    Parameter

    Mandatory

    Type

    Description

    X-Auth-Token

    Yes

    String

    User token obtained from IAM. For details, see Authentication.

    project_id

    Yes

    String

    Project ID of a tenant in a region.

    instance_id

    Yes

    String

    Instance ID, which can be obtained by calling the API described in Querying Instances and Details. If you do not have an instance, call the API described in Creating a DB Instance to create one.

Requests

  • Parameter description
    Table 2 Query parameters

    Parameter

    Mandatory

    Type

    Description

    operation_types

    Yes

    Array of strings

    SQL type. A maximum of six statement types can be selected at a time. If multiple types are selected, the rule takes effect when any type is matched.
    • insert: operation for inserting data.
    • update: operation for updating data.
    • query: operation for querying data.
    • command: command operation.
    • remove: operation for deleting data.
    • getmore: operation for obtaining more data.

    namespaces

    No

    Array of strings

    Namespace of a table. The value is in the format of database_name or database_name.table_name. If multiple namespaces are configured at the same time, the rule takes effect when any namespace is matched.
    • Currently, only one namespace can be configured.
    • This parameter can be left empty, indicating that this rule has no restrictions on table namespaces.
    • If this parameter is set to a database name, this rule applies to operations on all collections in the database.
    • If this parameter is set to a value in the format of database_name.collection_name, this rule only applies to operations on the collection.

    client_ips

    No

    Array of strings

    Client IP address.
    • Only IPv4 is supported.
    • This parameter can be left empty, indicating that this rule has no restrictions on client IP addresses.
    • A maximum of five IP addresses can be configured at a time. If multiple IP addresses are configured, the rule takes effect when any IP address is matched.

    plan_summary

    No

    String

    Execution plan. By default, this parameter is left blank, indicating that this rule has no restrictions on execution plans.
    • COLLSCAN
    • SORT_KEY_GENERATOR
    • SKIP
    • LIMIT
    • GEO_NEAR_2DSPHERE
    • GEO_NEAR_2D
    • AGGREGATE
    • OR

    max_concurrency

    No

    Integer

    Maximum number of concurrent SQL statements.

    • The value cannot be a negative number. This parameter can be left empty. The default value is 0, indicating that this rule has no restrictions on the maximum number of concurrent SQL statements. The value ranges from 1 to 100000.
    • The values of max_concurrency and secs_running cannot be 0 at the same time.

    secs_running

    No

    Integer

    Maximum execution duration of a single SQL statement.

    • This parameter can be left empty. The default value is 0, indicating that this rule has no restrictions on the maximum execution duration of a single SQL statement. The unit is second. The value ranges from 2 to 86400.
    • The values of secs_running and max_concurrency cannot be 0 at the same time.

    node_type

    Yes

    String

    Node type.
    • mongos_shard indicates that this rule applies to both mongos and shard nodes.
    • mongos indicates that this rule only applies to the mongos node in a cluster.
    • shard indicates that this rule only applies to the shard node in a cluster.
    • replica indicates that this rule applies to replica sets.
  • Example request
    { 
       "operation_types" : [ "query", "insert" ], 
       "namespaces" : [ "db.collections" ], 
       "client_ips" : [ "172.168.201.144" ], 
       "plan_summary" : "COLLSCAN", 
       "max_concurrency" : 0, 
       "secs_running" : 5, 
       "node_type" : "replica" 
     }

Responses

  • Parameter description

    None

  • Example response

    None

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.