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

Adding a Window Variable

Scenario

Service managers can define window variables and use them to query data in Redis streaming tables for subsequent rule calculation. A window variable corresponds to a Flink job.

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 > Window Variables.
  3. Click Add and set the required parameters by referring to the following table.

    Table 1 Parameters for creating a window variable

    Parameter

    Description

    Event Source Type

    Type of the event source to which the variable belongs.

    Query Primary Key

    The primary key is subjective to the event source type.

    NOTE:
    • Keys read by the window variable from the Redis database. The format is ${Prefix}:${Window variable name}_${Value of primary key 1}_${Value of primary key 2}_... ...". Pay attention to the sequence when selecting primary keys. For example, if you select PID and then UID, the query primary key is ${Prefix}:${Variable name}_${PID}_${UID}.
    • The sequence of primary keys must be the same as that of selected for a corresponding job.

    Name

    Window variable name. The value must start with wv_ and contain 4 to 30 characters, including letters, digits, and underscores (_).

    NOTE:

    The window variable name must be the same as the static value of concat of the SQL statement of a job.

    Type

    Variable type. The value can be string, long, integer, or double.

    Default Value

    Default value of the variable, which must be of the specified type.

    Redis Cluster

    Redis cluster to which the variable belongs

    Batch Variable

    Whether the window variable is also a batch variable. If you select Yes, it is a batch variable, and if you select No, it is a stream variable. These two variables correspond to Flink batch jobs and streaming jobs, respectively.

    Prefix

    Key value prefix in the Redis database.

    Stream/Table

    Stream/Table from which the variable reads

    Description

    Description of the variable

  4. Click OK.

    You can bring the variable online or take it offline, edit, or delete the variable on the Window Variables page. For details about how to operate, see Managing Window Variables.