Updated on 2026-01-05 GMT+08:00

Querying a Structuring Rule

Function

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

URI

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 32

Maximum: 32

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

logGroupId

Yes

String

Log group ID. For details about how to obtain a log group ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 36

Maximum: 36

logStreamId

Yes

String

Log stream ID. For details about how to obtain a log stream ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 36

Maximum: 36

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

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

Minimum: 1000

Maximum: 2000

Content-Type

Yes

String

Set this parameter to application/json;charset=UTF-8.

Minimum: 30

Maximum: 30

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

demoFields

Array of StructFieldInfoReturn objects

Structured field information parsed from logs.

tagFields

Array of tagFieldsInfo objects

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

demoLog

String

Sample log event.

demoLabel

String

This field has been discarded. If a structuring template is used, {} will be returned.

id

String

Structuring rule ID.

logGroupId

String

Log group ID.

rule

ShowStructTemplateRule object

Structuring method.

logStreamId

String

Log stream ID.

projectId

String

Project ID.

templateName

String

Template name.

regex

String

This field has been discarded.

custom_time_info

custom_time_info object

Custom time field information.

sql_analysis_enable

Boolean

Whether to enable the log analysis function. This field has been overwritten by a field with the same name in the index settings.

uploadOriginalLog

String

Whether to report raw logs.

uploadParseFailedLog

String

Whether to report logs that fail to be parsed.

Table 5 StructFieldInfoReturn

Parameter

Type

Description

fieldName

String

Field name.

type

String

Field data type.

content

String

Field content.

isAnalysis

Boolean

Whether parsing is enabled.

index

Integer

Field sequence number.

isLabelField

Boolean

This field is discarded and is no longer used.

isModified

Boolean

This field is discarded and is no longer used.

Table 6 tagFieldsInfo

Parameter

Type

Description

fieldName

String

Field name.

type

String

Field type.

content

String

Content.

isAnalysis

Boolean

Whether parsing is enabled.

index

Integer

Field No.

isModified

String

This field is discarded and is no longer used.

Table 7 ShowStructTemplateRule

Parameter

Type

Description

param

String

Structuring parameter.

type

String

Structuring method. regex is the regular expression structuring parameter of the old version, which is discarded. Its functionality has been replaced by parameters custom_regex and regex_auto.

Range

  • regex

  • json

  • split

  • nginx

  • built_in

  • custom_regex

  • regex_auto

Table 8 custom_time_info

Parameter

Type

Description

enable

Boolean

Whether to enable the custom reporting time function.

key

String

Structured field that is parsed as the reporting time.

time_format

String

Format that is used to parse a structured field into a time type.

value

String

Example of a structured field that is parsed as a time type.

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

GET https://{endpoint}/v2/{project_id}/lts/struct/template?logGroupId=123456&logStreamId=654321

Example Responses

Status code: 200

Details of the structuring rule are returned.

{
  "custom_time_info" : {
    "enable" : false,
    "key" : "",
    "value" : ""
  },
  "demoFields" : [ {
    "content" : "127.0.0.1:8080",
    "end" : "26",
    "fieldName" : "ip",
    "index" : 0,
    "isAnalysis" : true,
    "isLabelField" : false,
    "isModified" : false,
    "start" : "20",
    "type" : "string"
  } ],
  "demoLabel" : "{}",
  "demoLog" : "https://127.0.0.1:8080",
  "id" : "a0a12b069ab4491185d7cf26c3e86ada_86b572f8-11df-4361-b48e-b3861c3c761c_b7ce2abf-1625-42eb-89ea-cb396de4bb15",
  "logGroupId" : "86b572f8-11df-4361-b48e-b3861c3c761c",
  "logStreamId" : "b7ce2abf-1625-42eb-89ea-cb396de4bb15",
  "projectId" : "a0a12b069abxxxx185d7cf26c3e86ada",
  "rule" : {
    "param" : "{\"keyObject\":{\"1\":\"ip\"},\"regex_rules\":\"^(?:[^\\\\.]*\\\\.){1}(\\\\w+)\"}",
    "type" : "regex_auto"
  },
  "sql_analysis_enable" : true,
  "tagFields" : [ {
    "content" : "",
    "fieldName" : "tag1",
    "index" : 0,
    "isAnalysis" : true,
    "isModified" : false,
    "type" : "string"
  } ],
  "uploadOriginalLog" : true,
  "uploadParseFailedLog" : false
}

Status code: 400

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

{
  "error_code" : "SVCSTG.ALS.200201",
  "error_msg" : "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

The request has been rejected. The server has received and understood the request but it refused to respond, because the request is set to deny access. Do not retry the request before modifying it.

{
  "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

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

The request has been rejected. The server has received and understood the request but it refused to respond, because the request is set to deny access. Do not retry the request before modifying it.

500

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

503

The requested service is unavailable.

Error Codes

See Error Codes.