Updated on 2024-11-29 GMT+08:00

Adding a Real-Time Query Variable

Scenario

The platform allows you to do real-time query variable calculation with PL/SQL syntax. You can define real-time query variables in the following scenarios:

  • If the dimension of a variable in a rule does not match the rule dimension, you need to extract the variable from the rule and define it as a real-time query variable. Otherwise, query performance is reduced because cross-dimension MOTService query occurs during rule calculation.
  • Variables shared by multiple rules can be extracted and defined as real-time query variables to reduce the number of repeat calculations.

The ANSI standard SQL syntax is used for defining real-time query variables to query data in the last 15 days. You can reference event variables and batch variables customized on the platform in your definition to query data tables (such as POC tables and blacklists and whitelists) other than the current data source. The definition can be submitted only after passing the syntax check. This reduces the number of error variables caused by human factors.

Procedure

  1. Log in to the RTD web UI as a service user and select the tenant to be operated. For details, see section Accessing the RTDService Web UI.
  2. Choose Business Management > Variable and Rule Configuration > Real-time Query Variables.
  3. Click Add and set the parameters required for defining the real-time query variables.

    Table 1 Parameters for real-time query variables

    Parameter

    Description

    Event Source Type

    Type of the event source to which the variable belongs

    Dimension Name

    Dimension of to the variable

    Name

    Name of the variable

    NOTE:
    • The prefix of the variable name for real-time query is rv_.
    • The variable name is case insensitive and must start with a letter or underscore (_). The value must contain 4 to 30 characters, including letters, digits, and underscores (_).

    Type

    Variable type. The options are string, long, integer, double, boolean and timestamp.

    Default Value

    Optional. Set the default value of the variable.

    Variable Type

    Variable rule type. Available values include:

    • General variable: The variable can be used to calculate each packet (all traffic) after been brought online.
    • Gray variable: You need to set the traffic proportion.
      • If the variable is brought online before the rule is released, it uses the configured traffic proportion for calculation.
      • If the variable is brought online after the rule is released, it calculates each packet (all traffic). To do so, click Publish Rule in the Operation column of the desired variable, click OK, and then bring the variable online.

    Traffic Percentage

    Data distribution ratio. This parameter is mandatory when Gray Variable is selected. The value is an integer and the range is (0, 99].

    SQL

    SQL code for using the real-time querying variable

    Description

    Variable description

    Click Check Parameter, set the values of the variables used in the rule, and click Check Syntax.

    If the check fails, modify the code as prompted and perform the check again.

  4. After your code passes the syntax check, click OK to add a real-time query variable.

    Select the variable on the Real-Time Query Variable page. You can choose More > Online or Offline to bring the variable online or take it offline.