Updated on 2025-08-21 GMT+08:00

Querying a Structuring Rule

Function

This API is used to query the structuring rule of a specified log stream.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/lts/struct/template

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. It can be obtained by calling an API or from the console. For details, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

logGroupId

Yes

String

Definition

Log group ID. For details about how to obtain it, see Obtaining Log Group and Log Stream IDs.

Constraints

N/A

Range

N/A

Default Value

N/A

logStreamId

Yes

String

Definition

Log stream ID. For details about how to obtain it, see Obtaining Log Group and Log Stream IDs.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token obtained from IAM. For details about how to obtain it, see Obtaining a User Token.

Constraints:

N/A

Range

N/A

Default Value

N/A

Content-Type

Yes

String

Definition

Message body format. Set this parameter to application/json;charset=utf8.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

demoFields

Array of StructFieldInfoReturn objects

Definition

Fields generated after the sample log event is parsed based on the structuring configuration.

tagFields

Array of tag_fields_info objects

Definition

Fixed fields generated based on the log reporting channel or static fields manually configured by the user.

demoLog

String

Definition

Sample log event.

Range

N/A

demoLabel

String

Definition

Complete JSON structure example of the sample log and system fields.

Range

N/A

id

String

Definition

Structuring configuration ID.

Range

N/A

logGroupId

String

Definition

Log group ID.

Range

N/A

rule

TemplateRule object

Definition

Structuring method.

cluster_info

ShowStructTemplateclusterInfo object

Definition

Kafka cluster information.

logStreamId

String

Definition

Log stream ID.

Range

N/A

projectId

String

Definition

Project ID.

Range

N/A

templateName

String

Definition

Structuring template name.

Range

N/A

regex

String

Definition

Regular expression.

Range

N/A

custom_time_info

customTimeInfo object

Definition

Parameters related to the custom time in the structuring configuration.

Range

N/A

uploadOriginalLog

Boolean

Definition

Whether to upload raw logs.

Range

  • true

  • false

uploadParseFailedLog

Boolean

Definition

Whether to upload the raw logs that fail to be parsed to the specified system fields.

Range

  • true

  • false

Table 5 StructFieldInfoReturn

Parameter

Type

Description

fieldName

String

Definition

Name of an extracted field.

Range

N/A

type

String

Definition

Field data type.

Range

  • string

  • long

  • float

content

String

Definition

Sample content of the extracted field.

Range

N/A

isAnalysis

Boolean

Definition

Whether quick analysis is enabled. If indexing is configured, the quick analysis setting specified on the Index Settings tab page is applied.

Range

  • true: enables quick analysis.

  • false: disables quick analysis.

index

Integer

Definition

Field sequence number in regular expression and delimiter methods.

Range

N/A

Table 6 tag_fields_info

Parameter

Type

Description

fieldName

String

Definition

Tag field name.

Range

N/A

type

String

Definition

Tag field type.

Range

  • string

  • float

  • long

content

String

Definition

Sample content of the tag field.

Range

N/A

isAnalysis

Boolean

Definition

Whether quick analysis is enabled. If indexing is configured, the quick analysis setting specified on the Index Settings tab page is applied.

Range

  • true: enables quick analysis.

  • false: disables quick analysis.

index

Integer

Definition

Field sequence number.

Range

N/A

Table 7 TemplateRule

Parameter

Type

Description

type

String

Definition

Structuring method of the structuring template.

Range

  • regex

  • json

  • split

  • nginx

  • built_in

  • custom_regex

  • regex_auto

param

String

Definition

Structuring parameter. It contains configuration parameters required for the corresponding structuring type. For example, if type is set to split, the param field returns a JSON string containing delimiters. If type is set to regex, the param field returns the configured regular expression.

Range

N/A

Table 8 ShowStructTemplateclusterInfo

Parameter

Type

Description

cluster_name

String

Definition

Kafka cluster name.

Range

N/A

kafka_bootstrap_servers

String

Definition

The Kafka cluster's server address.

Range

N/A

kafka_ssl_enable

Boolean

Definition

Whether SSL encrypted authentication is enabled for Kafka.

Range

  • true: SSL encryption authentication is enabled.

  • false: SSL encryption authentication is disabled.

Table 9 customTimeInfo

Parameter

Type

Description

enable

Boolean

Definition

Whether to enable the custom time field.

Range

  • true

  • false

key

String

Definition

Field name selected from demoField as the log system time.

Range

N/A

value

String

Definition

Sample field content selected from demoField as the log system time.

Range

N/A

time_format

String

Definition

Time format parameter for parsing a field as the time type.

Range

N/A

Status code: 400

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Status code: 401

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Status code: 403

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Status code: 500

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Example Requests

GET https://{endpoint}/v2/{project_id}/lts/struct/template

/v2/{project_id}/lts/struct/template?logGroupId={logGroupId} &logStreamId={logStreamId}

Example Responses

Status code: 200

The request is successful and details of the structuring rule are returned.

{
  "custom_time_info" : {
    "enable" : false,
    "key" : "",
    "value" : ""
  },
  "demoFields" : [ {
    "content" : "aaa",
    "fieldName" : "field1",
    "index" : 0,
    "isAnalysis" : true,
    "type" : "string"
  }, {
    "content" : "bbb",
    "fieldName" : "field2",
    "index" : 1,
    "isAnalysis" : true,
    "type" : "string"
  }, {
    "content" : "ccc",
    "fieldName" : "field3",
    "index" : 2,
    "isAnalysis" : true,
    "type" : "string"
  }, {
    "content" : "ddd",
    "fieldName" : "field4",
    "index" : 3,
    "isAnalysis" : true,
    "type" : "string"
  } ],
  "demoLabel" : "{}",
  "demoLog" : "aaa bbb ccc ddd",
  "id" : "a0a1xxxxxx4491185d7cf26c3e86ada_86b5xxxx-11df-4361-b48e-b3861c3c761c_xxxx02c7-1dac-47d0-b3ef-39e2ed4e70da",
  "logGroupId" : "86b5xxxx-11df-4361-b48e-b3861c3c761c",
  "logStreamId" : "d9c4xxxx-1dac-47d0-b3ef-39e2ed4e70da",
  "projectId" : "a0a1xxxxxx4491185d7cf26c3e86ada",
  "rule" : {
    "param" : "{ \" keyObject \" :{ \" 0 \" : \" field1 \" , \" 1 \" : \" field2 \" , \" 2 \" : \" field3 \" , \" 3 \" : \" field4 \" }, \" tokenizer \" : \"   \" , \" split_type \" : \" char \" }",
    "type" : "split"
  },
  "tagFields" : [ ],
  "uploadOriginalLog" : true,
  "uploadParseFailedLog" : false
}

Status code: 400

Invalid request. Modify the request based on the description in error_msg before a retry.

{
  "errorCode" : "SVCSTG.ALS.200201",
  "errorMessage" : "Query Param is error."
}

Status code: 401

Authentication failed. Check the token and try again.

{
  "error_code" : "LTS.0414",
  "error_msg" : "Invalid token"
}

Status code: 403

Request rejected. The server has received the request and understood it, but refuses to respond to it. The client should not repeat the request without modifications.

{
  "error_code" : "LTS.0001",
  "error_msg" : "Invalid projectId"
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "error_code" : "LTS.0102",
  "error_msg" : "Query empty."
}

Status Codes

Status Code

Description

200

The request is successful and details of the structuring rule are returned.

400

Invalid request. Modify the request based on the description in error_msg before a retry.

401

Authentication failed. Check the token and try again.

403

Request rejected. The server has received the request and understood it, but refuses to respond to it. The client should not repeat the request without modifications.

500

The server has received the request but encountered an internal error.

503

The requested service is unavailable.

Error Codes

See Error Codes.