Collecting Logs from CTS

Scenario

You can enable trace analysis on the Cloud Trace Service (CTS) console to report traces to LTS, so you can analyze the traces on the LTS console.

Prerequisites

You have enabled CTS.

Reporting Traces from a Management Tracker

When you enable CTS, a management tracker named system is automatically created. Enable trace analysis of the tracker to report traces to LTS:

  1. Log in to the management console.
  2. Click in the upper left corner to select the desired region and project.
  3. Choose Service List > Management & Deployment > Cloud Trace Service.
  4. In the navigation pane on the left, choose Trackers.
  5. Click Configure in the Operation column of the row containing the system tracker. On the displayed Configure Tracker page, configure the tracker parameters.
    Table 1 Management tracker parameters

    Parameter

    Description

    Example Value

    Tracker Type

    The default value is Management.

    Management

    Tracker Name

    The default value is system.

    system

    Trace Analysis

    Enable Trace Analysis to connect the tracker to LTS.

    -

    Trace Analysis Path

    When Trace Analysis is enabled, a log group named CTS and a log stream named system-trace are automatically created.

    CTS/system-trace

    Transfer to OBS

    • If you select Yes for Transfer to OBS, select an existing OBS bucket or create one directly on the Configure Tracker page, and configure File Prefix.
    • If you select No for Transfer to OBS, you do not need to configure any parameter related to trace transfer.

    -

    Create OBS Bucket

    Choose whether you want to create a new OBS bucket.

    -

    OBS Bucket

    • If you enable Create OBS Bucket, an OBS bucket will be automatically created with the name you enter.
    • If you disable Create OBS Bucket, select an existing OBS bucket.

    cts-obs02

    File Prefix

    A prefix is used to mark a transferred trace file. Your specified prefix will be automatically added to the beginning of the name of a transferred file, helping you quickly filter files.

    -

    Encrypt Trace File

    Choose whether to encrypt trace files.

    Yes

    Verify Trace File

    Choose whether to enable file integrity verification.

    -

  6. Click OK.
  7. View CTS traces in real time on the LTS console. You can also structure the traces for future query and analysis:
    1. On the log stream details page of the LTS console, click Log Configuration in the navigation pane and click the Log Structuring tab.
    2. Select Structuring Template, select the system template for CTS, and click Save. On the log structuring details page, you can enable Quick Analysis.

Reporting Traces from a Data Tracker

You can create a data tracker in CTS and use it to report traces to LTS.

  1. On the CTS console, choose Trackers in the navigation pane on the left.
  2. In the upper right corner of the page, click Create Tracker. Configure the tracker parameters in the Create Tracker dialog box displayed.
    Table 2 Data tracker parameters

    Parameter

    Description

    Example Value

    Tracker Type

    Only Data can be selected.

    Data

    Tracker Name

    Name of the tracker.

    ctstra1

    OBS Bucket

    Select an OBS bucket to track.

    obs01

    Operation

    Select the operations to track. The options are:

    • Read
    • Write

    -

    Trace Analysis

    Enable Trace Analysis to connect the tracker to LTS.

    -

    Trace Analysis Path

    When Trace Analysis is enabled, a log group named CTS and a log stream named ctstra1 are automatically created.

    CTS/ctstra1

    Transfer to OBS

    • If you select Yes for Transfer to OBS, select an existing OBS bucket or create one directly on the Configure Tracker page, and configure File Prefix.
    • If you select No for Transfer to OBS, you do not need to configure any parameter related to trace transfer.

    -

    Create OBS Bucket

    Choose whether you want to create a new OBS bucket.

    -

    OBS Bucket

    • If you enable Create OBS Bucket, an OBS bucket will be automatically created with the name you enter.
    • If you disable Create OBS Bucket, select an existing OBS bucket.

    cts-obs01

    Retention Period

    Select how long the traces will be stored in the OBS bucket.

    30 days

    File Prefix

    A prefix is used to mark a transferred trace file. Your specified prefix will be automatically added to the beginning of the name of a transferred file, helping you quickly filter files.

    -

  3. Click OK. Then you can view traces in real time on the LTS console. You can also structure the traces for future query and analysis.

    If you did not enable trace analysis when you created a data tracker, you can click Configure in the Operation column of the row containing the tracker on the Trackers page and enable Trace Analysis.