This topic describes how to use the data demo package to generate data that simulates data in a real environment and use the data in subsequent data analytics.

Prerequisites

  • A Tablestore instance is created in the China (Beijing) region. The instance name and endpoint used to access the instance are recorded. You can log on to the Tablestore console and click the instance in the Instance Name column on the Overview or All Instances page to obtain the endpoint used to access the instance. If you access the instance across regions, we recommend that you use the public endpoint. For more information, see Activate services.
  • The AccessKey ID and AccessKey secret of your Alibaba Cloud account are obtained. You can log on to the Alibaba Cloud Management Console by using your Alibaba Cloud account and view the AccessKey ID and AccessKey secret on the Security Management page.
    Note The AccessKey ID and AccessKey secret of your Alibaba Cloud account are the credentials to access Alibaba Cloud APIs. Make sure that your AccessKey pair is safe.

Procedure

  1. Download the data demo package.
    You can download one of the following data demo packages based on your operating system. In this topic, the Windows 7 64-bit operating system is used.
  2. Configure the data demo.
    Decompress the data demo package and edit the app.conf file in the conf folder. Configure the environment

    The following content is an example of the app.conf file:

    endpoint = "https://workshop-bj-001.cn-beijing.ots.aliyuncs.com"
    instanceName = "workshop-bj-001"
    accessKeyId = "LTAIF24u7g******"
    accessKeySecret = "CcwFeF3sWTPy0wsKULMw34Px******"
    usercount = "200"
    daysCount = "7"
    You must modify the following parameters:
    • endpoint: the endpoint that is used to access the Tablestore instance. We recommend that you use the public endpoint. You can log on to the Tablestore console. On the Overview page, click the instance in the Instance Name column. On the Instance Management page, view the endpoint from the Instance Access URL section on the Instance Details tab.
    • instanceName: the name of the Tablestore instance. You can obtain the instance name from the Overview page in the Tablestore console.
    • accessKeyId and accessKeySecret: the AccessKey pair that is used to access Alibaba Cloud APIs.
  3. Start the data demo to test data.
    1. Start Command Prompt in Windows, go to the directory in which the data demo package is saved, and run the following command to view the usage of commands that are related to the data demo:
      workshop_demo.exe -h
      The command returns the following results:
      ...\workshop_demo>workshop_demo.exe -h 
      prepare will prepare the data
      raw 00005 "2017-12-19" will query user data by user id and time
      new/day_active/month_active/day_pv/month_pv will query metrics data 
      • prepare: prepares test data, creates data tables, and generates weekly user behavior logs based on the number of users specified in the app.conf file.
      • raw and raw ${userid} ${date} ${Number of top logs}: queries a specified number of logs of the specified user on the specified date.
      • new/day_active/month_active/day_pv/month_pv: queries the report data in result tables based on the following report types:
        • new
        • day_active
        • month_active
        • day_pv
        • month_pv
    2. Run the following command to generate test data:
      ...\workshop_demo>workshop_demo.exe prepare
      The following figure shows the command output. Test data

    In this process, the data demo package automatically creates two tables in Tablestore. The following tables describe the columns in the created tables.

    • Raw log table: user_trace_log
      Column Data type Description
      md5 STRING The MD5 value of the user ID. This column is a primary key column.
      uid STRING The user ID. This column is a primary key column.
      ts BIGINT The timestamp from when the user performed operations. This column is a primary key column.
      ip STRING The IP address of the client that sends requests.
      status BIGINT The status code returned by the server.
      bytes BIGINT The number of bytes sent to the client.
      device STRING The model of the terminal used by the user.
      system STRING The version of the operating system used by the user, in the format of iosxxx or androidxxx.
      customize_event STRING The custom event, which is logon, exit, purchase, register, click, run at the background, switch user, or browse.
      use_time BIGINT The duration for which an app is used at one time. This column is available when the custom event is exit, background running, or user switch.
      customize_event_content STRING The content of the custom event.
    • Analysis result table: analysis_result
      Column Data type Description
      metric STRING The report type. Valid values: new, day_active, month_active, day_pv, and month_pv. This column is a primary key column.
      ds STRING The data timestamp, in the format of yyyy-mm-dd or yyyy-mm. This column is a primary key column.
      num BIGINT The value of the specified metric.
  4. Verify data.
    • Query log details of a specified user.
      Run the following command to query a specified number of logs of a specified user on a specified date. In the command, set the date to when the logs are generated.
      raw ${userid} ${date} ${Number of top logs}
      In the preceding command, ${userid} indicates the user ID, ${date} indicates the date when the logs are generated, and ${Number of top logs} indicates the number of logs to query. For example, if a table is created on June 15, 2019, you can run the workshop_demo.exe raw 00010 "2019-06-15" 20 command to query 20 logs for the user whose ID is 00010. Log details
      Note Tablestore is schema-free. Therefore, you do not need to predefine attribute columns. Different events in the customize_event column have different event content. Therefore, the data demo generates both a custom event and its content in a data record.
    • Query data in the analysis result table.
      You can run the workshop_demo.exe day_active command to query the number of daily active users. Daily active users